示例#1
0
        /// <summary>
        /// Set the collection of objects that this control will show.
        /// </summary>
        /// <param name="collection"></param>
        /// <remark>This method can safely be called from background threads.</remark>
        override public void SetObjects(IEnumerable collection)
        {
            if (this.InvokeRequired)
            {
                this.Invoke((MethodInvoker) delegate { this.SetObjects(collection); });
                return;
            }

            if (this.DataSource == null)
            {
                return;
            }

            this.BeginUpdate();
            try {
                // Give the world a chance to cancel or change the assigned collection
                ItemsChangingEventArgs args = new ItemsChangingEventArgs(null, collection);
                this.OnItemsChanging(args);
                if (args.Canceled)
                {
                    return;
                }

                this.DataSource.SetObjects(args.NewObjects);
                this.UpdateVirtualListSize();
                this.Sort();
            }
            finally {
                this.EndUpdate();
            }
        }
示例#2
0
 protected virtual void OnItemsChanging(ItemsChangingEventArgs e)
 {
     if (this.ItemsChanging != null)
     {
         this.ItemsChanging(this, e);
     }
 }
示例#3
0
        /// <summary>
        /// Set the collection of objects that this control will show.
        /// </summary>
        /// <param name="collection"></param>
        /// <param name="preserveState">Should the state of the list be preserved as far as is possible.</param>
        public override void SetObjects(IEnumerable <object> collection, bool preserveState)
        {
            if (InvokeRequired)
            {
                Invoke((MethodInvoker) delegate { SetObjects(collection, preserveState); });
                return;
            }

            if (VirtualListDataSource == null)
            {
                return;
            }

            // Give the world a chance to cancel or change the assigned collection
            ItemsChangingEventArgs args = new ItemsChangingEventArgs(null, collection);

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

            BeginUpdate();
            try
            {
                VirtualListDataSource.SetObjects(args.NewObjects);
                BuildList();
            }
            finally
            {
                EndUpdate();
            }
        }
示例#4
0
        public override void SetObjects(IEnumerable collection)
        {
            MethodInvoker method = null;

            if (base.InvokeRequired)
            {
                if (method == null)
                {
                    method = delegate {
                        this.SetObjects(collection);
                    };
                }
                base.Invoke(method);
            }
            else if (this.DataSource != null)
            {
                base.BeginUpdate();
                try
                {
                    ItemsChangingEventArgs e = new ItemsChangingEventArgs(null, collection);
                    this.OnItemsChanging(e);
                    if (!e.Canceled)
                    {
                        this.DataSource.SetObjects(e.NewObjects);
                        this.UpdateVirtualListSize();
                        base.Sort();
                    }
                }
                finally
                {
                    base.EndUpdate();
                }
            }
        }
示例#5
0
        /// <summary>
        /// Set the collection of objects that will be shown in this list view.
        /// </summary>
        /// <remark>This method can safely be called from background threads.</remark>
        /// <remarks>The list is updated immediately</remarks>
        /// <param name="collection">The objects to be displayed</param>
        /// <param name="preserveState">Should the state of the list be preserved as far as is possible.</param>
        public virtual void SetObjects(IEnumerable collection, bool preserveState)
        {
            if (this.InvokeRequired) {
                this.Invoke((MethodInvoker)delegate { this.SetObjects(collection, preserveState); });
                return;
            }

            // Give the world a chance to cancel or change the assigned collection
            ItemsChangingEventArgs args = new ItemsChangingEventArgs(this.objects, collection);
            this.OnItemsChanging(args);
            if (args.Canceled)
                return;
            collection = args.NewObjects;

            // If we own the current list and they change to another list, we don't own it anymore
            if (this.isOwnerOfObjects && this.objects != collection)
                this.isOwnerOfObjects = false;
            this.objects = collection;
            this.BuildList(preserveState);

            // Tell the world that the list has changed
            this.OnItemsChanged(new ItemsChangedEventArgs());
        }
示例#6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnItemsChanging(ItemsChangingEventArgs e) {
     if (this.ItemsChanging != null)
         this.ItemsChanging(this, e);
 }
        /// <summary>
        /// Set the collection of objects that this control will show.
        /// </summary>
        /// <param name="collection"></param>
        /// <param name="preserveState">Should the state of the list be preserved as far as is possible.</param>
        public override void SetObjects(IEnumerable collection, bool preserveState) {
            if (this.InvokeRequired) {
                this.Invoke((MethodInvoker)delegate { this.SetObjects(collection, preserveState); });
                return;
            }

            if (this.VirtualListDataSource == null)
                return;

            // Give the world a chance to cancel or change the assigned collection
            ItemsChangingEventArgs args = new ItemsChangingEventArgs(null, collection);
            this.OnItemsChanging(args);
            if (args.Canceled)
                return;

            this.BeginUpdate();
            try {
                this.VirtualListDataSource.SetObjects(args.NewObjects);
                this.BuildList();
                this.UpdateNotificationSubscriptions(args.NewObjects);
            }
            finally {
                this.EndUpdate();
            }
        }
示例#8
0
        /// <summary>
        /// Set the collection of objects that this control will show.
        /// </summary>
        /// <param name="collection"></param>
        /// <remark>This method can safely be called from background threads.</remark>
        public override void SetObjects(IEnumerable collection)
        {
            if (this.InvokeRequired) {
                this.Invoke((MethodInvoker)delegate { this.SetObjects(collection); });
                return;
            }

            if (this.DataSource == null)
                return;

            this.BeginUpdate();
            try {
                // Give the world a chance to cancel or change the assigned collection
                ItemsChangingEventArgs args = new ItemsChangingEventArgs(null, collection);
                this.OnItemsChanging(args);
                if (args.Canceled)
                    return;

                this.DataSource.SetObjects(args.NewObjects);
                this.UpdateVirtualListSize();
                this.Sort();
            }
            finally {
                this.EndUpdate();
            }
        }