整理控件库

This commit is contained in:
GG Z
2025-05-05 17:04:06 +08:00
parent 74532b77be
commit 3eaad7566e
283 changed files with 2156 additions and 17846 deletions

View File

@@ -1,12 +1,30 @@
using System.Windows.Controls;
using WPFluent.Gallery.ControlsLookup;
using WPFluent.Gallery.Models;
using WPFluent.Gallery.Views.Pages;
namespace WPFluent.Gallery.ViewModels.Pages;
public class Grade
{
public string GradeLevel { get; set; }
public List<Student> Students { get; set; } = [];
}
public class Student
{
public int ID { get; set; }
public string Name { get; set; }
public string Class { get; set; }
}
public partial class BasicInputViewModel : ViewModel
{
public BasicInputViewModel()
{
GenerateTreeViewItem();
}
[ObservableProperty]
private ICollection<NavigationCard> navigationCards = new ObservableCollection<NavigationCard>(
ControlPages
@@ -19,135 +37,52 @@ public partial class BasicInputViewModel : ViewModel
PageType = x.PageType,
})
);
#region Anchor
[ObservableProperty]
private bool _isAnchorEnabled = true;
[RelayCommand]
private void OnAnchorCheckboxChecked(object sender)
private void ButtonClick()
{
if (sender is not CheckBox checkbox)
{
return;
}
IsAnchorEnabled = !(checkbox?.IsChecked ?? false);
Toast.Information("I am information message");
Toast.Error("I am error message");
Toast.Success("I am success message");
Toast.Warning("I am warning message");
Toast.Show(owner: null!, "I am any message", new ToastConfig());
}
public ObservableCollection<Grade> Grades { get; set; } = [];
#endregion
public ObservableCollection<Grade> SelectedItems { get; set; } = [];
#region Button
[ObservableProperty]
private bool _isSimpleButtonEnabled = true;
[ObservableProperty]
private bool _isUiButtonEnabled = true;
[RelayCommand]
private void OnSimpleButtonCheckboxChecked(object sender)
public void GenerateTreeViewItem()
{
if (sender is not CheckBox checkbox)
{
return;
}
IsSimpleButtonEnabled = !(checkbox?.IsChecked ?? false);
Grade item = new() { GradeLevel = "一年级" };
item.Students.Add(new() { Name = "学生11" });
item.Students.Add(new() { Name = "学生12" });
item.Students.Add(new() { Name = "学生13" });
Grade item1 = new() { GradeLevel = "二年级" };
item1.Students.Add(new() { Name = "学生21" });
item1.Students.Add(new() { Name = "学生22" });
Grades.Add(item);
Grades.Add(item1);
}
[RelayCommand]
private void OnUiButtonCheckboxChecked(object sender)
{
if (sender is not CheckBox checkbox)
{
return;
}
IsUiButtonEnabled = !(checkbox?.IsChecked ?? false);
}
[ObservableProperty]
private bool _isToggleSwitchEnabled = true;
[RelayCommand]
private void OnToggleSwitchCheckboxChecked(object sender)
{
if (sender is not CheckBox checkbox)
{
return;
}
IsToggleSwitchEnabled = !(checkbox?.IsChecked ?? false);
}
[ObservableProperty]
private bool _isToggleButtonEnabled = true;
[RelayCommand]
private void OnToggleButtonCheckboxChecked(object sender)
{
if (sender is not CheckBox checkbox)
{
return;
}
IsToggleButtonEnabled = !(checkbox?.IsChecked ?? false);
}
#endregion
#region CheckBox
[ObservableProperty]
private bool? _selectAllCheckBoxChecked = null;
[ObservableProperty]
private bool _optionOneCheckBoxChecked = false;
[ObservableProperty]
private bool _optionTwoCheckBoxChecked = true;
[ObservableProperty]
private bool _optionThreeCheckBoxChecked = false;
[RelayCommand]
private void OnSelectAllChecked(object sender)
{
if (sender is not CheckBox checkBox)
{
return;
}
checkBox.IsChecked ??=
!OptionOneCheckBoxChecked || !OptionTwoCheckBoxChecked || !OptionThreeCheckBoxChecked;
if (checkBox.IsChecked == true)
{
OptionOneCheckBoxChecked = true;
OptionTwoCheckBoxChecked = true;
OptionThreeCheckBoxChecked = true;
}
else if (checkBox.IsChecked == false)
{
OptionOneCheckBoxChecked = false;
OptionTwoCheckBoxChecked = false;
OptionThreeCheckBoxChecked = false;
}
}
[RelayCommand]
private void OnSingleChecked(string option)
{
bool allChecked = OptionOneCheckBoxChecked && OptionTwoCheckBoxChecked && OptionThreeCheckBoxChecked;
bool allUnchecked =
!OptionOneCheckBoxChecked && !OptionTwoCheckBoxChecked && !OptionThreeCheckBoxChecked;
SelectAllCheckBoxChecked =
allChecked ? true
: allUnchecked ? false
: (bool?)null;
}
#endregion
private ObservableCollection<string> animals =
[
"Cat",
"Dog",
"Bear",
"Lion",
"Mouse",
"Horse",
"Rat",
"Elephant",
"Kangaroo",
"Lizard",
"Snake",
"Frog",
"Fish",
"Butterfly",
"Human",
"Cow",
"Bumble Bee"
];
#region ComboBox
@@ -180,108 +115,4 @@ public partial class BasicInputViewModel : ViewModel
];
#endregion
[ObservableProperty]
private bool _isHyperlinkEnabled = true;
[RelayCommand]
private void OnHyperlinkCheckboxChecked(object sender)
{
if (sender is not CheckBox checkbox)
{
return;
}
IsHyperlinkEnabled = !(checkbox?.IsChecked ?? false);
}
[ObservableProperty]
private bool _isRadioButtonEnabled = true;
[RelayCommand]
private void OnRadioButtonCheckboxChecked(object sender)
{
if (sender is not CheckBox checkbox)
{
return;
}
IsRadioButtonEnabled = !(checkbox?.IsChecked ?? false);
}
#region Rating
[ObservableProperty]
private bool _isFirstRatingEnabled = true;
[ObservableProperty]
private double _firstRatingValue = 1.5D;
[ObservableProperty]
private bool _isSecondRatingEnabled = true;
[ObservableProperty]
private double _secondRatingValue = 3D;
[RelayCommand]
private void OnFirstRatingCheckboxChecked(object sender)
{
if (sender is not CheckBox checkbox)
{
return;
}
IsFirstRatingEnabled = !(checkbox?.IsChecked ?? false);
}
[RelayCommand]
private void OnSecondRatingCheckboxChecked(object sender)
{
if (sender is not CheckBox checkbox)
{
return;
}
IsSecondRatingEnabled = !(checkbox?.IsChecked ?? false);
}
#endregion
[ObservableProperty]
private int _simpleSliderValue = 0;
[ObservableProperty]
private int _rangeSliderValue = 500;
[ObservableProperty]
private int _marksSliderValue = 0;
[ObservableProperty]
private int _verticalSliderValue = 0;
[ObservableProperty]
private string _thumRateStateText = "Liked";
[ObservableProperty]
private string _thumRateStateCodeText = "<ui:ThumbRate State=\"Liked\" />";
private ThumbRateState _thumbRateState = ThumbRateState.Liked;
public ThumbRateState ThumbRateState
{
get => _thumbRateState;
set
{
ThumRateStateText = value switch
{
ThumbRateState.Liked => "Liked",
ThumbRateState.Disliked => "Disliked",
_ => "None",
};
ThumRateStateCodeText = $"<ui:ThumbRate State=\"{ThumRateStateText}\" />";
_ = SetProperty(ref _thumbRateState, value);
}
}
}