/trunk/Windows/Window.cs |
@@ -26,6 +26,22 @@ |
} |
} |
|
[XmlElement(ElementName = "IgnoreWidth")] |
public bool IgnoreWidth |
{ |
get => _ignoreWidth; |
set |
{ |
if (value == _ignoreWidth) |
{ |
return; |
} |
|
_ignoreWidth = value; |
OnPropertyChanged(); |
} |
} |
|
[XmlElement(ElementName = "Width")] |
public int Width |
{ |
@@ -42,6 +58,22 @@ |
} |
} |
|
[XmlElement(ElementName = "IgnoreHeight")] |
public bool IgnoreHeight |
{ |
get => _ignoreHeight; |
set |
{ |
if (value == _ignoreHeight) |
{ |
return; |
} |
|
_ignoreHeight = value; |
OnPropertyChanged(); |
} |
} |
|
[XmlElement(ElementName = "Height")] |
public int Height |
{ |
@@ -58,6 +90,22 @@ |
} |
} |
|
[XmlElement(ElementName = "IgnoreLeft")] |
public bool IgnoreLeft |
{ |
get => _ignoreLeft; |
set |
{ |
if (value == _ignoreLeft) |
{ |
return; |
} |
|
_ignoreLeft = value; |
OnPropertyChanged(); |
} |
} |
|
[XmlElement(ElementName = "Left")] |
public int Left |
{ |
@@ -74,6 +122,22 @@ |
} |
} |
|
[XmlElement(ElementName = "IgnoreTop")] |
public bool IgnoreTop |
{ |
get => _ignoreTop; |
set |
{ |
if (value == _ignoreTop) |
{ |
return; |
} |
|
_ignoreTop = value; |
OnPropertyChanged(); |
} |
} |
|
[XmlElement(ElementName = "Top")] |
public int Top |
{ |
@@ -96,6 +160,14 @@ |
|
private int _height; |
|
private bool _ignoreHeight; |
|
private bool _ignoreLeft; |
|
private bool _ignoreTop; |
|
private bool _ignoreWidth; |
|
private int _left; |
|
private string _name; |
/trunk/Windows/Windows.cs |
@@ -1,5 +1,9 @@ |
using System.Collections.Generic; |
using System; |
using System.Collections.Generic; |
using System.Collections.ObjectModel; |
using System.Collections.Specialized; |
using System.ComponentModel; |
using System.Linq; |
using System.Runtime.CompilerServices; |
using System.Xml.Serialization; |
using Windows.Annotations; |
@@ -7,12 +11,12 @@ |
namespace Windows |
{ |
[XmlRoot(Namespace = "urn:widow-windows-schema", ElementName = "Windows")] |
public class Windows : INotifyPropertyChanged |
public class Windows : INotifyPropertyChanged, IDisposable |
{ |
#region Public Enums, Properties and Fields |
|
[XmlElement(ElementName = "Window")] |
public List<Window> Window |
public ObservableCollection<Window> Window |
{ |
get => _window; |
set |
@@ -22,7 +26,15 @@ |
return; |
} |
|
_window.CollectionChanged -= _window_CollectionChanged; |
_window = value; |
_windows.Clear(); |
foreach (var window in value) |
{ |
_windows.Add(window.Name); |
} |
|
_window.CollectionChanged += _window_CollectionChanged; |
OnPropertyChanged(); |
} |
} |
@@ -31,8 +43,10 @@ |
|
#region Private Delegates, Events, Enums, Properties, Indexers and Fields |
|
private List<Window> _window = new List<Window>(); |
private ObservableCollection<Window> _window = new ObservableCollection<Window>(); |
|
private HashSet<string> _windows = new HashSet<string>(); |
|
#endregion |
|
#region Constructors, Destructors and Finalizers |
@@ -40,8 +54,14 @@ |
[UsedImplicitly] |
public Windows() |
{ |
_window.CollectionChanged += _window_CollectionChanged; |
} |
|
public void Dispose() |
{ |
Window.CollectionChanged -= _window_CollectionChanged; |
} |
|
#endregion |
|
#region Interface |
@@ -50,6 +70,45 @@ |
|
#endregion |
|
#region Event Handlers |
|
private void _window_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) |
{ |
if (e.OldItems != null) |
{ |
foreach (var window in e.OldItems.OfType<Window>()) |
{ |
if (_windows.Contains(window.Name)) |
{ |
_windows.Remove(window.Name); |
} |
} |
} |
|
|
if (e.NewItems != null) |
{ |
foreach (var window in e.NewItems.OfType<Window>()) |
{ |
if (!_windows.Contains(window.Name)) |
{ |
_windows.Add(window.Name); |
} |
} |
} |
} |
|
#endregion |
|
#region Public Methods |
|
public bool Contains(string name) |
{ |
return _windows.Contains(name); |
} |
|
#endregion |
|
#region Private Methods |
|
[NotifyPropertyChangedInvocator] |