-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColorList.xaml.cs
More file actions
64 lines (53 loc) · 2.29 KB
/
ColorList.xaml.cs
File metadata and controls
64 lines (53 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Input;
using System.Windows.Shapes;
using AdvancedColorPicker.Models;
using LoLDuvarKağıtları.Models;
namespace AdvancedColorPicker
{
/// <summary>
/// ColorList.xaml etkileşim mantığı
/// </summary>
public partial class ColorList : INotifyPropertyChanged
{
public ColorList()
{
InitializeComponent();
}
public Theme ParentTheme
{
get => (Theme)GetValue(ParentThemeProperty);
set => SetValue(ParentThemeProperty, value);
}
// Using a DependencyProperty as the backing store for Parent. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ParentThemeProperty =
DependencyProperty.Register("ParentTheme", typeof(Theme), typeof(ColorList));
public ColorHistoryCollection Colors
{
get => (ColorHistoryCollection)GetValue(ColorsProperty);
set => SetValue(ColorsProperty, value);
}
// Using a DependencyProperty as the backing store for Colors. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ColorsProperty =
DependencyProperty.Register("Colors", typeof(ColorHistoryCollection), typeof(ColorList));
private void Rectangle_MouseDown(object sender, MouseButtonEventArgs e)
{
var sourceRect = (Rectangle)sender;
var colorEntry = (ColorEntry)sourceRect.DataContext;
Clipboard.SetText(colorEntry.Color.ToString());
MainWindow.Instance.MainSnackbar.MessageQueue.Enqueue("Hex code copied to the clipboard.");
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public RelayCommand RemoveColorFromThemeCommand => new RelayCommand(x =>
{
ParentTheme.ColorEntries.Remove((ColorEntry) x);
MainWindow.Instance.MainSnackbar.MessageQueue.Enqueue($"Removed {x} from theme.");
});
}
}