288 lines
6.6 KiB
C#
288 lines
6.6 KiB
C#
using System.Windows.Controls;
|
|
using WPFluent.Gallery.ControlsLookup;
|
|
using WPFluent.Gallery.Models;
|
|
using WPFluent.Gallery.Views.Pages;
|
|
|
|
namespace WPFluent.Gallery.ViewModels.Pages;
|
|
|
|
public partial class BasicInputViewModel : ViewModel
|
|
{
|
|
[ObservableProperty]
|
|
private ICollection<NavigationCard> navigationCards = new ObservableCollection<NavigationCard>(
|
|
ControlPages
|
|
.FromNamespace(typeof(BasicInputPage).Namespace!)
|
|
.Select(x => new NavigationCard()
|
|
{
|
|
Name = x.Name,
|
|
Icon = x.Icon,
|
|
Description = x.Description,
|
|
PageType = x.PageType,
|
|
})
|
|
);
|
|
|
|
#region Anchor
|
|
|
|
[ObservableProperty]
|
|
private bool _isAnchorEnabled = true;
|
|
|
|
[RelayCommand]
|
|
private void OnAnchorCheckboxChecked(object sender)
|
|
{
|
|
if (sender is not CheckBox checkbox)
|
|
{
|
|
return;
|
|
}
|
|
|
|
IsAnchorEnabled = !(checkbox?.IsChecked ?? false);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Button
|
|
[ObservableProperty]
|
|
private bool _isSimpleButtonEnabled = true;
|
|
|
|
[ObservableProperty]
|
|
private bool _isUiButtonEnabled = true;
|
|
|
|
[RelayCommand]
|
|
private void OnSimpleButtonCheckboxChecked(object sender)
|
|
{
|
|
if (sender is not CheckBox checkbox)
|
|
{
|
|
return;
|
|
}
|
|
|
|
IsSimpleButtonEnabled = !(checkbox?.IsChecked ?? false);
|
|
}
|
|
|
|
[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
|
|
|
|
#region ComboBox
|
|
|
|
[ObservableProperty]
|
|
private ObservableCollection<string> _comboBoxFontFamilies =
|
|
[
|
|
"Arial",
|
|
"Comic Sans MS",
|
|
"Segoe UI",
|
|
"Times New Roman",
|
|
];
|
|
|
|
[ObservableProperty]
|
|
private ObservableCollection<int> _comboBoxFontSizes =
|
|
[
|
|
8,
|
|
9,
|
|
10,
|
|
11,
|
|
12,
|
|
14,
|
|
16,
|
|
18,
|
|
20,
|
|
24,
|
|
28,
|
|
36,
|
|
48,
|
|
72,
|
|
];
|
|
|
|
#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);
|
|
}
|
|
}
|
|
}
|