protected virtual void OnCollectionChanging(CollectionChangingEventArgs <T> e)
        {
            var handler = CollectionChanging;

            if (handler != null)
            {
                var subscriptions = handler.GetInvocationList();
                int index         = 0;
                try {
                    for (; index < subscriptions.Length; index++)
                    {
                        ((EventHandler <CollectionChangingEventArgs <T> >)subscriptions[index])(this, e);
                        if (e.Cancel)
                        {
                            break;
                        }
                    }
                } catch (Exception) {
                    e.Cancel = true;
                }
            }

            if (e.Cancel)
            {
                OnCollectionChangingCancelled(EventArgs.Empty);
            }
        }
Пример #2
0
 void OnTabCollectionRemoving(object sender, CollectionChangingEventArgs e)
 {
     if (PageRemoving != null)
     {
         PageRemoving(sender, e);
     }
 }
Пример #3
0
 void controlPanel_PageRemoving(object sender, CollectionChangingEventArgs args)
 {
     if (PageRemoving != null)
     {
         PageRemoving(sender, args);
     }
 }
Пример #4
0
        private bool OnCollectionChanging(CollectionChangeAction action, T item)
        {
            var eventArgs = new CollectionChangingEventArgs <T>(action, item);

            CollectionChanging(this, eventArgs);

            return(eventArgs.Cancel);
        }
Пример #5
0
        protected void OnCategoryInserted(Object o, CollectionChangingEventArgs e)
        {
            ButtonsPanel panel = (ButtonsPanel)e.Value;

            panel.Clicked += OnSelectionChanged;
            panel.Dock     = DockStyle.Top;
            Controls.Add((ButtonsPanel)e.Value);
            panel.BringToFront();
        }
Пример #6
0
 protected void OnTabCollectionRemoved(Object o, CollectionChangingEventArgs e)
 {
     Controls.Remove((Page)e.Value);
     if (e.Index <= selectedPage)
     {
         SelectedPage = SelectedPage - 1;
     }
     Refresh();
 }
Пример #7
0
        protected void OnCategoryInserted(Object o, CollectionChangingEventArgs e)
        {
            Panel clientPanel = new Panel();

            clientPanel.Dock = DockStyle.Fill;
            FloatPanel panel = (FloatPanel)e.Value;

            panel.Dock = DockStyle.Top;
            Controls.Add((FloatPanel)e.Value);
            panel.BringToFront();
        }
Пример #8
0
        protected void OnTabCollectionInserted(Object o, CollectionChangingEventArgs e)
        {
            Page page = (Page)e.Value;

            page.Dock        = DockStyle.Fill;
            page.ActiveColor = ActiveColor;
            page.DrawBorder  = drawBorder;
            Parent.Controls.Add((Page)e.Value);
            SelectedPage = Pages.Count - 1;
            page.BringToFront();
            ShowHideCloseButton();
        }
 private void ManagedJobInfo_CollectionChanging(object sender, CollectionChangingEventArgs e)
 {
     if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
     {
         lock (this.ManagedJobInfo)
         {
             if (this.ManagedJobInfo.Any(t => t.JobId == ((JobInfo)e.NewItems[0]).JobId))
             {
                 //擲例外 or 取消加入
                 e.Cancel = true;
             }
         }
     }
 }
Пример #10
0
 private void Entities_CollectionChanging(object sender, CollectionChangingEventArgs <TEntityViewModel> e)
 {
     switch (e.Action)
     {
     case CollectionChangeAction.Remove:
         string cantRemoveError;
         if (!IsCanRemove(e.Item, out cantRemoveError))
         {
             _MessageService.ShowMessage(cantRemoveError, "Ошибка", image: MessageBoxImage.Error);
             e.Cancel = true;
         }
         else
         {
             RemoveEntityFromDatabase(e.Item.DbEntity);
         }
         break;
     }
 }
Пример #11
0
 private static void Assemblies_InsertingItem(object sender, CollectionChangingEventArgs<AssemblyDefinition> e)
 {
     if (e.TargetObject.Compilation != null)
     {
         e.Cancel = true;
         throw new InvalidOperationException("Assembly reference is already added to another compilation.");
     }
 }
Пример #12
0
 private void _toolWindows_InsertingItem(object sender, CollectionChangingEventArgs e)
 {
     e.Cancel = DockPanel.GetContainer(e.TargetObject as LiteViewContent) != null;
 }
Пример #13
0
 protected void OnCategoryRemoved(Object o, CollectionChangingEventArgs e)
 {
     Controls.Remove((ButtonsPanel)e.Value);
 }
Пример #14
0
 private void _toolWindows_InsertingItem(object sender, CollectionChangingEventArgs e)
 {
     e.Cancel = DockPanel.GetContainer(e.TargetObject as LiteViewContent) != null;
 }
Пример #15
0
 private static void SourceFilesOnInsertingItem(object sender, CollectionChangingEventArgs<SourceFile> e)
 {
     if (e.TargetObject.Assembly != null)
     {
         e.Cancel = true;
         throw new InvalidOperationException("Source file is already added to another assembly.");
     }
 }
 private bool TryPassChangingChecks(CollectionChangingEventArgs <T> e)
 {
     OnCollectionChanging(e);
     return(!e.Cancel);
 }
Пример #17
0
 protected void OnButtonRemoved(Object o, CollectionChangingEventArgs e)
 {
     StateChanged();
 }