diff --git a/Nuclex.Windows.Forms.csproj b/Nuclex.Windows.Forms.csproj index 3ecfd66..15c6756 100644 --- a/Nuclex.Windows.Forms.csproj +++ b/Nuclex.Windows.Forms.csproj @@ -2,7 +2,7 @@ Debug AnyCPU - 9.0.21022 + 9.0.30729 2.0 {BDC43D2A-7638-412E-976A-E7E115803A27} Library @@ -79,7 +79,6 @@ ContainerListView.cs - Form diff --git a/Source/ContainerListView/ContainerListView.cs b/Source/ContainerListView/ContainerListView.cs index c2a5310..1994e8a 100644 --- a/Source/ContainerListView/ContainerListView.cs +++ b/Source/ContainerListView/ContainerListView.cs @@ -27,6 +27,8 @@ using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; +using Nuclex.Support.Collections; + namespace Nuclex.Windows.Forms { /// ListView allowing for other controls to be embedded in its cells @@ -44,20 +46,13 @@ namespace Nuclex.Windows.Forms { public ContainerListView() { this.embeddedControlClickedDelegate = new EventHandler(embeddedControlClicked); - this.embeddedControls = new ListViewEmbeddedControlCollection(); + this.embeddedControls = new ObservableCollection(); - this.embeddedControls.Added += - new EventHandler( - embeddedControlAdded - ); - - this.embeddedControls.Removed += - new EventHandler( - embeddedControlRemoved - ); - - this.embeddedControls.Clearing += - new EventHandler(embeddedControlsClearing); + this.embeddedControls.ItemAdded += + new EventHandler>(embeddedControlAdded); + this.embeddedControls.ItemRemoved += + new EventHandler>(embeddedControlRemoved); + this.embeddedControls.Clearing += new EventHandler(embeddedControlsClearing); InitializeComponent(); @@ -88,10 +83,10 @@ namespace Nuclex.Windows.Forms { /// private void embeddedControlAdded( object sender, - ListViewEmbeddedControlCollection.ListViewEmbeddedControlEventArgs arguments + ItemEventArgs arguments ) { - arguments.EmbeddedControl.Control.Click += this.embeddedControlClickedDelegate; - this.Controls.Add(arguments.EmbeddedControl.Control); + arguments.Item.Control.Click += this.embeddedControlClickedDelegate; + this.Controls.Add(arguments.Item.Control); } /// Called when a control gets added to the embedded controls list @@ -101,11 +96,11 @@ namespace Nuclex.Windows.Forms { /// private void embeddedControlRemoved( object sender, - ListViewEmbeddedControlCollection.ListViewEmbeddedControlEventArgs arguments + ItemEventArgs arguments ) { - if(this.Controls.Contains(arguments.EmbeddedControl.Control)) { - arguments.EmbeddedControl.Control.Click -= this.embeddedControlClickedDelegate; - this.Controls.Remove(arguments.EmbeddedControl.Control); + if(this.Controls.Contains(arguments.Item.Control)) { + arguments.Item.Control.Click -= this.embeddedControlClickedDelegate; + this.Controls.Remove(arguments.Item.Control); } } @@ -182,7 +177,7 @@ namespace Nuclex.Windows.Forms { /// Event handler for when embedded controls are clicked on private EventHandler embeddedControlClickedDelegate; /// Controls being embedded in this ListView - private ListViewEmbeddedControlCollection embeddedControls; + private ObservableCollection embeddedControls; } diff --git a/Source/ContainerListView/ListViewEmbeddedControlCollection.cs b/Source/ContainerListView/ListViewEmbeddedControlCollection.cs deleted file mode 100644 index 65ab13a..0000000 --- a/Source/ContainerListView/ListViewEmbeddedControlCollection.cs +++ /dev/null @@ -1,133 +0,0 @@ -#region CPL License -/* -Nuclex Framework -Copyright (C) 2002-2007 Nuclex Development Labs - -This library is free software; you can redistribute it and/or -modify it under the terms of the IBM Common Public License as -published by the IBM Corporation; either version 1.0 of the -License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -IBM Common Public License for more details. - -You should have received a copy of the IBM Common Public -License along with this library -*/ -#endregion - -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; - -namespace Nuclex.Windows.Forms { - - /// Collection of controls embedded in a ListView - public class ListViewEmbeddedControlCollection : Collection { - - #region class ListViewEmbeddedControlEventArgs - - /// Arguments class for events that need to pass a control - public class ListViewEmbeddedControlEventArgs : EventArgs { - - /// Initializes a new event arguments supplier - /// Control to be supplied to the event handler - public ListViewEmbeddedControlEventArgs(ListViewEmbeddedControl embeddedControl) { - this.embeddedControl = embeddedControl; - } - - /// Obtains the control the event arguments are carrying - public ListViewEmbeddedControl EmbeddedControl { - get { return this.embeddedControl; } - } - - /// Control that's passed to the event handler - private ListViewEmbeddedControl embeddedControl; - - } - - #endregion // class ListViewEmbeddedControlEventArgs - - /// Raised when a control has been added to the collection - public event EventHandler Added; - /// Raised when a control is removed from the collection - public event EventHandler Removed; - /// Raised when the collection is about to be cleared - public event EventHandler Clearing; - - /// Removes all elements from the ListViewEmbeddedControlCollection - protected override void ClearItems() { - OnClearing(); - - base.ClearItems(); - } - - /// - /// Inserts an element into the ListViewEmbeddedControlCollection at the specified index - /// - /// - /// The object to insert. The value can be null for reference types - /// - /// The zero-based index at which item should be inserted - protected override void InsertItem(int index, ListViewEmbeddedControl item) { - base.InsertItem(index, item); - - OnAdded(item); - } - - /// - /// Removes the element at the specified index of the ListViewEmbeddedControlCollection - /// - /// The zero-based index of the element to remove - protected override void RemoveItem(int index) { - ListViewEmbeddedControl control = base[index]; - - base.RemoveItem(index); - - OnRemoved(control); - } - - /// Replaces the element at the specified index - /// - /// The new value for the element at the specified index. The value can be null - /// for reference types - /// - /// The zero-based index of the element to replace - protected override void SetItem(int index, ListViewEmbeddedControl item) { - ListViewEmbeddedControl control = base[index]; - - base.SetItem(index, item); - - OnRemoved(control); - OnAdded(item); - } - - /// Fires the Added event - /// - /// Embedded control that has been added to the collection - /// - protected virtual void OnAdded(ListViewEmbeddedControl embeddedControl) { - if(Added != null) - Added(this, new ListViewEmbeddedControlEventArgs(embeddedControl)); - } - - /// Fires the Removed event - /// - /// Embedded control that has been removed from the collection - /// - protected virtual void OnRemoved(ListViewEmbeddedControl embeddedControl) { - if(Removed != null) - Removed(this, new ListViewEmbeddedControlEventArgs(embeddedControl)); - } - - /// Fires the Clearing event - protected virtual void OnClearing() { - if(Clearing != null) - Clearing(this, EventArgs.Empty); - } - - } - -} // namespace Nuclex.Windows.Forms diff --git a/Source/ProgressReporter/ProgressReporterForm.cs b/Source/ProgressReporter/ProgressReporterForm.cs index 3ef3687..f4de20c 100644 --- a/Source/ProgressReporter/ProgressReporterForm.cs +++ b/Source/ProgressReporter/ProgressReporterForm.cs @@ -78,13 +78,15 @@ namespace Nuclex.Windows.Forms { } /// Called when the user tries to close the form manually - /// Contains a flag that can be used to abort the close attempt - protected override void OnClosing(CancelEventArgs e) { - base.OnClosing(e); + /// + /// Contains a flag that can be used to abort the close attempt + /// + protected override void OnClosing(CancelEventArgs arguments) { + base.OnClosing(arguments); // Only allow the form to close when the form is ready to close and the // transaction being tracked has also finished. - e.Cancel = (Thread.VolatileRead(ref this.state) < 2); + arguments.Cancel = (Thread.VolatileRead(ref this.state) < 2); } ///