Пример #1
0
 protected virtual void OnItemsRemoving(ItemsRemovingEventArgs e)
 {
     if (this.ItemsRemoving != null)
     {
         this.ItemsRemoving(this, e);
     }
 }
Пример #2
0
        /// <summary>
        /// Remove all of the given objects from the control
        /// </summary>
        /// <param name="modelObjects">Collection of objects to be removed</param>
        /// <remarks>
        /// <para>Nulls and model objects that are not in the ListView are silently ignored.</para>
        /// <para>Due to problems in the underlying ListView, if you remove all the objects from
        /// the control using this method and the list scroll vertically when you do so,
        /// then when you subsequenially add more objects to the control,
        /// the vertical scroll bar will become confused and the control will draw one or more
        /// blank lines at the top of the list. </para>
        /// </remarks>
        public override void RemoveObjects(ICollection <object> modelObjects)
        {
            if (VirtualListDataSource == null)
            {
                return;
            }

            // Give the world a chance to cancel or change the removed objects
            ItemsRemovingEventArgs args = new ItemsRemovingEventArgs(modelObjects);

            OnItemsRemoving(args);
            if (args.Canceled)
            {
                return;
            }

            try
            {
                BeginUpdate();
                VirtualListDataSource.RemoveObjects(args.ObjectsToRemove);
                BuildList();
            }
            finally
            {
                EndUpdate();
            }
        }
Пример #3
0
 public override void RemoveObjects(ICollection modelObjects)
 {
     if (this.DataSource != null)
     {
         ItemsRemovingEventArgs e = new ItemsRemovingEventArgs(modelObjects);
         this.OnItemsRemoving(e);
         if (!e.Canceled)
         {
             this.ClearCachedInfo();
             this.DataSource.RemoveObjects(e.ObjectsToRemove);
             this.UpdateVirtualListSize();
         }
     }
 }
Пример #4
0
        /// <summary>
        /// Remove all of the given objects from the control
        /// </summary>
        /// <param name="modelObjects">Collection of objects to be removed</param>
        /// <remarks>
        /// <para>Nulls and model objects that are not in the ListView are silently ignored.</para>
        /// <para>Due to problems in the underlying ListView, if you remove all the objects from
        /// the control using this method and the list scroll vertically when you do so,
        /// then when you subsequenially add more objects to the control,
        /// the vertical scroll bar will become confused and the control will draw one or more
        /// blank lines at the top of the list. </para>
        /// </remarks>
        override public void RemoveObjects(ICollection modelObjects)
        {
            if (this.DataSource == null)
            {
                return;
            }

            // Give the world a chance to cancel or change the removed objects
            ItemsRemovingEventArgs args = new ItemsRemovingEventArgs(modelObjects);

            this.OnItemsRemoving(args);
            if (args.Canceled)
            {
                return;
            }

            this.DataSource.RemoveObjects(args.ObjectsToRemove);
            this.UpdateVirtualListSize();
        }
Пример #5
0
        /// <summary>
        /// Remove all of the given objects from the control
        /// </summary>
        /// <param name="modelObjects">Collection of objects to be removed</param>
        /// <remarks>
        /// <para>Nulls and model objects that are not in the ListView are silently ignored.</para>
        /// <para>Due to problems in the underlying ListView, if you remove all the objects from
        /// the control using this method and the list scroll vertically when you do so,
        /// then when you subsequenially add more objects to the control,
        /// the vertical scroll bar will become confused and the control will draw one or more
        /// blank lines at the top of the list. </para>
        /// </remarks>
        public override void RemoveObjects(ICollection modelObjects)
        {
            if (VirtualListDataSource == null)
            {
                return;
            }

            // Give the world a chance to cancel or change the removed objects
            var args = new ItemsRemovingEventArgs(modelObjects);

            OnItemsRemoving(args);
            if (args.Canceled)
            {
                return;
            }

            ClearCachedInfo();
            VirtualListDataSource.RemoveObjects(args.ObjectsToRemove);
            UpdateVirtualListSize();
        }
Пример #6
0
        /// <summary>
        /// Remove all of the given objects from the control.
        /// </summary>
        /// <param name="modelObjects">Collection of objects to be removed</param>
        /// <remarks>
        /// <para>Nulls and model objects that are not in the ListView are silently ignored.</para>
        /// <para>This method is thread-safe.</para>
        /// </remarks>
        public virtual void RemoveObjects(ICollection modelObjects)
        {
            if (this.InvokeRequired) {
                this.Invoke((MethodInvoker)delegate() { this.RemoveObjects(modelObjects); });
                return;
            }
            if (modelObjects == null)
                return;

            this.BeginUpdate();
            try {
                // Give the world a chance to cancel or change the added objects
                ItemsRemovingEventArgs args = new ItemsRemovingEventArgs(modelObjects);
                this.OnItemsRemoving(args);
                if (args.Canceled)
                    return;
                modelObjects = args.ObjectsToRemove;

                this.TakeOwnershipOfObjects();
                ArrayList ourObjects = (ArrayList)this.Objects;
                foreach (object modelObject in modelObjects) {
                    if (modelObject != null) {
                        ourObjects.Remove(modelObject);
                        int i = this.IndexOf(modelObject);
                        if (i >= 0)
                            this.Items.RemoveAt(i);
                    }
                }
                this.PostProcessRows();

                // Tell the world that the list has changed
                this.OnItemsChanged(new ItemsChangedEventArgs());
            } finally {
                this.EndUpdate();
            }
        }
Пример #7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnItemsRemoving(ItemsRemovingEventArgs e) {
     if (this.ItemsRemoving != null)
         this.ItemsRemoving(this, e);
 }
        /// <summary>
        /// Remove all of the given objects from the control
        /// </summary>
        /// <param name="modelObjects">Collection of objects to be removed</param>
        /// <remarks>
        /// <para>Nulls and model objects that are not in the ListView are silently ignored.</para>
        /// <para>Due to problems in the underlying ListView, if you remove all the objects from
        /// the control using this method and the list scroll vertically when you do so,
        /// then when you subsequenially add more objects to the control,
        /// the vertical scroll bar will become confused and the control will draw one or more
        /// blank lines at the top of the list. </para>
        /// </remarks>
        public override void RemoveObjects(ICollection modelObjects) {
            if (this.VirtualListDataSource == null)
                return;

            // Give the world a chance to cancel or change the removed objects
            ItemsRemovingEventArgs args = new ItemsRemovingEventArgs(modelObjects);
            this.OnItemsRemoving(args);
            if (args.Canceled)
                return;

            try {
                this.BeginUpdate();
                this.VirtualListDataSource.RemoveObjects(args.ObjectsToRemove);
                this.BuildList();
                this.UnsubscribeNotifications(args.ObjectsToRemove);
            }
            finally {
                this.EndUpdate();
            }
        }
Пример #9
0
        /// <summary>
        /// Remove all of the given objects from the control.
        /// </summary>
        /// <param name="modelObjects">Collection of objects to be removed</param>
        /// <remarks>
        /// <para>Nulls and model objects that are not in the ListView are silently ignored.</para>
        /// <para>This method is thread-safe.</para>
        /// </remarks>
        public virtual void RemoveObjects(ICollection modelObjects) {
            if (this.InvokeRequired) {
                this.Invoke((MethodInvoker)delegate() { this.RemoveObjects(modelObjects); });
                return;
            }
            if (modelObjects == null)
                return;

            this.BeginUpdate();
            try {
                // Give the world a chance to cancel or change the added objects
                ItemsRemovingEventArgs args = new ItemsRemovingEventArgs(modelObjects);
                this.OnItemsRemoving(args);
                if (args.Canceled)
                    return;
                modelObjects = args.ObjectsToRemove;

                this.TakeOwnershipOfObjects();
                ArrayList ourObjects = ObjectListView.EnumerableToArray(this.Objects, false);
                foreach (object modelObject in modelObjects) {
                    if (modelObject != null) {
// ReSharper disable PossibleMultipleEnumeration
                        ourObjects.Remove(modelObject);
// ReSharper restore PossibleMultipleEnumeration
                        int i = this.IndexOf(modelObject);
                        if (i >= 0)
                            this.Items.RemoveAt(i);
                    }
                }
                this.PostProcessRows();

                // Tell the world that the list has changed
                this.UnsubscribeNotifications(modelObjects);
                this.OnItemsChanged(new ItemsChangedEventArgs());
            } finally {
                this.EndUpdate();
            }
        }
        /// <summary>
        /// Remove all of the given objects from the control
        /// </summary>
        /// <param name="modelObjects">Collection of objects to be removed</param>
        /// <remarks>
        /// <para>Nulls and model objects that are not in the ListView are silently ignored.</para>
        /// <para>Due to problems in the underlying ListView, if you remove all the objects from
        /// the control using this method and the list scroll vertically when you do so,
        /// then when you subsequenially add more objects to the control,
        /// the vertical scroll bar will become confused and the control will draw one or more
        /// blank lines at the top of the list. </para>
        /// </remarks>
        public override void RemoveObjects(ICollection modelObjects) {
            if (this.VirtualListDataSource == null)
                return;

            // Give the world a chance to cancel or change the removed objects
            ItemsRemovingEventArgs args = new ItemsRemovingEventArgs(modelObjects);
            this.OnItemsRemoving(args);
            if (args.Canceled)
                return;

            this.ClearCachedInfo();
            this.VirtualListDataSource.RemoveObjects(args.ObjectsToRemove);
            this.UpdateVirtualListSize();
        }