1using CommunityToolkit.Mvvm.ComponentModel;
2using CommunityToolkit.Mvvm.Input;
4using System.Windows.Input;
5using System.Windows.Media;
20 public WorkspaceSetting<T>
Setting {
get; }
35 public string Icon {
get; }
52 private bool _supportResetToDefault;
58 get => _supportResetToDefault;
59 set => SetProperty(ref _supportResetToDefault, value);
80 if (!
Setting.Value.Equals(value))
82 Setting.Value = value;
124 set =>
Value = (T)Convert.ChangeType(value, typeof(T));
142 public WorkspaceSettingViewModel(WorkspaceSetting<T> setting,
string label,
string tooltip,
string icon, Geometry iconGeometry, DataTemplate editorTemplate,
bool supportResetToDefault)
152 OnPropertyChanged(nameof(
Value));
162 OnPropertyChanged(nameof(
Value));
171 setting.PropertyChanged += (sender, e) =>
173 switch(e.PropertyName)
175 case nameof(WorkspaceSetting<T>.
Value): OnPropertyChanged(nameof(
Value));
break;
void Reset()
Set the Value to the SnapshotValue
void SetToDefault()
Set the Value to the DefaultValue
bool SupportResetToDefault
Support for resetting the setting value to the default value.
T MaxValue
Maximum value for the setting.
DataTemplate EditorTemplate
Data template to assign a setting dependent editor view.
bool HasChanged
True, if the setting value is not the snapshot value.
WorkspaceSetting< T > Setting
WorkspaceSetting<T> that is managed by this view model
bool HasDefaultValue
True if the setting value is the default value.
string Tooltip
Tooltip for this setting.
T MinValue
Minimum value for the setting.
object UntypedMaxValue
Maximum value for the setting.
ICommand SetToDefaultCommand
Command to set the setting value back to the default value.
string Label
Label describing the setting.
WorkspaceSettingViewModel(WorkspaceSetting< T > setting, string label, string tooltip, string icon, Geometry iconGeometry, DataTemplate editorTemplate, bool supportResetToDefault)
Constructor for the WorkspaceSettingViewModel<T>
Type ValueType
Type of the setting value.
ICommand ResetCommand
Command to set the setting value back to the snapshot value.
object UntypedValue
Value for the setting.
Geometry IconGeometry
Icon Geometry for this setting.
string Icon
Icon for this setting.
object UntypedMinValue
Minimum value for the setting.
Interface for the workspace setting view model.