QuickImage – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | using System; |
2 | using System.Collections.Generic; |
||
3 | using System.ComponentModel; |
||
4 | using System.Linq; |
||
5 | using System.Runtime.CompilerServices; |
||
6 | using System.Text; |
||
7 | using System.Threading.Tasks; |
||
8 | using System.Xml.Serialization; |
||
9 | using static System.Net.Mime.MediaTypeNames; |
||
10 | |||
11 | namespace Configuration |
||
12 | { |
||
13 | [XmlRoot(ElementName = "DragDropConvertExclude")] |
||
14 | public class DragDropConvertExclude : INotifyPropertyChanged |
||
15 | { |
||
16 | public event PropertyChangedEventHandler PropertyChanged; |
||
17 | |||
18 | private Images _images = new Images(); |
||
19 | |||
20 | [XmlElement(ElementName = "Image")] |
||
21 | public Images Images |
||
22 | { |
||
23 | get => _images; |
||
24 | set |
||
25 | { |
||
26 | if (Equals(value, _images)) |
||
27 | { |
||
28 | return; |
||
29 | } |
||
30 | |||
31 | _images = value; |
||
32 | if (value is { Image: { } } && value.Image.Count != 0) |
||
33 | { |
||
34 | excludedImages.UnionWith(value.Image); |
||
35 | } |
||
36 | OnPropertyChanged(); |
||
37 | } |
||
38 | } |
||
39 | |||
40 | private readonly HashSet<string> excludedImages = new HashSet<string>(); |
||
41 | |||
42 | public DragDropConvertExclude() |
||
43 | { |
||
44 | |||
45 | } |
||
46 | |||
47 | public DragDropConvertExclude(string[] mimeTypes) |
||
48 | { |
||
49 | _images.Add(mimeTypes); |
||
50 | excludedImages.UnionWith(mimeTypes); |
||
51 | } |
||
52 | |||
53 | public bool IsExcluded(string mime) |
||
54 | { |
||
55 | return excludedImages.Contains(mime); |
||
56 | } |
||
57 | |||
58 | public bool IsExcludedImage(string mime) |
||
59 | { |
||
60 | return excludedImages.Contains(mime); |
||
61 | } |
||
62 | |||
63 | protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) |
||
64 | { |
||
65 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); |
||
66 | } |
||
67 | |||
68 | protected bool SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = null) |
||
69 | { |
||
70 | if (EqualityComparer<T>.Default.Equals(field, value)) return false; |
||
71 | field = value; |
||
72 | OnPropertyChanged(propertyName); |
||
73 | return true; |
||
74 | } |
||
75 | } |
||
76 | } |