Beispiel #1
0
        /// <summary>
        /// Event handler for the "Remove Tab" verb.
        /// </summary>
        /// <param name="dh"></param>
        /// <param name="panel"></param>
        private static void RemovePage(IDesignerHost dh, MultiPanel panel)
        {
            MultiPanelPage page = panel.SelectedPage;
            if (page == null)
                return;

            DesignerTransaction dt = dh.CreateTransaction("Removed page");

            panel.Controls.Remove(page);
            dh.DestroyComponent(page);

            panel.SelectedPage = panel.Controls.Count > 0 ? (MultiPanelPage)panel.Controls[0] : null;

            dt.Commit();
        }
Beispiel #2
0
        private void OnComponentRemoving(object sender, ComponentEventArgs e)
        {
            // If our control is being removed
            if (e.Component == _gallery)
            {
                // Need access to host in order to delete a component
                IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

                // We need to remove all the range instances
                for (int i = _gallery.DropButtonRanges.Count - 1; i >= 0; i--)
                {
                    KryptonGalleryRange dropRange = _gallery.DropButtonRanges[i];
                    _gallery.DropButtonRanges.Remove(dropRange);
                    host.DestroyComponent(dropRange);
                }
            }
        }
Beispiel #3
0
        private void OnComponentRemoving(object sender, ComponentEventArgs e)
        {
            // If our item collection is being removed
            if ((_contextMenuItems != null) && (e.Component == _contextMenuItems))
            {
                // Need access to host in order to delete a component
                IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

                // We need to remove all items from the item collection
                for (int j = _contextMenuItems.Items.Count - 1; j >= 0; j--)
                {
                    Component item = _contextMenuItems.Items[j] as Component;
                    _contextMenuItems.Items.Remove(item);
                    host.DestroyComponent(item);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Removes controls of type T from the form.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="host">The idesigner host</param>
        /// <param name="showWarning">if set to <c>true</c> [show warning].</param>
        public static void Host_Components_Remove <T>(IDesignerHost host, bool showWarning = false) where T : Component
        {
            var components = Host_Controls_All <T>(host);

            if (showWarning && components.Count > 0)
            {
                var msg = "This will remove " + typeof(T).ToString() + ". Continue?";
                if (MessageBox_YesNo(msg) == false)
                {
                    return;
                }
            }
            foreach (var component in components)
            {
                host.DestroyComponent(component);
            }
        }
        private void OnComponentRemoving(object sender, ComponentEventArgs e)
        {
            // If our group is being removed
            if (e.Component == _ribbonGroup)
            {
                // Need access to host in order to delete a component
                IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

                // We need to remove all containers from the group
                for (int j = _ribbonGroup.Items.Count - 1; j >= 0; j--)
                {
                    KryptonRibbonGroupContainer item = _ribbonGroup.Items[j] as KryptonRibbonGroupContainer;
                    _ribbonGroup.Items.Remove(item);
                    host.DestroyComponent(item);
                }
            }
        }
Beispiel #6
0
        protected internal virtual void RemoveStep()
        {
            IDesignerHost service = (IDesignerHost)this.GetService(typeof(IDesignerHost));

            if (this.WizardControl == null || service == null)
            {
                return;
            }
            if (MessageBox.Show(this.WizardControl.FindForm(), "Are you sure you want to remove the step?", "Remove Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                WizardStep step = this.WizardControl.WizardSteps[this.WizardControl.CurrentStepIndex];
                this.WizardControl.WizardSteps.Remove(step);
                service.DestroyComponent(step);
                step.Dispose();
            }
            this.SelectWizard();
        }
Beispiel #7
0
 private object Transaction_RemovePage(IDesignerHost theHost, object theParam)
 {
     if (this.mySelectedPage != null)
     {
         MemberDescriptor member = TypeDescriptor.GetProperties(this.DesignedControl)["Controls"];
         base.RaiseComponentChanging(member);
         try
         {
             theHost.DestroyComponent(this.mySelectedPage);
         }
         catch
         {
         }
         base.RaiseComponentChanged(member, null, null);
     }
     return(null);
 }
Beispiel #8
0
        public void ClearComponents()
        {
            bLoading = true;
            IDesignerHost host = (IDesignerHost)dsf.GetService(typeof(IDesignerHost));

            if (host != null)
            {
                ComponentCollection cc = host.Container.Components;
                foreach (IComponent c in cc)
                {
                    if (c != root)
                    {
                        host.DestroyComponent(c);
                    }
                }
            }
        }
Beispiel #9
0
        private void OnComponentRemoving(object sender, ComponentEventArgs e)
        {
            // If our tab is being removed
            if (e.Component == _ribbonTab)
            {
                // Need access to host in order to delete a component
                IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

                // We need to remove all the groups from the tab
                for (int i = _ribbonTab.Groups.Count - 1; i >= 0; i--)
                {
                    KryptonRibbonGroup group = _ribbonTab.Groups[i];
                    _ribbonTab.Groups.Remove(group);
                    host.DestroyComponent(group);
                }
            }
        }
Beispiel #10
0
        /// <summary>
        /// Event handler for the "Remove Tab" verb.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="ea">
        /// Some <see cref="EventArgs"/>.
        /// </param>
        private void RemoveTab(object sender, EventArgs ea)
        {
            IDesignerHost dh = ( IDesignerHost )GetService(typeof(IDesignerHost));

            if (dh != null)
            {
                int i = ytc.SelectedIndex;
                if (i > -1)
                {
                    YaTabPage ytp = ytc.SelectedTab;
                    ytc.Controls.Remove(ytp);
                    dh.DestroyComponent(ytp);
                    RaiseComponentChanging(TypeDescriptor.GetProperties(Control)["SelectedIndex"]);
                    RaiseComponentChanged(TypeDescriptor.GetProperties(Control)["SelectedIndex"], i, 0);
                }
            }
        }
        /// <summary>
        /// Event handler for the "Remove Tab" verb.
        /// </summary>
        /// <param name="dh"></param>
        /// <param name="panel"></param>
        private static void RemovePage(IDesignerHost dh, MultiPanel panel)
        {
            MultiPanelPage page = panel.SelectedPage;

            if (page == null)
            {
                return;
            }

            DesignerTransaction dt = dh.CreateTransaction("Removed page");

            panel.Controls.Remove(page);
            dh.DestroyComponent(page);

            panel.SelectedPage = panel.Controls.Count > 0 ? (MultiPanelPage)panel.Controls[0] : null;

            dt.Commit();
        }
Beispiel #12
0
				public override void Undo (UndoEngine engine)
				{
					IDesignerHost host = engine.GetRequiredService (typeof (IDesignerHost)) as IDesignerHost;
					if (_added) {
						// Console.WriteLine ("Component*Add*RemoveAction.Undo (" + _componentName + ")");
						IComponent component = host.Container.Components[_componentName];
						if (component != null) // the component might have been destroyed already
							host.DestroyComponent (component);
						_added = false;
					} else {
						// Console.WriteLine ("ComponentAdd*Remove*Action.Undo (" + _componentName + ")");
						ComponentSerializationService serializationService = engine.GetRequiredService (
							typeof (ComponentSerializationService)) as ComponentSerializationService;

						serializationService.DeserializeTo (_serializedComponent, host.Container);
						_added = true;
					}
				}
Beispiel #13
0
        private void OnComponentRemoved(object sender, ComponentEventArgs ce)
        {
            if (ce.Component is GradientEditorControl)
            {
                GradientEditorControl host       = (GradientEditorControl)ce.Component;
                IDesignerHost         designHost = (IDesignerHost)GetService(typeof(IDesignerHost));

                // remove our gradient key components
                // so they are not left in the serialized form definition
                foreach (Component c in host.mGradientKeyCollection)
                {
                    if (c != null)
                    {
                        designHost.DestroyComponent(c);
                    }
                }
            }
        }
Beispiel #14
0
 protected override void DisposeManagedResources()
 {
     if (this.site != null && this.site.DesignMode)
     {
         IDesignerHost service = this.site.GetService(typeof(IDesignerHost)) as IDesignerHost;
         if (service != null)
         {
             try
             {
                 service.DestroyComponent((IComponent)this);
             }
             catch (InvalidOperationException ex)
             {
             }
         }
     }
     base.DisposeManagedResources();
 }
        private object Transaction_RemovePage(IDesignerHost theHost, object theParam)
        {
            if (selectedPage == null)
            {
                return(null);
            }
            MultiLayerPanel  aCtl             = DesignedControl;
            MemberDescriptor aMember_Controls = TypeDescriptor.GetProperties(aCtl)["Controls"];

            RaiseComponentChanging(aMember_Controls);
            try
            {
                theHost.DestroyComponent(selectedPage);
            }
            catch { }
            RaiseComponentChanged(aMember_Controls, null, null);
            return(null);
        }
        private void OnComponentRemoving(object sender, ComponentEventArgs e)
        {
            // If our sequence is being removed
            if (e.Component == _sequence)
            {
                // Need access to host in order to delete a component
                IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

                // Climb the workspace item tree to get the top most sequence
                KryptonWorkspace workspace     = null;
                IWorkspaceItem   workspaceItem = _sequence;
                while (workspaceItem.WorkspaceParent != null)
                {
                    workspaceItem = workspaceItem.WorkspaceParent;
                }

                // Grab the workspace control that contains the top most sequence
                if ((workspaceItem != null) && (workspaceItem is KryptonWorkspaceSequence))
                {
                    KryptonWorkspaceSequence sequence = (KryptonWorkspaceSequence)workspaceItem;
                    workspace = sequence.WorkspaceControl;
                }

                // We need to remove all children from the sequence
                for (int j = _sequence.Children.Count - 1; j >= 0; j--)
                {
                    Component comp = _sequence.Children[j] as Component;

                    // If the component is a control...
                    if ((comp is Control) && (workspace != null))
                    {
                        // We need to manually remove it from the workspace controls collection
                        KryptonReadOnlyControls readOnlyControls = (KryptonReadOnlyControls)workspace.Controls;
                        readOnlyControls.RemoveInternal(comp as Control);
                    }

                    host.DestroyComponent(comp);

                    // Must remove the child after it has been destroyed otherwise the component destroy method
                    // will not be able to climb the sequence chain to find the parent workspace instance
                    _sequence.Children.Remove(comp);
                }
            }
        }
Beispiel #17
0
        internal void RemovePageFromWizard(WizardPage page)
        {
            IDesignerHost           h = DesignerHost;
            IComponentChangeService c = ComponentChangeService;

            if (h == null || c == null)
            {
                throw new ArgumentException("Both IDesignerHost and IComponentChangeService arguments cannot be null.");
            }

            if (Control == null || !Control.Pages.Contains(page))
            {
                return;
            }

            DesignerTransaction dt = null;

            try
            {
                dt = h.CreateTransaction("Remove Wizard Page");

                MemberDescriptor member = TypeDescriptor.GetProperties(Control)["Pages"];
                base.RaiseComponentChanging(member);

                if (page.Owner != null)
                {
                    page.Owner.Pages.Remove(page);
                    h.DestroyComponent(page);
                }
                else
                {
                    page.Dispose();
                }
                base.RaiseComponentChanged(member, null, null);
            }
            finally
            {
                if (dt != null)
                {
                    dt.Commit();
                }
            }
            RefreshDesigner();
        }
        private void OnRemove(object sender, EventArgs eevent)
        {
            HorizontalTabs tabs = (HorizontalTabs)base.Component;

            if ((tabs == null) || (tabs.Tabs.Count == 0))
            {
                return;
            }
            MemberDescriptor descriptor1 = TypeDescriptor.GetProperties(base.Component)["Controls"];
            HorizontalTab    page1       = tabs.SelectedTab;
            IDesignerHost    host1       = (IDesignerHost)this.GetService(typeof(IDesignerHost));

            if (host1 == null)
            {
                return;
            }
            DesignerTransaction transaction1 = null;

            try
            {
                try
                {
                    transaction1 = host1.CreateTransaction("RemoveTabTransaction");
                    base.RaiseComponentChanging(descriptor1);
                }
                catch (CheckoutException exception1)
                {
                    if (exception1 != CheckoutException.Canceled)
                    {
                        throw exception1;
                    }
                    return;
                }
                host1.DestroyComponent(page1);
                base.RaiseComponentChanged(descriptor1, null, null);
            }
            finally
            {
                if (transaction1 != null)
                {
                    transaction1.Commit();
                }
            }
        }
Beispiel #19
0
 private void ReactToMouseClick(int messageType)
 {
     if (Control.TabPages.Count != 0)
     {
         Point point       = Control.PointToClient(Cursor.Position);
         int   pageByPoint = Control.GetPageByPoint(point);
         if (pageByPoint != -1)
         {
             MultitabPage tabPage = Control.TabPages[pageByPoint];
             if (messageType == 0x201)
             {
                 Control.SelectTab(tabPage);
             }
             else if (messageType == 0x207)
             {
                 IDesignerHost service = (IDesignerHost)GetService(typeof(IDesignerHost));
                 Control.CloseTab(tabPage);
                 service.DestroyComponent(tabPage);
             }
         }
         else if (Control.DropDownButton.Bounds.Contains(point))
         {
             Control.ActivePagesMenu.Items.Clear();
             for (int i = 0; i < Control.TabPages.Count; i++)
             {
                 Control.ActivePagesMenu.Items.Add(Control.TabPages[i].Text, null, Control.TabClicked).Tag =
                     Control.TabPages[i];
             }
             Control.ActivePagesMenu.Show(Control, Control.DropDownButton.Left,
                                          Control.DropDownButton.Top + Control.DropDownButton.Height);
         }
         else if (Control.CloseButton.Bounds.Contains(point))
         {
             Control.CloseTab(Control.SelectedTab);
         }
         else if (((pageByPoint == -1) && (messageType == 0x207)) && (Control.TabPages.Count > 0))
         {
             IDesignerHost host2       = (IDesignerHost)GetService(typeof(IDesignerHost));
             MultitabPage  selectedTab = Control.SelectedTab;
             Control.CloseTab(selectedTab);
             host2.DestroyComponent(selectedTab);
         }
     }
 }
Beispiel #20
0
 public void DeleteSelectedComponents()
 {
     try
     {
         bool bSaved          = false;
         ISelectionService ss = (ISelectionService)dsf.GetService(typeof(ISelectionService));
         if (ss != null)
         {
             ICollection cc = ss.GetSelectedComponents();
             if (cc != null)
             {
                 IDesignerHost host = (IDesignerHost)dsf.GetService(typeof(IDesignerHost));
                 if (host != null)
                 {
                     CreateUndoTransaction("deleteSelectedComponent");
                     foreach (object v in cc)
                     {
                         if (v is System.ComponentModel.IComponent)
                         {
                             if (v != host.RootComponent)
                             {
                                 if (!bSaved)
                                 {
                                     bSaved   = true;
                                     bLoading = true;
                                     bLoading = false;
                                 }
                                 host.DestroyComponent((System.ComponentModel.IComponent)v);
                             }
                         }
                     }
                     root.Changed = true;
                     CommitUndoTransaction("deleteSelectedComponent");
                 }
             }
         }
     }
     catch (Exception err)
     {
         MathNode.Log(this.FindForm(), err);
         RollbackUndoTransaction("deleteSelectedComponent");
     }
 }
Beispiel #21
0
        protected override void DisposeManagedResources()
        {
            if (this.site != null && this.site.DesignMode)
            {
                IDesignerHost host = this.site.GetService(typeof(IDesignerHost)) as IDesignerHost;
                if (host != null)
                {
                    try
                    {
                        host.DestroyComponent(this);
                    }
                    catch (InvalidOperationException)//fixed VS2010 inherit controls issue
                    {
                    }
                }
            }

            base.DisposeManagedResources();
        }
        void ExecuteDel(object sender, EventArgs e)
        {
            if (VobState.GetMainPropertyGridFocus != null)
            {
                if (VobState.GetMainPropertyGridFocus())
                {
                    if (VobState.SendDeleteToMainPropertyGridTextEditor != null)
                    {
                        VobState.SendDeleteToMainPropertyGridTextEditor(this, EventArgs.Empty);
                    }
                    return;
                }
            }
            ISelectionService ss = (ISelectionService)this.GetService(typeof(ISelectionService));

            if (ss != null)
            {
                ICollection cc = ss.GetSelectedComponents();
                if (cc != null)
                {
                    IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost));
                    if (host != null)
                    {
                        using (DesignerTransaction trans = host.CreateTransaction("Delete " + cc.Count + " component(s)"))
                        {
                            foreach (object v in cc)
                            {
                                if (v is System.ComponentModel.IComponent)
                                {
                                    if (v != host.RootComponent)
                                    {
                                        host.DestroyComponent((System.ComponentModel.IComponent)v);
                                    }
                                }
                            }
                            trans.Commit();
                            enableUndoMenu();
                        }
                    }
                }
            }
        }
 public void DestroyComponent(IComponent component)
 {
     try
     {
         IDesignerHost host = this.Host;
         if (null == host)
         {
             return;
         }
         if (null == host.RootComponent)
         {
             return;
         }
         host.DestroyComponent(component);
     }
     catch (Exception ex)
     {
         throw new Exception("::DestroyComponent() - Exception: (see Inner Exception)", ex);
     }
 }
        private void RemoveBasePanel(object sender, EventArgs ea)
        {
            if (this.m_DockPanel.BasePanels.Count <= 1)
            {
                GISShare.Controls.WinForm.WFNew.Forms.TBMessageBox.Show("一个停靠面板(DockPanel)中至少要有一个基础面板(BasePanel)项,否则可能会出现异常!"); return;
            }
            //
            IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

            if (host != null)
            {
                BasePanel basePanel = this.m_DockPanel.SelectedBasePanel;//key
                if (basePanel == null)
                {
                    return;
                }
                this.m_DockPanel.BasePanels.Remove(basePanel);
                host.DestroyComponent(basePanel);
            }
        }
        /// <summary>
        /// Initializes the layout engine of the Navigation pane
        /// </summary>
        /// <exception cref="System.SystemException">Invalid value for property LayoutStyle</exception>
        private void InitializeLayout()
        {
            if (designingControl.NaviLayout != null)
            {
                host.DestroyComponent(designingControl.NaviLayout);
            }

            switch (designingControl.LayoutStyle)
            {
            case NaviLayoutStyle.Office2003Blue:
            case NaviLayoutStyle.Office2007Silver:
            case NaviLayoutStyle.Office2007Black:
            case NaviLayoutStyle.Office2007Blue:
                break;

            default:
                throw new SystemException("Invalid value for property LayoutStyle");
            }
            designingControl.Invalidate();
        }
Beispiel #26
0
        protected virtual void RemoveTab()
        {
            if (!(this.Control is TabView))
            {
                return;
            }

            IDesignerHost designerHost = (IDesignerHost)this.GetService(typeof(IDesignerHost));
            TabView       tabView      = this.Control as TabView;
            TabPanel      tabPanel     = null;

            if (tabView.SelectedTab != null)
            {
                tabPanel = tabView.SelectedTab;
            }

            if (designerHost == null || tabPanel == null)
            {
                return;
            }

            using (DesignerTransaction transaction = designerHost.CreateTransaction($"Remove tab from \"{tabView.Name}\""))
            {
                try
                {
                    PropertyDescriptor controlsProperty = TypeDescriptor.GetProperties(tabView)[nameof(tabView.Controls)];

                    this.RaiseComponentChanging(controlsProperty);
                    designerHost.DestroyComponent(tabPanel);
                    this.RaiseComponentChanged(controlsProperty, null, null);

                    tabView.UpdateLayout();
                    tabView.Refresh();
                    transaction.Commit();
                }
                catch
                {
                    transaction.Cancel();
                }
            }
        }
        /*
         * DestroyNavigationPane
         */

        /// <summary>
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para>
        ///		<paramref name="navigationPaneToDestroy"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        protected void DestroyNavigationPane(NuGenNavigationPane navigationPaneToDestroy)
        {
            if (navigationPaneToDestroy == null)
            {
                throw new ArgumentNullException("navigationPaneToDestroy");
            }

            IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost));

            if (host != null)
            {
                DesignerTransaction transaction = null;

                try
                {
                    try
                    {
                        transaction = host.CreateTransaction("NuGenNavigationBar.RemoveNavigationPane");
                    }
                    catch (CheckoutException e)
                    {
                        if (e != CheckoutException.Canceled)
                        {
                            throw;
                        }

                        return;
                    }

                    _navigationBar.NavigationPanes.Remove(navigationPaneToDestroy);
                    host.DestroyComponent(navigationPaneToDestroy);
                }
                finally
                {
                    if (transaction != null)
                    {
                        transaction.Commit();
                    }
                }
            }
        }
        /// <summary>
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para>
        ///		<paramref name="tabPageToDestroy"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        protected void DestroyTabPage(NuGenTabPage tabPageToDestroy)
        {
            if (tabPageToDestroy == null)
            {
                throw new ArgumentNullException("tabPageToDestroy");
            }

            IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost));

            if (host != null)
            {
                DesignerTransaction transaction = null;

                try
                {
                    try
                    {
                        transaction = host.CreateTransaction("NuGenTabControl.RemoveTabPage");
                    }
                    catch (CheckoutException e)
                    {
                        if (e != CheckoutException.Canceled)
                        {
                            throw;
                        }

                        return;
                    }

                    _tabControl.TabPages.Remove(tabPageToDestroy);
                    host.DestroyComponent(tabPageToDestroy);
                }
                finally
                {
                    if (transaction != null)
                    {
                        transaction.Commit();
                    }
                }
            }
        }
 public override void Undo(UndoEngine engine)
 {
     if (this._nextUndoAdds)
     {
         IDesignerHost requiredService = engine.GetRequiredService(typeof(IDesignerHost)) as IDesignerHost;
         if (requiredService != null)
         {
             engine._serializationService.DeserializeTo(this._serializedData, requiredService.Container);
         }
     }
     else
     {
         IDesignerHost host2     = engine.GetRequiredService(typeof(IDesignerHost)) as IDesignerHost;
         IComponent    component = host2.Container.Components[this._componentName];
         if (component != null)
         {
             host2.DestroyComponent(component);
         }
     }
     this._nextUndoAdds = !this._nextUndoAdds;
 }
        private static void RemoveTab(DetailsTemplatesSurface designSurface)
        {
            UIService     uiservice    = null;
            IDesignerHost designerHost = designSurface.GetService(typeof(IDesignerHost)) as IDesignerHost;

            if (designerHost != null)
            {
                uiservice = (designerHost.GetService(typeof(UIService)) as UIService);
            }
            if (uiservice != null)
            {
                if (designSurface.TemplateTab.Controls.Count <= 1)
                {
                    uiservice.ShowMessage(Strings.CannotDeletePage);
                    return;
                }
                TabPage selectedTab = designSurface.TemplateTab.SelectedTab;
                if (selectedTab != null)
                {
                    DialogResult dialogResult = uiservice.ShowMessage(Strings.ConfirmDeleteTab(selectedTab.Text), UIService.DefaultCaption, MessageBoxButtons.OKCancel);
                    if (dialogResult == DialogResult.OK)
                    {
                        DesignerTransaction designerTransaction = null;
                        try
                        {
                            designerTransaction = designerHost.CreateTransaction("TabControlRemoveTabPage" + designSurface.TemplateTab.Site.Name);
                            designerHost.DestroyComponent(selectedTab);
                        }
                        finally
                        {
                            if (designerTransaction != null)
                            {
                                designerTransaction.Commit();
                            }
                        }
                        designSurface.DataContext.IsDirty = true;
                    }
                }
            }
        }
        private void OnRemove(object sender, EventArgs eevent)
        {
            TabControl component = (TabControl)base.Component;

            if ((component != null) && (component.TabPages.Count != 0))
            {
                MemberDescriptor member      = TypeDescriptor.GetProperties(base.Component)["Controls"];
                TabPage          selectedTab = component.SelectedTab;
                IDesignerHost    service     = (IDesignerHost)this.GetService(typeof(IDesignerHost));
                if (service != null)
                {
                    DesignerTransaction transaction = null;
                    try
                    {
                        try
                        {
                            transaction = service.CreateTransaction(System.Design.SR.GetString("TabControlRemoveTab", new object[] { selectedTab.Site.Name, base.Component.Site.Name }));
                            base.RaiseComponentChanging(member);
                        }
                        catch (CheckoutException exception)
                        {
                            if (exception != CheckoutException.Canceled)
                            {
                                throw exception;
                            }
                            return;
                        }
                        service.DestroyComponent(selectedTab);
                        base.RaiseComponentChanged(member, null, null);
                    }
                    finally
                    {
                        if (transaction != null)
                        {
                            transaction.Commit();
                        }
                    }
                }
            }
        }
 private object Transaction_RemovePage(IDesignerHost theHost, object theParam)
 {
     if (this.mySelectedPage != null)
     {
         MemberDescriptor member = TypeDescriptor.GetProperties(this.DesignedControl)["Controls"];
         base.RaiseComponentChanging(member);
         try
         {
             theHost.DestroyComponent(this.mySelectedPage);
         }
         catch
         {
         }
         base.RaiseComponentChanged(member, null, null);
     }
     return null;
 }
Beispiel #33
0
 /// <summary>
 /// Destroy instance of an object using the provided designer host.
 /// </summary>
 /// <param name="instance">Reference to item for destroying.</param>
 /// <param name="host">Designer host used if provided.</param>
 public static void DestroyInstance(object instance, IDesignerHost host)
 {
     IComponent component = instance as IComponent;
     if (component != null)
     {
         // Use designer to remove component if possible
         if (host != null)
             host.DestroyComponent(component);
         else
             component.Dispose();
     }
     else
     {
         // Fallback to calling any exposed dispose method
         IDisposable disposable = instance as IDisposable;
         if (disposable != null)
             disposable.Dispose();
     }
 }
 private object Transaction_RemoveTab(IDesignerHost host, object parameter)
 {
     // Tab Control
     NeoTabWindow tabControl = (NeoTabWindow)parameter;
     MemberDescriptor md = TypeDescriptor.GetProperties(tabControl)["Controls"];
     RaiseComponentChanging(md);
     host.DestroyComponent(tabControl.SelectedTab);
     RaiseComponentChanged(md, null, null);
     return parameter;
 }
Beispiel #35
0
 public void RemoveFromDesigner(IDesignerHost designer, Activity workflow)
 {
     if (workflow != null)
     {
         designer.DestroyComponent(workflow);
         if (workflow is CompositeActivity)
         {
             List<Activity> children = new List<Activity>();
             GetChildActivities(workflow as CompositeActivity, children);
             foreach (Activity child in children)
             {
                 designer.DestroyComponent(child);
             }
         }
     }
 }
        internal static void DeletePage(WizardPage page, IDesignerHost dh, IComponentChangeService cc)
        {
            if (page == null || !(page.Parent is PageSlider))
                return;

            PageSlider slider = (PageSlider)page.Parent;

            DesignerTransaction dt = dh.CreateTransaction("Deleting page");

            try
            {
                if (cc != null)
                    cc.OnComponentChanging(slider, TypeDescriptor.GetProperties(slider)["Controls"]);

                slider.Controls.Remove(page);

                if (cc != null)
                    cc.OnComponentChanged(slider, TypeDescriptor.GetProperties(slider)["Controls"], null, null);

                dh.DestroyComponent(page);
            }
            catch
            {
                dt.Cancel();
            }
            finally
            {
                if (!dt.Canceled)
                    dt.Commit();
            }
        }
Beispiel #37
0
        internal static void DestroyObjectGraphFromDesignerHost(IDesignerHost designerHost, Activity activity)
        {
            if (designerHost == null)
                throw new ArgumentNullException("designerHost");
            if (activity == null)
                throw new ArgumentNullException("activity");

            designerHost.DestroyComponent(activity);

            if (activity is CompositeActivity)
            {
                foreach (Activity activity2 in GetNestedActivities(activity as CompositeActivity))
                    designerHost.DestroyComponent(activity2);
            }
        }
Beispiel #38
0
        internal static void DeletePage(WizardPage page, IDesignerHost dh, IComponentChangeService cc)
        {
            if (page == null || !(page.Parent is Wizard))
                return;

            Wizard w = page.Parent as Wizard;

            DesignerTransaction dt = dh.CreateTransaction();

            try
            {
                if (cc != null)
                    cc.OnComponentChanging(w, TypeDescriptor.GetProperties(w)["WizardPages"]);

                w.WizardPages.Remove(page);

                if (cc != null)
                    cc.OnComponentChanged(w, TypeDescriptor.GetProperties(w)["WizardPages"], null, null);

                dh.DestroyComponent(page);
            }
            catch
            {
                dt.Cancel();
            }
            finally
            {
                if (!dt.Canceled)
                    dt.Commit();
            }
        }
Beispiel #39
0
		/// <summary>
		/// Destroys the component
		/// </summary>
		/// <param name="oDesignerHost">The designer instance interface</param>
		internal void DestroyComponent(IDesignerHost oDesignerHost)
		{
			// destroy subnodes
			foreach (Node oSubNode in Nodes.ToNodeArray())			
				oSubNode.DestroyComponent(oDesignerHost);	
		
			if (this.Panel != null)
			{
				if (GetTreeView() != null)
					GetTreeView().Controls.Remove(this.Panel);

				oDesignerHost.DestroyComponent(this.Panel);

				this.Panel = null;
			}

			// destroys the component
			oDesignerHost.DestroyComponent(this);			
		}
Beispiel #40
0
        public void RemoveRecursive(IContainsRibbonComponents item, IDesignerHost service)
        {
            if (item == null || service == null) return;

            foreach (Component c in item.GetAllChildComponents())
            {
                if (c is IContainsRibbonComponents)
                {
                    RemoveRecursive(c as IContainsRibbonComponents, service);
                }
                service.DestroyComponent(c);
            }
        }
Beispiel #41
0
        /// <include file='doc\ToolboxItem.uex' path='docs/doc[@for="ToolboxItem.CreateComponentsCore1"]/*' />
        /// <devdoc>
        ///     Creates objects from the type contained in this toolbox item.  If designerHost is non-null
        ///     this will also add them to the designer.
        /// </devdoc>
        protected virtual IComponent[] CreateComponentsCore(IDesignerHost host, IDictionary defaultValues) {
            IComponent[] components = CreateComponentsCore(host);

            if (host != null) {
                for (int i = 0; i < components.Length; i++) {
                    IComponentInitializer init = host.GetDesigner(components[i]) as IComponentInitializer;
                    if (init != null) {
                        bool removeComponent = true;
                        
                        try {
                            init.InitializeNewComponent(defaultValues);
                            removeComponent = false;

                        }
                        finally 
                        {
                            if (removeComponent) {
                                for (int index = 0; index < components.Length; index++) {
                                    host.DestroyComponent(components[index]);
                                }
                            }
                        }

                    }
                }
            }

            return components;
        }
        private object Transaction_RemovePage(IDesignerHost theHost, object theParam)
        {
            if (mySelectedPage == null)
                return null;

            MultiPaneControl aCtl = DesignedControl;

            MemberDescriptor aMember_Controls = TypeDescriptor.GetProperties(aCtl)["Controls"];

            RaiseComponentChanging(aMember_Controls);

            try
            {
                theHost.DestroyComponent(mySelectedPage);
                // NOTE: we don't process anything here because processing will
                // be performed in Handler_ComponentRemoving
            }
            catch { }

            RaiseComponentChanged(aMember_Controls, null, null);

            return null;
        }
Beispiel #43
0
		/// <summary>
		/// Destroys the component
		/// </summary>
		/// <param name="oDesignerHost">The designer instance interface</param>
		internal void DestroyComponentNoRemove(IDesignerHost oDesignerHost)
		{
			// destroy subnodes
			Node [] aNodes = Nodes.ToNodeArray();

			foreach (Node oNode in aNodes)			
				oNode.DestroyComponentNoRemove(oDesignerHost);			

			// destroys the component
			oDesignerHost.DestroyComponent(this);			
		}
		protected virtual void DestroySubItems(BaseItem parent, IDesignerHost dh)
		{
			if(parent is ControlContainerItem)
			{
				if(((ControlContainerItem)parent).Control!=null)
				{
					Control c=((ControlContainerItem)parent).Control;
					((ControlContainerItem)parent).Control=null;
					dh.DestroyComponent(c);
				}
			}
			else if(parent is DockContainerItem)
			{
				if(((DockContainerItem)parent).Control!=null)
				{
					Control c=((DockContainerItem)parent).Control;
					((DockContainerItem)parent).Control=null;
					dh.DestroyComponent(c);
				}
			}

			BaseItem[] subitems=new BaseItem[parent.SubItems.Count];
			parent.SubItems.CopyTo(subitems,0);
			foreach(BaseItem item in subitems)
			{
				DestroySubItems(item,dh);
				dh.DestroyComponent(item);
			}
		}
 protected virtual IComponent[] CreateComponentsCore(IDesignerHost host, IDictionary defaultValues)
 {
     IComponent[] componentArray = this.CreateComponentsCore(host);
     if (host != null)
     {
         for (int i = 0; i < componentArray.Length; i++)
         {
             IComponentInitializer designer = host.GetDesigner(componentArray[i]) as IComponentInitializer;
             if (designer != null)
             {
                 bool flag = true;
                 try
                 {
                     designer.InitializeNewComponent(defaultValues);
                     flag = false;
                 }
                 finally
                 {
                     if (flag)
                     {
                         for (int j = 0; j < componentArray.Length; j++)
                         {
                             host.DestroyComponent(componentArray[j]);
                         }
                     }
                 }
             }
         }
     }
     return componentArray;
 }