2020-05-20 17:40:06 +02:00
|
|
|
|
using System.Linq;
|
2018-06-26 15:01:02 +02:00
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
using Windows.UI.Xaml.Controls;
|
|
|
|
|
using Windows.UI.Xaml.Media;
|
2020-05-20 17:40:06 +02:00
|
|
|
|
using ModernKeePass.ViewModels;
|
2018-06-26 15:01:02 +02:00
|
|
|
|
|
|
|
|
|
// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
|
|
|
|
|
|
|
|
|
|
namespace ModernKeePass.Views.UserControls
|
|
|
|
|
{
|
|
|
|
|
public sealed partial class ColorPickerUserControl
|
|
|
|
|
{
|
2020-05-20 17:40:06 +02:00
|
|
|
|
private ColorPickerControlVm Model => ComboBox.DataContext as ColorPickerControlVm;
|
2018-06-26 15:01:02 +02:00
|
|
|
|
|
|
|
|
|
public SolidColorBrush SelectedColor
|
|
|
|
|
{
|
|
|
|
|
get { return (SolidColorBrush)GetValue(SelectedColorProperty); }
|
|
|
|
|
set { SetValue(SelectedColorProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
public static readonly DependencyProperty SelectedColorProperty =
|
|
|
|
|
DependencyProperty.Register(
|
2020-04-14 13:44:07 +02:00
|
|
|
|
nameof(SelectedColor),
|
2018-06-26 15:01:02 +02:00
|
|
|
|
typeof(SolidColorBrush),
|
|
|
|
|
typeof(ColorPickerUserControl),
|
|
|
|
|
new PropertyMetadata(new SolidColorBrush(), (o, args) => { }));
|
|
|
|
|
|
|
|
|
|
public ColorPickerUserControl()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2020-05-20 17:40:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ComboBox_OnLoaded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Model.Initialize(SelectedColor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.RemovedItems.Any())
|
|
|
|
|
SelectedColor = ComboBox.SelectedValue as SolidColorBrush;
|
2018-06-26 15:01:02 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|