Example #1
0
        protected virtual ItemMovingEventArgs <T> OnItemRemoving(T item)
        {
            var evArg = new ItemMovingEventArgs <T>(item);

            ItemRemoving?.Invoke(this, evArg);
            return(evArg);
        }
Example #2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            object item = SelectedItem;

            if (item != null)
            {
                int index = dgvAdditionalFiles.SelectedRows[0].Index;
                AdditionalFilesEventArgs cancelEvent = new AdditionalFilesEventArgs(item);
                ItemRemoving?.Invoke(this, cancelEvent);

                if (!cancelEvent.Cancel)
                {
                    m_files.Remove(item);
                    Rebind();

                    if (dgvAdditionalFiles.Rows.Count > 0)
                    {
                        if (index >= dgvAdditionalFiles.Rows.Count)
                        {
                            index = dgvAdditionalFiles.Rows.Count - 1;
                        }
                        dgvAdditionalFiles.Rows[index].Selected = true;
                    }

                    ItemRemoved?.Invoke(this, new AdditionalFilesEventArgs(item));
                }
            }
        }
Example #3
0
        protected override void RemoveItem(int index)
        {
            var item = Items[index];

            ItemRemoving?.Invoke(item, index);
            base.RemoveItem(index);
        }
Example #4
0
        public IGrabableItem RemoveItem(IGrabableItem item, bool triggerEvent = true)
        {
            if (triggerEvent)
            {
                ItemRemoving?.Invoke(this, item);
            }

            items.Remove(item);
            return(item);
        }
Example #5
0
        private void OnItemRemoving(object sender, ChipRemovingEventArgs e)
        {
            if (sender is Chip container)
            {
                var args = new ChipItemRemovingEventArgs(ItemFromContainer(container));
                args.Cancel = e.Cancel;

                ItemRemoving?.Invoke(this, new ChipItemRemovingEventArgs(ItemFromContainer(container)));
                e.Cancel = args.Cancel;
            }
        }
Example #6
0
        /// <summary>
        /// Remove the item at the specified index of this collection.
        /// </summary>
        /// <param name="index">The index of the item to remove.</param>
        /// <returns><c>true</c> if the item is removed, otherwise <c>false</c>. It will be <c>false</c> if the removal was cancelled via the ItemRemoving event.</returns>
        public new bool RemoveAt(int index)
        {
            T t = this[index];

            ItemRemovingEventArgs <T> te = new ItemRemovingEventArgs <T>(t);

            ItemRemoving?.Invoke(this, te);

            if (te.Cancel)
            {
                return(false);
            }

            base.RemoveAt(index);

            return(true);
        }
Example #7
0
        /// <summary>
        /// Removes the first occurrence of a specific object in the collection.
        /// </summary>
        /// <param name="item">The item to remove.</param>
        /// <returns><c>true</c> if the item is removed, otherwise <c>false</c>. It may be <c>false</c> if the item isn't actually in the collection or if the removal was cancelled via the ItemRemoving event.</returns>
        public new bool Remove(T item)
        {
            ItemRemovingEventArgs <T> te = new ItemRemovingEventArgs <T>(item);

            ItemRemoving?.Invoke(this, te);

            if (te.Cancel)
            {
                return(false);
            }

            bool res = base.Remove(item);

            if (res && selectedItems.Contains(item))
            {
                selectedItems.Remove(item);
            }

            return(res);
        }
Example #8
0
 private void OnRowClicked(ItemListRow row)
 {
     ItemRemoving?.Invoke(row.Item);
 }
Example #9
0
 public void OnItemRemoved(ObservableListEventArgs <T> e)
 {
     ItemRemoving?.Invoke(this, e);
     ItemRemoved?.Invoke(this, e);
 }