mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-02-04 10:53:31 +00:00
UI - Added new icon picker to profile configuration dialog
This commit is contained in:
parent
07f8209b7b
commit
ed3a770881
@ -19,7 +19,20 @@ public sealed class MaterialIconPickerFlyout : Flyout
|
|||||||
protected override Control CreatePresenter()
|
protected override Control CreatePresenter()
|
||||||
{
|
{
|
||||||
_picker ??= new MaterialIconPicker.MaterialIconPicker();
|
_picker ??= new MaterialIconPicker.MaterialIconPicker();
|
||||||
PickerFlyoutPresenter presenter = new() {Content = MaterialIconPicker};
|
_picker.Flyout = this;
|
||||||
|
FlyoutPresenter presenter = new() {Content = MaterialIconPicker};
|
||||||
return presenter;
|
return presenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Overrides of FlyoutBase
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void OnClosed()
|
||||||
|
{
|
||||||
|
if (_picker != null)
|
||||||
|
_picker.Flyout = null;
|
||||||
|
base.OnClosed();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
@ -5,6 +5,7 @@ using System.Linq;
|
|||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
using Artemis.UI.Shared.Flyouts;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.Primitives;
|
using Avalonia.Controls.Primitives;
|
||||||
@ -28,16 +29,35 @@ public partial class MaterialIconPicker : TemplatedControl
|
|||||||
public static readonly StyledProperty<MaterialIconKind?> ValueProperty =
|
public static readonly StyledProperty<MaterialIconKind?> ValueProperty =
|
||||||
AvaloniaProperty.Register<MaterialIconPicker, MaterialIconKind?>(nameof(Value), defaultBindingMode: BindingMode.TwoWay);
|
AvaloniaProperty.Register<MaterialIconPicker, MaterialIconKind?>(nameof(Value), defaultBindingMode: BindingMode.TwoWay);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the command to execute when deleting stops.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly DirectProperty<MaterialIconPicker, ICommand> SelectIconProperty =
|
||||||
|
AvaloniaProperty.RegisterDirect<MaterialIconPicker, ICommand>(nameof(SelectIcon), g => g.SelectIcon);
|
||||||
|
|
||||||
|
private readonly ICommand _selectIcon;
|
||||||
|
private ItemsRepeater? _iconsContainer;
|
||||||
|
|
||||||
private SourceList<MaterialIconKind>? _iconsSource;
|
private SourceList<MaterialIconKind>? _iconsSource;
|
||||||
private TextBox? _searchBox;
|
private TextBox? _searchBox;
|
||||||
private IDisposable? _sub;
|
private IDisposable? _sub;
|
||||||
private ItemsRepeater? _iconsContainer;
|
private readonly Dictionary<string,MaterialIconKind> _enumNames;
|
||||||
private readonly ICommand _selectIcon;
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public MaterialIconPicker()
|
public MaterialIconPicker()
|
||||||
{
|
{
|
||||||
_selectIcon = ReactiveCommand.Create<MaterialIconKind>(i => Value = i);
|
_selectIcon = ReactiveCommand.Create<MaterialIconKind>(i =>
|
||||||
|
{
|
||||||
|
Value = i;
|
||||||
|
Flyout?.Hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Build a list of enum names and values, this is required because a value may have more than one name
|
||||||
|
_enumNames = new Dictionary<string, MaterialIconKind>();
|
||||||
|
MaterialIconKind[] values = Enum.GetValues<MaterialIconKind>();
|
||||||
|
string[] names = Enum.GetNames<MaterialIconKind>();
|
||||||
|
for (int index = 0; index < names.Length; index++)
|
||||||
|
_enumNames[names[index]] = values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -49,12 +69,6 @@ public partial class MaterialIconPicker : TemplatedControl
|
|||||||
set => SetValue(ValueProperty, value);
|
set => SetValue(ValueProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the command to execute when deleting stops.
|
|
||||||
/// </summary>
|
|
||||||
public static readonly DirectProperty<MaterialIconPicker, ICommand> SelectIconProperty =
|
|
||||||
AvaloniaProperty.RegisterDirect<MaterialIconPicker, ICommand>(nameof(SelectIcon), g => g.SelectIcon);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the command to execute when deleting stops.
|
/// Gets the command to execute when deleting stops.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -64,16 +78,14 @@ public partial class MaterialIconPicker : TemplatedControl
|
|||||||
private init => SetAndRaise(SelectIconProperty, ref _selectIcon, value);
|
private init => SetAndRaise(SelectIconProperty, ref _selectIcon, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Overrides of TemplatedControl
|
internal MaterialIconPickerFlyout? Flyout { get; set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
private void Setup()
|
||||||
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
|
||||||
{
|
{
|
||||||
_searchBox = e.NameScope.Find<TextBox>("SearchBox");
|
if (_searchBox == null || _iconsContainer == null)
|
||||||
_iconsContainer = e.NameScope.Find<ItemsRepeater>("IconsContainer");
|
|
||||||
if (_iconsContainer == null)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Build a list of values, they are not unique because a value with multiple names occurs once per name
|
||||||
_iconsSource = new SourceList<MaterialIconKind>();
|
_iconsSource = new SourceList<MaterialIconKind>();
|
||||||
_iconsSource.AddRange(Enum.GetValues<MaterialIconKind>().Distinct());
|
_iconsSource.AddRange(Enum.GetValues<MaterialIconKind>().Distinct());
|
||||||
_sub = _iconsSource.Connect()
|
_sub = _iconsSource.Connect()
|
||||||
@ -84,6 +96,25 @@ public partial class MaterialIconPicker : TemplatedControl
|
|||||||
_iconsContainer.ItemsSource = icons;
|
_iconsContainer.ItemsSource = icons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Overrides of TemplatedControl
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
||||||
|
{
|
||||||
|
_searchBox = e.NameScope.Find<TextBox>("SearchBox");
|
||||||
|
_iconsContainer = e.NameScope.Find<ItemsRepeater>("IconsContainer");
|
||||||
|
|
||||||
|
Setup();
|
||||||
|
base.OnApplyTemplate(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
|
||||||
|
{
|
||||||
|
Setup();
|
||||||
|
base.OnAttachedToLogicalTree(e);
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
|
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
|
||||||
{
|
{
|
||||||
@ -91,6 +122,9 @@ public partial class MaterialIconPicker : TemplatedControl
|
|||||||
_iconsSource = null;
|
_iconsSource = null;
|
||||||
_sub?.Dispose();
|
_sub?.Dispose();
|
||||||
_sub = null;
|
_sub = null;
|
||||||
|
|
||||||
|
if (_searchBox != null)
|
||||||
|
_searchBox.Text = "";
|
||||||
base.OnDetachedFromLogicalTree(e);
|
base.OnDetachedFromLogicalTree(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,8 +133,11 @@ public partial class MaterialIconPicker : TemplatedControl
|
|||||||
if (string.IsNullOrWhiteSpace(text))
|
if (string.IsNullOrWhiteSpace(text))
|
||||||
return _ => true;
|
return _ => true;
|
||||||
|
|
||||||
|
// Strip out whitespace and find all matching enum values
|
||||||
text = StripWhiteSpaceRegex().Replace(text, "");
|
text = StripWhiteSpaceRegex().Replace(text, "");
|
||||||
return data => data.ToString().Contains(text, StringComparison.InvariantCultureIgnoreCase);
|
HashSet<MaterialIconKind> values = _enumNames.Where(n => n.Key.Contains(text, StringComparison.OrdinalIgnoreCase)).Select(n => n.Value).ToHashSet();
|
||||||
|
// Only show those that matched
|
||||||
|
return data => values.Contains(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
[GeneratedRegex("\\s+")]
|
[GeneratedRegex("\\s+")]
|
||||||
|
|||||||
@ -31,7 +31,7 @@ public class MaterialIconPickerButton : TemplatedControl
|
|||||||
/// Gets or sets the desired flyout placement.
|
/// Gets or sets the desired flyout placement.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly StyledProperty<PlacementMode> PlacementProperty =
|
public static readonly StyledProperty<PlacementMode> PlacementProperty =
|
||||||
AvaloniaProperty.Register<FlyoutBase, PlacementMode>(nameof(Placement));
|
AvaloniaProperty.Register<FlyoutBase, PlacementMode>(nameof(Placement), PlacementMode.BottomEdgeAlignedLeft);
|
||||||
|
|
||||||
private Button? _button;
|
private Button? _button;
|
||||||
private MaterialIconPickerFlyout? _flyout;
|
private MaterialIconPickerFlyout? _flyout;
|
||||||
@ -79,14 +79,21 @@ public class MaterialIconPickerButton : TemplatedControl
|
|||||||
if (_flyout == null)
|
if (_flyout == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Logic here is taken from Fluent Avalonia's ColorPicker which also reuses the same control since it's large
|
MaterialIconPickerFlyout flyout = new();
|
||||||
_flyout.MaterialIconPicker.Value = Value;
|
flyout.FlyoutPresenterClasses.Add("material-icon-picker-presenter");
|
||||||
|
flyout.MaterialIconPicker.Value = Value;
|
||||||
_flyout.Placement = Placement;
|
flyout.Placement = Placement;
|
||||||
_flyout.ShowAt(_button != null ? _button : this);
|
|
||||||
_flyoutActive = true;
|
|
||||||
|
|
||||||
|
flyout.Closed += FlyoutOnClosed;
|
||||||
|
flyout.ShowAt(this);
|
||||||
FlyoutOpened?.Invoke(this, EventArgs.Empty);
|
FlyoutOpened?.Invoke(this, EventArgs.Empty);
|
||||||
|
|
||||||
|
void FlyoutOnClosed(object? closedSender, EventArgs closedEventArgs)
|
||||||
|
{
|
||||||
|
Value = flyout.MaterialIconPicker.Value;
|
||||||
|
flyout.Closed -= FlyoutOnClosed;
|
||||||
|
FlyoutClosed?.Invoke(this, EventArgs.Empty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Overrides of TemplatedControl
|
#region Overrides of TemplatedControl
|
||||||
|
|||||||
@ -28,7 +28,6 @@
|
|||||||
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
|
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<ControlTemplate>
|
<ControlTemplate>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
Name="MainButton"
|
Name="MainButton"
|
||||||
Padding="0 0 12 0"
|
Padding="0 0 12 0"
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
<Styles xmlns="https://github.com/avaloniaui"
|
<Styles xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:materialIconPicker="clr-namespace:Artemis.UI.Shared.MaterialIconPicker">
|
xmlns:materialIconPicker="clr-namespace:Artemis.UI.Shared.MaterialIconPicker"
|
||||||
|
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||||
|
xmlns:converters="clr-namespace:Artemis.UI.Shared.Converters">
|
||||||
<Design.PreviewWith>
|
<Design.PreviewWith>
|
||||||
<Border Padding="20" Width="600" Height="800">
|
<Border Padding="20" Width="600" Height="800">
|
||||||
<StackPanel Spacing="5">
|
<StackPanel Spacing="5">
|
||||||
@ -9,7 +11,8 @@
|
|||||||
</Border>
|
</Border>
|
||||||
</Design.PreviewWith>
|
</Design.PreviewWith>
|
||||||
|
|
||||||
<Style Selector="FlyoutPresenter.data-model-picker-presenter">
|
<Style Selector="FlyoutPresenter.material-icon-picker-presenter">
|
||||||
|
<Setter Property="Padding" Value="0" />
|
||||||
<Setter Property="MaxWidth" Value="1200" />
|
<Setter Property="MaxWidth" Value="1200" />
|
||||||
<Setter Property="MaxHeight" Value="1200" />
|
<Setter Property="MaxHeight" Value="1200" />
|
||||||
<Setter Property="Background" Value="{DynamicResource SolidBackgroundFillColorBaseBrush}" />
|
<Setter Property="Background" Value="{DynamicResource SolidBackgroundFillColorBaseBrush}" />
|
||||||
@ -18,6 +21,9 @@
|
|||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style Selector="materialIconPicker|MaterialIconPickerButton">
|
<Style Selector="materialIconPicker|MaterialIconPickerButton">
|
||||||
|
<Style.Resources>
|
||||||
|
<converters:ToStringConverter x:Key="ToStringConverter" />
|
||||||
|
</Style.Resources>
|
||||||
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrush}" />
|
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrush}" />
|
||||||
<Setter Property="MinHeight" Value="{DynamicResource TextControlThemeMinHeight}" />
|
<Setter Property="MinHeight" Value="{DynamicResource TextControlThemeMinHeight}" />
|
||||||
<Setter Property="MinWidth" Value="{DynamicResource TextControlThemeMinWidth}" />
|
<Setter Property="MinWidth" Value="{DynamicResource TextControlThemeMinWidth}" />
|
||||||
@ -33,16 +39,15 @@
|
|||||||
Height="{TemplateBinding Height}"
|
Height="{TemplateBinding Height}"
|
||||||
HorizontalContentAlignment="Stretch">
|
HorizontalContentAlignment="Stretch">
|
||||||
<Grid ColumnDefinitions="*,Auto" HorizontalAlignment="Stretch">
|
<Grid ColumnDefinitions="*,Auto" HorizontalAlignment="Stretch">
|
||||||
<TextBlock Name="MainButtonLabel"
|
<StackPanel Grid.Column="0" IsVisible="{TemplateBinding Value, Converter={x:Static ObjectConverters.IsNotNull}}" Orientation="Horizontal" Spacing="5">
|
||||||
Grid.Column="0"
|
<avalonia:MaterialIcon Kind="{TemplateBinding Value}"/>
|
||||||
VerticalAlignment="Center"
|
<TextBlock VerticalAlignment="Center" TextAlignment="Left" TextTrimming="CharacterEllipsis" Text="{TemplateBinding Value, Converter={StaticResource ToStringConverter}}"/>
|
||||||
TextAlignment="Left"
|
</StackPanel>
|
||||||
TextTrimming="CharacterEllipsis"
|
|
||||||
Text="{TemplateBinding Value}"
|
|
||||||
IsVisible="{TemplateBinding Value, Converter={x:Static ObjectConverters.IsNotNull}}"/>
|
|
||||||
<TextBlock Grid.Column="0"
|
<TextBlock Grid.Column="0"
|
||||||
Text="{TemplateBinding Placeholder}"
|
Text="{TemplateBinding Placeholder}"
|
||||||
Foreground="{DynamicResource TextControlPlaceholderForeground}"></TextBlock>
|
Foreground="{DynamicResource TextControlPlaceholderForeground}"
|
||||||
|
IsVisible="{TemplateBinding Value, Converter={x:Static ObjectConverters.IsNull}}" />
|
||||||
<TextBlock Name="ChevronTextBlock"
|
<TextBlock Name="ChevronTextBlock"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
FontFamily="{DynamicResource SymbolThemeFontFamily}"
|
FontFamily="{DynamicResource SymbolThemeFontFamily}"
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Sidebar"
|
xmlns:local="clr-namespace:Artemis.UI.Screens.Sidebar"
|
||||||
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
|
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
|
||||||
xmlns:windowing="clr-namespace:FluentAvalonia.UI.Windowing;assembly=FluentAvalonia"
|
xmlns:windowing="clr-namespace:FluentAvalonia.UI.Windowing;assembly=FluentAvalonia"
|
||||||
|
xmlns:materialIconPicker="clr-namespace:Artemis.UI.Shared.MaterialIconPicker;assembly=Artemis.UI.Shared"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="850"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="850"
|
||||||
x:Class="Artemis.UI.Screens.Sidebar.ProfileConfigurationEditView"
|
x:Class="Artemis.UI.Screens.Sidebar.ProfileConfigurationEditView"
|
||||||
x:DataType="local:ProfileConfigurationEditViewModel"
|
x:DataType="local:ProfileConfigurationEditViewModel"
|
||||||
@ -108,27 +109,12 @@
|
|||||||
<Border Background="{DynamicResource CheckerboardBrush}" CornerRadius="{DynamicResource CardCornerRadius}" Width="78" Height="78">
|
<Border Background="{DynamicResource CheckerboardBrush}" CornerRadius="{DynamicResource CardCornerRadius}" Width="78" Height="78">
|
||||||
<avalonia:MaterialIcon Kind="{CompiledBinding SelectedMaterialIcon.Icon}" Width="45" Height="45" />
|
<avalonia:MaterialIcon Kind="{CompiledBinding SelectedMaterialIcon.Icon}" Width="45" Height="45" />
|
||||||
</Border>
|
</Border>
|
||||||
<ComboBox ItemsSource="{CompiledBinding MaterialIcons}"
|
<materialIconPicker:MaterialIconPickerButton
|
||||||
SelectedItem="{CompiledBinding SelectedMaterialIcon}"
|
Value="{CompiledBinding SelectedMaterialIcon.Icon}"
|
||||||
VerticalAlignment="Bottom"
|
|
||||||
IsTextSearchEnabled="True"
|
|
||||||
Margin="10 0"
|
Margin="10 0"
|
||||||
Width="250"
|
Width="250"
|
||||||
IsVisible="{CompiledBinding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.MaterialIcon}}">
|
VerticalAlignment="Bottom"
|
||||||
<ComboBox.ItemsPanel>
|
IsVisible="{CompiledBinding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.MaterialIcon}}"/>
|
||||||
<ItemsPanelTemplate>
|
|
||||||
<VirtualizingStackPanel Width="250"/>
|
|
||||||
</ItemsPanelTemplate>
|
|
||||||
</ComboBox.ItemsPanel>
|
|
||||||
<ComboBox.ItemTemplate>
|
|
||||||
<DataTemplate DataType="local:ProfileIconViewModel">
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<avalonia:MaterialIcon Kind="{CompiledBinding Icon}" Margin="0 0 5 0" />
|
|
||||||
<TextBlock Text="{CompiledBinding DisplayName}" />
|
|
||||||
</StackPanel>
|
|
||||||
</DataTemplate>
|
|
||||||
</ComboBox.ItemTemplate>
|
|
||||||
</ComboBox>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<CheckBox VerticalAlignment="Bottom" IsChecked="{CompiledBinding FadeInAndOut}" ToolTip.Tip="Smoothly animates in and out when the profile activation conditions change.">
|
<CheckBox VerticalAlignment="Bottom" IsChecked="{CompiledBinding FadeInAndOut}" ToolTip.Tip="Smoothly animates in and out when the profile activation conditions change.">
|
||||||
|
|||||||
@ -32,7 +32,6 @@ public class ProfileConfigurationEditViewModel : DialogViewModelBase<ProfileConf
|
|||||||
private bool _fadeInAndOut;
|
private bool _fadeInAndOut;
|
||||||
private ProfileConfigurationHotkeyMode _hotkeyMode;
|
private ProfileConfigurationHotkeyMode _hotkeyMode;
|
||||||
private ProfileConfigurationIconType _iconType;
|
private ProfileConfigurationIconType _iconType;
|
||||||
private ObservableCollection<ProfileIconViewModel>? _materialIcons;
|
|
||||||
private ProfileConfiguration _profileConfiguration;
|
private ProfileConfiguration _profileConfiguration;
|
||||||
private string _profileName;
|
private string _profileName;
|
||||||
private Bitmap? _selectedBitmapSource;
|
private Bitmap? _selectedBitmapSource;
|
||||||
@ -186,12 +185,6 @@ public class ProfileConfigurationEditViewModel : DialogViewModelBase<ProfileConf
|
|||||||
set => RaiseAndSetIfChanged(ref _iconType, value);
|
set => RaiseAndSetIfChanged(ref _iconType, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableCollection<ProfileIconViewModel>? MaterialIcons
|
|
||||||
{
|
|
||||||
get => _materialIcons;
|
|
||||||
set => RaiseAndSetIfChanged(ref _materialIcons, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProfileIconViewModel? SelectedMaterialIcon
|
public ProfileIconViewModel? SelectedMaterialIcon
|
||||||
{
|
{
|
||||||
get => _selectedMaterialIcon;
|
get => _selectedMaterialIcon;
|
||||||
@ -227,7 +220,6 @@ public class ProfileConfigurationEditViewModel : DialogViewModelBase<ProfileConf
|
|||||||
SelectedMaterialIcon = !IsNew && Enum.TryParse(_profileConfiguration.Icon.IconName, out MaterialIconKind enumValue)
|
SelectedMaterialIcon = !IsNew && Enum.TryParse(_profileConfiguration.Icon.IconName, out MaterialIconKind enumValue)
|
||||||
? icons.FirstOrDefault(m => m.Icon == enumValue)
|
? icons.FirstOrDefault(m => m.Icon == enumValue)
|
||||||
: icons.ElementAt(new Random().Next(0, icons.Count - 1));
|
: icons.ElementAt(new Random().Next(0, icons.Count - 1));
|
||||||
MaterialIcons = icons;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SaveIcon()
|
private async Task SaveIcon()
|
||||||
|
|||||||
@ -5,11 +5,20 @@ namespace Artemis.UI.Screens.Sidebar;
|
|||||||
|
|
||||||
public class ProfileIconViewModel : ViewModelBase
|
public class ProfileIconViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
|
private MaterialIconKind _icon;
|
||||||
|
|
||||||
public ProfileIconViewModel(MaterialIconKind icon)
|
public ProfileIconViewModel(MaterialIconKind icon)
|
||||||
{
|
{
|
||||||
Icon = icon;
|
Icon = icon;
|
||||||
DisplayName = icon.ToString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MaterialIconKind Icon { get; }
|
public MaterialIconKind Icon
|
||||||
|
{
|
||||||
|
get => _icon;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
RaiseAndSetIfChanged(ref _icon, value);
|
||||||
|
DisplayName = _icon.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -61,7 +61,8 @@
|
|||||||
</Button>
|
</Button>
|
||||||
<gradientPicker:GradientPickerButton ColorGradient="{CompiledBinding ColorGradient}" IsCompact="True" />
|
<gradientPicker:GradientPickerButton ColorGradient="{CompiledBinding ColorGradient}" IsCompact="True" />
|
||||||
|
|
||||||
<materialIconPicker:MaterialIconPickerButton/>
|
<materialIconPicker:MaterialIconPickerButton Name="IconPicker" Value="Abc"/>
|
||||||
|
<TextBlock Text="{CompiledBinding #IconPicker.Value}"></TextBlock>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user