Widow

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 10  →  ?path2? @ 11
/trunk/Windows/Window.cs
@@ -10,18 +10,34 @@
{
#region Public Enums, Properties and Fields
 
[XmlElement(ElementName = "Process")]
public string Process
{
get => _process;
set
{
if (value == _process)
{
return;
}
 
_process = value;
OnPropertyChanged();
}
}
 
[XmlElement(ElementName = "Name")]
public string Name
public string Title
{
get => _name;
get => _title;
set
{
if (value == _name)
if (value == _title)
{
return;
}
 
_name = value;
_title = value;
OnPropertyChanged();
}
}
@@ -170,8 +186,10 @@
 
private int _left;
 
private string _name;
private string _process;
 
private string _title;
 
private int _top;
 
private int _width;
@@ -185,9 +203,10 @@
{
}
 
public Window(string name, int top, int left, int width, int height) : this()
public Window(string process, string title, int top, int left, int width, int height) : this()
{
Name = name;
Process = process;
Title = title;
Top = top;
Left = left;
Width = width;
/trunk/Windows/Windows.cs
@@ -26,15 +26,23 @@
return;
}
 
_window.CollectionChanged -= _window_CollectionChanged;
_window = value;
_window.CollectionChanged -= Window_CollectionChanged;
_window.Clear();
 
_windows.Clear();
foreach (var window in value)
{
_windows.Add(window.Name);
_window.Add(window);
 
if (_windows.Contains(window.Title))
{
continue;
}
 
_windows.Add(window.Title);
}
 
_window.CollectionChanged += _window_CollectionChanged;
_window.CollectionChanged += Window_CollectionChanged;
OnPropertyChanged();
}
}
@@ -43,9 +51,9 @@
 
#region Private Delegates, Events, Enums, Properties, Indexers and Fields
 
private ObservableCollection<Window> _window = new ObservableCollection<Window>();
private readonly ObservableCollection<Window> _window = new ObservableCollection<Window>();
 
private HashSet<string> _windows = new HashSet<string>();
private readonly HashSet<string> _windows = new HashSet<string>();
 
#endregion
 
@@ -54,12 +62,12 @@
[UsedImplicitly]
public Windows()
{
_window.CollectionChanged += _window_CollectionChanged;
_window.CollectionChanged += Window_CollectionChanged;
}
 
public void Dispose()
{
Window.CollectionChanged -= _window_CollectionChanged;
Window.CollectionChanged -= Window_CollectionChanged;
}
 
#endregion
@@ -72,15 +80,15 @@
 
#region Event Handlers
 
private void _window_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
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))
if (_windows.Contains(window.Title))
{
_windows.Remove(window.Name);
_windows.Remove(window.Title);
}
}
}
@@ -90,9 +98,9 @@
{
foreach (var window in e.NewItems.OfType<Window>())
{
if (!_windows.Contains(window.Name))
if (!_windows.Contains(window.Title))
{
_windows.Add(window.Name);
_windows.Add(window.Title);
}
}
}
@@ -102,9 +110,9 @@
 
#region Public Methods
 
public bool Contains(string name)
public bool Contains(string hash)
{
return _windows.Contains(name);
return _windows.Contains(hash);
}
 
#endregion