Index: Core/Common/src/Core.Common.Gui/Forms/ViewManager/ViewList.cs
===================================================================
diff -u -r42ca97fdb85a553c6aac3bfdfe57c7be4af90821 -rd53a27a49d8db860ff0894554dab040a1b6204a5
--- Core/Common/src/Core.Common.Gui/Forms/ViewManager/ViewList.cs (.../ViewList.cs) (revision 42ca97fdb85a553c6aac3bfdfe57c7be4af90821)
+++ Core/Common/src/Core.Common.Gui/Forms/ViewManager/ViewList.cs (.../ViewList.cs) (revision d53a27a49d8db860ff0894554dab040a1b6204a5)
@@ -165,7 +165,7 @@
clearing = false;
ActiveView = null;
- FireCollectionChangedEvent(NotifyCollectionChangeAction.Reset, -1, null);
+ FireCollectionChangedEvent(NotifyCollectionChangeEventArgs.CreateCollectionResetArgs());
}
public void Clear(IView viewToKeep)
@@ -353,7 +353,7 @@
views.Remove(view);
- FireCollectionChangedEvent(NotifyCollectionChangeAction.Remove, oldIndex, view);
+ FireCollectionChangedEvent(NotifyCollectionChangeEventArgs.CreateCollectionRemoveArgs(view, oldIndex));
// remove from docking manager
dockingManager.Remove(view, removeTabFromDockingManager);
@@ -410,11 +410,11 @@
}
}
- private void FireCollectionChangedEvent(NotifyCollectionChangeAction notifyCollectionChangeAction, int index, IView item)
+ private void FireCollectionChangedEvent(NotifyCollectionChangeEventArgs eventArgs)
{
if (CollectionChanged != null)
{
- CollectionChanged(this, new NotifyCollectionChangeEventArgs(notifyCollectionChangeAction, item, index, -1));
+ CollectionChanged(this, eventArgs);
}
}
@@ -436,7 +436,7 @@
dockingManager.Add(view, viewLocation);
- FireCollectionChangedEvent(NotifyCollectionChangeAction.Add, index, view);
+ FireCollectionChangedEvent(NotifyCollectionChangeEventArgs.CreateCollectionAddArgs(view, index));
ActiveView = view;
}
Index: Core/Common/src/Core.Common.Utils/Events/EventArgs.cs
===================================================================
diff -u -rfa33f7c078c5d17f92f6a519f147a0a371593944 -rd53a27a49d8db860ff0894554dab040a1b6204a5
--- Core/Common/src/Core.Common.Utils/Events/EventArgs.cs (.../EventArgs.cs) (revision fa33f7c078c5d17f92f6a519f147a0a371593944)
+++ Core/Common/src/Core.Common.Utils/Events/EventArgs.cs (.../EventArgs.cs) (revision d53a27a49d8db860ff0894554dab040a1b6204a5)
@@ -2,13 +2,24 @@
namespace Core.Common.Utils.Events
{
+ ///
+ /// Event arguments with a particular value.
+ ///
+ /// Type of the attached class instance.
public class EventArgs : EventArgs
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The attached instance.
public EventArgs(T t)
{
Value = t;
}
- public T Value { get; set; }
+ ///
+ /// Gets or sets the attached instance.
+ ///
+ public T Value { get; private set; }
}
}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Utils/Events/INotifyCollectionChanged.cs
===================================================================
diff -u -rfa33f7c078c5d17f92f6a519f147a0a371593944 -rd53a27a49d8db860ff0894554dab040a1b6204a5
--- Core/Common/src/Core.Common.Utils/Events/INotifyCollectionChanged.cs (.../INotifyCollectionChanged.cs) (revision fa33f7c078c5d17f92f6a519f147a0a371593944)
+++ Core/Common/src/Core.Common.Utils/Events/INotifyCollectionChanged.cs (.../INotifyCollectionChanged.cs) (revision d53a27a49d8db860ff0894554dab040a1b6204a5)
@@ -1,7 +1,14 @@
namespace Core.Common.Utils.Events
{
+ ///
+ /// Interface for defining collections that fire an event when a collection has changed.
+ ///
public interface INotifyCollectionChanged
{
+ ///
+ /// Occurs when the collection has been changed (such as an element has been added,
+ /// removed, inserted, replaced or the collection has completely been changed).
+ ///
event NotifyCollectionChangedEventHandler CollectionChanged;
}
}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Utils/Events/NotifyCollectionChangeAction.cs
===================================================================
diff -u -rfa33f7c078c5d17f92f6a519f147a0a371593944 -rd53a27a49d8db860ff0894554dab040a1b6204a5
--- Core/Common/src/Core.Common.Utils/Events/NotifyCollectionChangeAction.cs (.../NotifyCollectionChangeAction.cs) (revision fa33f7c078c5d17f92f6a519f147a0a371593944)
+++ Core/Common/src/Core.Common.Utils/Events/NotifyCollectionChangeAction.cs (.../NotifyCollectionChangeAction.cs) (revision d53a27a49d8db860ff0894554dab040a1b6204a5)
@@ -1,13 +1,25 @@
namespace Core.Common.Utils.Events
{
///
- /// Action for changes to a collection such as add, remove.
+ /// Marks the type of action that has been performed on a collection.
///
public enum NotifyCollectionChangeAction
{
+ ///
+ /// An element has been added (or inserted at a specific index).
+ ///
Add,
+ ///
+ /// An element has been removed.
+ ///
Remove,
+ ///
+ /// An element has been replaced by another.
+ ///
Replace,
+ ///
+ /// The collection as a whole as changed.
+ ///
Reset
}
}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Utils/Events/NotifyCollectionChangeEventArgs.cs
===================================================================
diff -u -rfa33f7c078c5d17f92f6a519f147a0a371593944 -rd53a27a49d8db860ff0894554dab040a1b6204a5
--- Core/Common/src/Core.Common.Utils/Events/NotifyCollectionChangeEventArgs.cs (.../NotifyCollectionChangeEventArgs.cs) (revision fa33f7c078c5d17f92f6a519f147a0a371593944)
+++ Core/Common/src/Core.Common.Utils/Events/NotifyCollectionChangeEventArgs.cs (.../NotifyCollectionChangeEventArgs.cs) (revision d53a27a49d8db860ff0894554dab040a1b6204a5)
@@ -3,45 +3,101 @@
namespace Core.Common.Utils.Events
{
///
- /// EventArgs for a collection that include the item and the action.
- ///
- /// Note: for performance reasons we use fields here instead of properties.
+ /// for collection changes.
///
public class NotifyCollectionChangeEventArgs : CancelEventArgs
{
///
- /// Indicate what operation took place such as add, remove etc...
+ /// Initializes a new instance of the class.
///
- public NotifyCollectionChangeAction Action;
+ /// The action that has been reformed on the collection.
+ /// The item affected by the action.
+ /// The current index of .
+ /// The previous index of .
+ public NotifyCollectionChangeEventArgs(NotifyCollectionChangeAction action, object item, int index, int oldIndex)
+ {
+ Action = action;
+ Item = item;
+ OldItem = null;
+ Index = index;
+ OldIndex = oldIndex;
+ }
///
- /// When inserting, this is the position where the item is inserted.
+ /// Initializes a new instance of the class.
///
- public int Index;
-
- ///
- /// Previous index (if changed). TODO: remove it. This is the index at which the insert was intent
- ///
- public int OldIndex;
-
- public NotifyCollectionChangeEventArgs(NotifyCollectionChangeAction action, object item, int index, int oldIndex)
+ /// The action that has been reformed on the collection.
+ /// The item affected by the action.
+ /// The current index of .
+ /// The previous index of .
+ /// The previous value of the effected element that is now replaced with .
+ public NotifyCollectionChangeEventArgs(NotifyCollectionChangeAction action, object item, int index, int oldIndex, object oldItem)
{
Action = action;
Item = item;
+ OldItem = oldItem;
Index = index;
OldIndex = oldIndex;
}
- public NotifyCollectionChangeEventArgs() {}
+ ///
+ /// The operation took place.
+ ///
+ public NotifyCollectionChangeAction Action { get; private set; }
///
- /// The item added, removed or replaced. On replace the new item is given
+ /// The location where the element now resides.
///
- public virtual object Item { get; set; }
+ public int Index { get; private set; }
///
- /// Item that is replaced. (only filled out on replace)
+ /// The location where the element used to reside.
///
- public virtual object OldItem { get; set; }
+ public int OldIndex { get; private set; }
+
+ ///
+ /// The value of the element for which the event was generated.
+ ///
+ public object Item { get; private set; }
+
+ ///
+ /// The value of the element before it was replaced.
+ ///
+ public object OldItem { get; private set; }
+
+ #region Factory methods
+
+ ///
+ /// Creates and initializes an new instance of the
+ /// class for when the collection has completely been reset.
+ ///
+ public static NotifyCollectionChangeEventArgs CreateCollectionResetArgs()
+ {
+ return new NotifyCollectionChangeEventArgs(NotifyCollectionChangeAction.Reset, null, -1, -1);
+ }
+
+ ///
+ /// Creates and initializes an new instance of the
+ /// class for when an element has been added to the collection.
+ ///
+ /// The element that has been added to the collection.
+ /// The index where has been added.
+ public static NotifyCollectionChangeEventArgs CreateCollectionAddArgs(object addedElement, int currentIndex)
+ {
+ return new NotifyCollectionChangeEventArgs(NotifyCollectionChangeAction.Add, addedElement, currentIndex, -1);
+ }
+
+ ///
+ /// Creates and initializes an new instance of the
+ /// class for when an element has been removed from the collection.
+ ///
+ /// The element that has been removed from the collection.
+ /// The index where was removed.
+ public static NotifyCollectionChangeEventArgs CreateCollectionRemoveArgs(object removedElement, int originalIndex)
+ {
+ return new NotifyCollectionChangeEventArgs(NotifyCollectionChangeAction.Remove, removedElement, originalIndex, -1);
+ }
+
+ #endregion
}
}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Utils/Events/NotifyCollectionChangedEventHandler.cs
===================================================================
diff -u -rfa33f7c078c5d17f92f6a519f147a0a371593944 -rd53a27a49d8db860ff0894554dab040a1b6204a5
--- Core/Common/src/Core.Common.Utils/Events/NotifyCollectionChangedEventHandler.cs (.../NotifyCollectionChangedEventHandler.cs) (revision fa33f7c078c5d17f92f6a519f147a0a371593944)
+++ Core/Common/src/Core.Common.Utils/Events/NotifyCollectionChangedEventHandler.cs (.../NotifyCollectionChangedEventHandler.cs) (revision d53a27a49d8db860ff0894554dab040a1b6204a5)
@@ -1,4 +1,9 @@
namespace Core.Common.Utils.Events
{
+ ///
+ /// Defines the event delegate for .
+ ///
+ /// The sender of the event.
+ /// The instance containing the event data.
public delegate void NotifyCollectionChangedEventHandler(object sender, NotifyCollectionChangeEventArgs e);
}
\ No newline at end of file
Index: Core/Common/test/Core.Common.Controls.TreeView.Test/TreeViewControllerTest.cs
===================================================================
diff -u -rd7da4fd9051547085f0cbbec790eda9cb8ca7f14 -rd53a27a49d8db860ff0894554dab040a1b6204a5
--- Core/Common/test/Core.Common.Controls.TreeView.Test/TreeViewControllerTest.cs (.../TreeViewControllerTest.cs) (revision d7da4fd9051547085f0cbbec790eda9cb8ca7f14)
+++ Core/Common/test/Core.Common.Controls.TreeView.Test/TreeViewControllerTest.cs (.../TreeViewControllerTest.cs) (revision d53a27a49d8db860ff0894554dab040a1b6204a5)
@@ -296,7 +296,7 @@
// Collection changed is bubbled to nodePresenter => expect 1 call during parent.Children.Remove(child2);
// not that in some cases Full refresh can be called
- Expect.Call(() => childNodePresenter.OnCollectionChanged(parent, new NotifyCollectionChangeEventArgs())).IgnoreArguments().Repeat.Any();
+ Expect.Call(() => childNodePresenter.OnCollectionChanged(parent, new NotifyCollectionChangeEventArgs(NotifyCollectionChangeAction.Add, null, 0, 0))).IgnoreArguments().Repeat.Any();
mocks.ReplayAll();
Index: Core/Common/test/Core.Common.Test/Gui/ViewListTest.cs
===================================================================
diff -u -rb824d24e9f2698cfd0ba7f253ffd037266c16dc4 -rd53a27a49d8db860ff0894554dab040a1b6204a5
--- Core/Common/test/Core.Common.Test/Gui/ViewListTest.cs (.../ViewListTest.cs) (revision b824d24e9f2698cfd0ba7f253ffd037266c16dc4)
+++ Core/Common/test/Core.Common.Test/Gui/ViewListTest.cs (.../ViewListTest.cs) (revision d53a27a49d8db860ff0894554dab040a1b6204a5)
@@ -10,6 +10,8 @@
using NUnit.Framework;
+using Rhino.Mocks;
+
namespace Core.Common.Test.Gui
{
[TestFixture]
@@ -27,6 +29,8 @@
Text = @"text"
};
+ toolWindowViewManager.Add(view);
+
var senders = new List