Horizon – Diff between revs 1 and 5
?pathlinks?
Rev 1 | Rev 5 | |||
---|---|---|---|---|
1 | using System.ComponentModel; |
1 | using System.ComponentModel; |
|
2 | using System.Runtime.CompilerServices; |
2 | using System.Runtime.CompilerServices; |
|
3 | using System.Xml.Serialization; |
3 | using System.Xml.Serialization; |
|
4 | using TrackedFolders.Properties; |
4 | using TrackedFolders.Properties; |
|
5 | using TrackedFolders.Utilities; |
5 | using TrackedFolders.Utilities; |
|
6 | |
6 | |
|
7 | namespace TrackedFolders |
7 | namespace TrackedFolders |
|
8 | { |
8 | { |
|
9 | [XmlRoot(Namespace = "urn:horizon-tracked-folders-schema", ElementName = "TrackedFolders")] |
9 | [XmlRoot(Namespace = "urn:horizon-tracked-folders-schema", ElementName = "TrackedFolders")] |
|
10 | public class TrackedFolders : INotifyPropertyChanged |
10 | public class TrackedFolders : INotifyPropertyChanged |
|
11 | { |
11 | { |
|
12 | #region Private Delegates, Events, Enums, Properties, Indexers and Fields |
12 | #region Private Delegates, Events, Enums, Properties, Indexers and Fields |
|
13 | |
13 | |
|
14 | private BindingListWithCollectionChanged<Folder> _folder = new BindingListWithCollectionChanged<Folder>(); |
14 | private BindingListWithCollectionChanged<Folder> _folder = new BindingListWithCollectionChanged<Folder>(); |
|
15 | |
15 | |
|
16 | #endregion |
16 | #endregion |
|
- | 17 | |
||
- | 18 | #region Constructors |
||
- | 19 | |
||
- | 20 | [UsedImplicitly] |
||
- | 21 | public TrackedFolders() |
||
- | 22 | { |
||
- | 23 | |
||
- | 24 | } |
||
- | 25 | |
||
- | 26 | #endregion |
||
17 | |
27 | |
|
18 | #region Public Enums, Properties and Fields |
28 | #region Public Enums, Properties and Fields |
|
19 | |
29 | |
|
20 | public BindingListWithCollectionChanged<Folder> Folder |
30 | public BindingListWithCollectionChanged<Folder> Folder |
|
21 | { |
31 | { |
|
22 | get => _folder; |
32 | get => _folder; |
|
23 | set |
33 | set |
|
24 | { |
34 | { |
|
25 | if (Equals(value, _folder)) |
35 | if (Equals(value, _folder)) |
|
26 | { |
36 | { |
|
27 | return; |
37 | return; |
|
28 | } |
38 | } |
|
29 | |
39 | |
|
30 | _folder = value; |
40 | _folder = value; |
|
31 | OnPropertyChanged(); |
41 | OnPropertyChanged(); |
|
32 | } |
42 | } |
|
33 | } |
43 | } |
|
34 | |
44 | |
|
35 | #endregion |
45 | #endregion |
|
36 | |
46 | |
|
37 | #region Interface |
47 | #region Interface |
|
38 | |
48 | |
|
39 | public event PropertyChangedEventHandler PropertyChanged; |
49 | public event PropertyChangedEventHandler PropertyChanged; |
|
40 | |
50 | |
|
41 | #endregion |
51 | #endregion |
|
42 | |
52 | |
|
43 | #region Private Methods |
53 | #region Private Methods |
|
44 | |
54 | |
|
45 | [NotifyPropertyChangedInvocator] |
55 | [NotifyPropertyChangedInvocator] |
|
46 | protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) |
56 | protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) |
|
47 | { |
57 | { |
|
48 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); |
58 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); |
|
49 | } |
59 | } |
|
50 | |
60 | |
|
51 | #endregion |
61 | #endregion |
|
52 | |
62 | |
|
53 | #region Public Methods |
63 | #region Public Methods |
|
54 | |
64 | |
|
55 | public bool TryGet(string path, out Folder folder) |
65 | public bool TryGet(string path, out Folder folder) |
|
56 | { |
66 | { |
|
57 | foreach (var tracked in Folder) |
67 | foreach (var tracked in Folder) |
|
58 | { |
68 | { |
|
59 | if (!path.IsPathEqual(tracked.Path) && |
69 | if (!path.IsPathEqual(tracked.Path) && |
|
60 | !path.IsSubPathOf(tracked.Path)) |
70 | !path.IsSubPathOf(tracked.Path)) |
|
61 | { |
71 | { |
|
62 | continue; |
72 | continue; |
|
63 | } |
73 | } |
|
64 | |
74 | |
|
65 | folder = tracked; |
75 | folder = tracked; |
|
66 | |
76 | |
|
67 | return true; |
77 | return true; |
|
68 | } |
78 | } |
|
69 | |
79 | |
|
70 | folder = null; |
80 | folder = null; |
|
71 | |
81 | |
|
72 | return false; |
82 | return false; |
|
73 | } |
83 | } |
|
74 | |
84 | |
|
75 | #endregion |
85 | #endregion |
|
76 | } |
86 | } |
|
77 | } |
87 | } |
|
78 | |
88 | |
|
79 |
|
89 |
|
|
80 | |
90 | |
|
81 | |
91 | |
|
82 | |
92 | |