private void InvokeEmbedVerb()
        {
            DesignerActionUIService service = (DesignerActionUIService)this._toolStrip.Site.GetService(typeof(DesignerActionUIService));

            if (service != null)
            {
                service.HideUI(this._toolStrip);
            }
            this.changeParentVerb.ChangeParent();
        }
        public ListControlBoundActionList(ControlDesigner owner) : base(owner.Component)
        {
            this._owner = owner;
            ListControl component = (ListControl)base.Component;

            if (component.DataSource != null)
            {
                this._boundMode = true;
            }
            this.uiService = base.GetService(typeof(DesignerActionUIService)) as DesignerActionUIService;
        }
 public void Dispose()
 {
     if (this.marshalingControl != null)
     {
         this.marshalingControl.Dispose();
         this.marshalingControl = null;
     }
     if (this.serviceProvider != null)
     {
         IComponentChangeService service = (IComponentChangeService)this.serviceProvider.GetService(typeof(IComponentChangeService));
         if (service != null)
         {
             service.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged);
         }
         if (this.cmdShowDesignerActions != null)
         {
             IMenuCommandService service2 = (IMenuCommandService)this.serviceProvider.GetService(typeof(IMenuCommandService));
             if (service2 != null)
             {
                 service2.RemoveCommand(this.cmdShowDesignerActions);
             }
         }
     }
     this.serviceProvider = null;
     this.behaviorService = null;
     this.selSvc          = null;
     if (this.designerActionService != null)
     {
         this.designerActionService.DesignerActionListsChanged -= new DesignerActionListsChangedEventHandler(this.OnDesignerActionsChanged);
         if (this.disposeActionService)
         {
             this.designerActionService.Dispose();
         }
     }
     this.designerActionService = null;
     if (this.designerActionUIService != null)
     {
         this.designerActionUIService.DesignerActionUIStateChange -= new DesignerActionUIStateChangeEventHandler(this.OnDesignerActionUIStateChange);
         if (this.disposeActionUIService)
         {
             this.designerActionUIService.Dispose();
         }
     }
     this.designerActionUIService = null;
     this.designerActionAdorner   = null;
 }
 public DesignerActionUI(IServiceProvider serviceProvider, Adorner containerAdorner)
 {
     this.serviceProvider       = serviceProvider;
     this.designerActionAdorner = containerAdorner;
     this.behaviorService       = (BehaviorService)serviceProvider.GetService(typeof(BehaviorService));
     this.menuCommandService    = (IMenuCommandService)serviceProvider.GetService(typeof(IMenuCommandService));
     this.selSvc = (ISelectionService)serviceProvider.GetService(typeof(ISelectionService));
     if ((this.behaviorService != null) && (this.selSvc != null))
     {
         this.designerActionService = (DesignerActionService)serviceProvider.GetService(typeof(DesignerActionService));
         if (this.designerActionService == null)
         {
             this.designerActionService = new DesignerActionService(serviceProvider);
             this.disposeActionService  = true;
         }
         this.designerActionUIService = (DesignerActionUIService)serviceProvider.GetService(typeof(DesignerActionUIService));
         if (this.designerActionUIService == null)
         {
             this.designerActionUIService = new DesignerActionUIService(serviceProvider);
             this.disposeActionUIService  = true;
         }
         this.designerActionUIService.DesignerActionUIStateChange += new DesignerActionUIStateChangeEventHandler(this.OnDesignerActionUIStateChange);
         this.designerActionService.DesignerActionListsChanged    += new DesignerActionListsChangedEventHandler(this.OnDesignerActionsChanged);
         this.lastPanelComponent = null;
         IComponentChangeService service = (IComponentChangeService)serviceProvider.GetService(typeof(IComponentChangeService));
         if (service != null)
         {
             service.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
         }
         if (this.menuCommandService != null)
         {
             this.cmdShowDesignerActions = new MenuCommand(new EventHandler(this.OnKeyShowDesignerActions), MenuCommands.KeyInvokeSmartTag);
             this.menuCommandService.AddCommand(this.cmdShowDesignerActions);
         }
         this.uiService = (IUIService)serviceProvider.GetService(typeof(IUIService));
         if (this.uiService != null)
         {
             this.mainParentWindow = this.uiService.GetDialogOwnerWindow();
         }
         this.componentToGlyph  = new Hashtable();
         this.marshalingControl = new Control();
         this.marshalingControl.CreateControl();
     }
 }
        private void OnEditItems(object sender, EventArgs e)
        {
            DesignerActionUIService service = (DesignerActionUIService)((IServiceProvider)this).GetService(typeof(DesignerActionUIService));

            if (service != null)
            {
                service.HideUI(this._designer.Component);
            }
            object component = this._targetProperty.GetValue(this._designer.Component);

            if (component != null)
            {
                CollectionEditor editor = TypeDescriptor.GetEditor(component, typeof(UITypeEditor)) as CollectionEditor;
                if (editor != null)
                {
                    editor.EditValue(this, this, component);
                }
            }
        }
            private void OnOrientationActionClick(object sender, EventArgs e)
            {
                DesignerVerb verb = sender as DesignerVerb;

                if (verb != null)
                {
                    Orientation orientation = verb.Text.Equals(System.Design.SR.GetString("DesignerShortcutHorizontalOrientation")) ? Orientation.Horizontal : Orientation.Vertical;
                    this.actionName = (orientation == Orientation.Horizontal) ? System.Design.SR.GetString("DesignerShortcutVerticalOrientation") : System.Design.SR.GetString("DesignerShortcutHorizontalOrientation");
                    PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.ownerComponent)["Orientation"];
                    if ((descriptor != null) && (((Orientation)descriptor.GetValue(this.ownerComponent)) != orientation))
                    {
                        descriptor.SetValue(this.ownerComponent, orientation);
                    }
                    DesignerActionUIService service = (DesignerActionUIService)this.owner.GetService(typeof(DesignerActionUIService));
                    if (service != null)
                    {
                        service.Refresh(this.ownerComponent);
                    }
                }
            }
Exemple #7
0
        /// <summary>
        ///  When the verb is invoked, change the parent of the ToolStrip.
        /// </summary>
        // This is actually called...
        public void ChangeParent()
        {
            Cursor current = Cursor.Current;
            // create a transaction so this happens as an atomic unit.
            DesignerTransaction changeParent = _host.CreateTransaction("Add ToolStripContainer Transaction");

            try
            {
                Cursor.Current = Cursors.WaitCursor;
                //Add a New ToolStripContainer to the RootComponent ...
                Control root = _host.RootComponent as Control;
                if (_host.GetDesigner(root) is ParentControlDesigner rootDesigner)
                {
                    // close the DAP first - this is so that the autoshown panel on drag drop here is not conflicting with the currently opened panel
                    // if the verb was called from the panel
                    ToolStrip toolStrip = _designer.Component as ToolStrip;
                    if (toolStrip != null && _designer != null && _designer.Component != null && _provider != null)
                    {
                        DesignerActionUIService dapuisvc = _provider.GetService(typeof(DesignerActionUIService)) as DesignerActionUIService;
                        dapuisvc.HideUI(toolStrip);
                    }

                    // Get OleDragHandler ...
                    ToolboxItem        tbi = new ToolboxItem(typeof(ToolStripContainer));
                    OleDragDropHandler ddh = rootDesigner.GetOleDragHandler();
                    if (ddh != null)
                    {
                        IComponent[] newComp = ddh.CreateTool(tbi, root, 0, 0, 0, 0, false, false);
                        if (newComp[0] is ToolStripContainer tsc)
                        {
                            if (toolStrip != null)
                            {
                                var                changeService = _provider.GetService <IComponentChangeService>();
                                Control            newParent     = GetParent(tsc, toolStrip);
                                PropertyDescriptor controlsProp  = TypeDescriptor.GetProperties(newParent)["Controls"];
                                Control            oldParent     = toolStrip.Parent;
                                if (oldParent != null)
                                {
                                    changeService.OnComponentChanging(oldParent, controlsProp);
                                    //remove control from the old parent
                                    oldParent.Controls.Remove(toolStrip);
                                }

                                if (newParent != null)
                                {
                                    changeService.OnComponentChanging(newParent, controlsProp);
                                    //finally add & relocate the control with the new parent
                                    newParent.Controls.Add(toolStrip);
                                }

                                //fire our comp changed events
                                if (changeService != null && oldParent != null && newParent != null)
                                {
                                    changeService.OnComponentChanged(oldParent, controlsProp);
                                    changeService.OnComponentChanged(newParent, controlsProp);
                                }

                                //Set the Selection on the new Parent ... so that the selection is restored to the new item,
                                if (_provider.GetService(typeof(ISelectionService)) is ISelectionService selSvc)
                                {
                                    selSvc.SetSelectedComponents(new IComponent[] { tsc });
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (e is InvalidOperationException)
                {
                    IUIService uiService = (IUIService)_provider.GetService(typeof(IUIService));
                    uiService.ShowError(e.Message);
                }

                if (changeParent != null)
                {
                    changeParent.Cancel();
                    changeParent = null;
                }
            }
            finally
            {
                if (changeParent != null)
                {
                    changeParent.Commit();
                }

                Cursor.Current = current;
            }
        }
        /// <summary>
        ///  Here is where all the fun stuff starts.  We create the structure and apply the naming here.
        /// </summary>
        private void CreateStandardMenuStrip(IDesignerHost host, MenuStrip tool)
        {
            // build the static menu items structure.
            string[][] menuItemNames = new string[][]
            {
                new string[] { SR.StandardMenuFile, SR.StandardMenuNew, SR.StandardMenuOpen, "-", SR.StandardMenuSave, SR.StandardMenuSaveAs, "-", SR.StandardMenuPrint, SR.StandardMenuPrintPreview, "-", SR.StandardMenuExit },
                new string[] { SR.StandardMenuEdit, SR.StandardMenuUndo, SR.StandardMenuRedo, "-", SR.StandardMenuCut, SR.StandardMenuCopy, SR.StandardMenuPaste, "-", SR.StandardMenuSelectAll },
                new string[] { SR.StandardMenuTools, SR.StandardMenuCustomize, SR.StandardMenuOptions },
                new string[] { SR.StandardMenuHelp, SR.StandardMenuContents, SR.StandardMenuIndex, SR.StandardMenuSearch, "-", SR.StandardMenuAbout }
            };

            // build the static menu items image list that maps one-one with above menuItems structure. this is required so that the in LOCALIZED build we dont use the Localized item string.
            string[][] menuItemImageNames = new string[][]
            {
                new string[] { "", "new", "open", "-", "save", "", "-", "print", "printPreview", "-", "" },
                new string[] { "", "", "", "-", "cut", "copy", "paste", "-", "" },
                new string[] { "", "", "" },
                new string[] { "", "", "", "", "-", "" }
            };

            Keys[][] menuItemShortcuts = new Keys[][]
            {
                new Keys[] { /*File*/ Keys.None, /*New*/ Keys.Control | Keys.N, /*Open*/ Keys.Control | Keys.O, /*Separator*/ Keys.None, /*Save*/ Keys.Control | Keys.S, /*SaveAs*/ Keys.None, Keys.None, /*Print*/ Keys.Control | Keys.P, /*PrintPreview*/ Keys.None, /*Separator*/ Keys.None, /*Exit*/ Keys.None },
                new Keys[] { /*Edit*/ Keys.None, /*Undo*/ Keys.Control | Keys.Z, /*Redo*/ Keys.Control | Keys.Y, /*Separator*/ Keys.None, /*Cut*/ Keys.Control | Keys.X, /*Copy*/ Keys.Control | Keys.C, /*Paste*/ Keys.Control | Keys.V, /*Separator*/ Keys.None, /*SelectAll*/ Keys.None },
                new Keys[] { /*Tools*/ Keys.None, /*Customize*/ Keys.None, /*Options*/ Keys.None },
                new Keys[] { /*Help*/ Keys.None, /*Contents*/ Keys.None, /*Index*/ Keys.None, /*Search*/ Keys.None, /*Separator*/ Keys.None, /*About*/ Keys.None }
            };

            Debug.Assert(host != null, "can't create standard menu without designer _host.");
            if (host is null)
            {
                return;
            }

            tool.SuspendLayout();
            ToolStripDesigner.s_autoAddNewItems = false;
            // create a transaction so this happens as an atomic unit.
            DesignerTransaction createMenu = _host.CreateTransaction(SR.StandardMenuCreateDesc);

            try
            {
                INameCreationService nameCreationService = (INameCreationService)_provider.GetService(typeof(INameCreationService));
                string defaultName = "standardMainMenuStrip";
                string name        = defaultName;
                int    index       = 1;

                if (host != null)
                {
                    while (_host.Container.Components[name] != null)
                    {
                        name = defaultName + (index++).ToString(CultureInfo.InvariantCulture);
                    }
                }

                // now build the menu items themselves.
                for (int j = 0; j < menuItemNames.Length; j++)
                {
                    string[]          menuArray = menuItemNames[j];
                    ToolStripMenuItem rootItem  = null;
                    for (int i = 0; i < menuArray.Length; i++)
                    {
                        name = null;
                        // for separators, just use the default name.  Otherwise, remove any non-characters and  get the name from the text.
                        string itemText = menuArray[i];
                        name = NameFromText(itemText, typeof(ToolStripMenuItem), nameCreationService, true);
                        ToolStripItem item = null;
                        if (name.Contains("Separator"))
                        {
                            // create the componennt.
                            item = (ToolStripSeparator)_host.CreateComponent(typeof(ToolStripSeparator), name);
                            IDesigner designer = _host.GetDesigner(item);
                            if (designer is ComponentDesigner)
                            {
                                ((ComponentDesigner)designer).InitializeNewComponent(null);
                            }

                            item.Text = itemText;
                        }
                        else
                        {
                            // create the componennt.
                            item = (ToolStripMenuItem)_host.CreateComponent(typeof(ToolStripMenuItem), name);
                            IDesigner designer = _host.GetDesigner(item);
                            if (designer is ComponentDesigner)
                            {
                                ((ComponentDesigner)designer).InitializeNewComponent(null);
                            }

                            item.Text = itemText;
                            Keys shortcut = menuItemShortcuts[j][i];
                            if ((item is ToolStripMenuItem) && shortcut != Keys.None)
                            {
                                if (!ToolStripManager.IsShortcutDefined(shortcut) && ToolStripManager.IsValidShortcut(shortcut))
                                {
                                    ((ToolStripMenuItem)item).ShortcutKeys = shortcut;
                                }
                            }

                            Bitmap image = null;
                            try
                            {
                                image = GetImage(menuItemImageNames[j][i]);
                            }
                            catch
                            {
                                // eat the exception.. as you may not find image for all MenuItems.
                            }

                            if (image != null)
                            {
                                PropertyDescriptor imageProperty = TypeDescriptor.GetProperties(item)["Image"];
                                Debug.Assert(imageProperty != null, "Could not find 'Image' property in ToolStripItem.");
                                if (imageProperty != null)
                                {
                                    imageProperty.SetValue(item, image);
                                }

                                item.ImageTransparentColor = Color.Magenta;
                            }
                        }

                        // the first item in each array is the root item.
                        if (i == 0)
                        {
                            rootItem = (ToolStripMenuItem)item;
                            rootItem.DropDown.SuspendLayout();
                        }
                        else
                        {
                            rootItem.DropDownItems.Add(item);
                        }

                        //If Last SubItem Added the Raise the Events
                        if (i == menuArray.Length - 1)
                        {
                            // member is OK to be null...
                            MemberDescriptor member = TypeDescriptor.GetProperties(rootItem)["DropDownItems"];
                            _componentChangeSvc.OnComponentChanging(rootItem, member);
                            _componentChangeSvc.OnComponentChanged(rootItem, member, null, null);
                        }
                    }

                    // finally, add it to the MainMenu.
                    rootItem.DropDown.ResumeLayout(false);
                    tool.Items.Add(rootItem);
                    //If Last SubItem Added the Raise the Events
                    if (j == menuItemNames.Length - 1)
                    {
                        // member is OK to be null...
                        MemberDescriptor topMember = TypeDescriptor.GetProperties(tool)["Items"];
                        _componentChangeSvc.OnComponentChanging(tool, topMember);
                        _componentChangeSvc.OnComponentChanged(tool, topMember, null, null);
                    }
                }
            }
            catch (Exception e)
            {
                if (e is InvalidOperationException)
                {
                    IUIService uiService = (IUIService)_provider.GetService(typeof(IUIService));
                    uiService.ShowError(e.Message);
                }

                if (createMenu != null)
                {
                    createMenu.Cancel();
                    createMenu = null;
                }
            }
            finally
            {
                ToolStripDesigner.s_autoAddNewItems = true;
                if (createMenu != null)
                {
                    createMenu.Commit();
                    createMenu = null;
                }

                tool.ResumeLayout();
                // Select the Main Menu...
                ISelectionService selSvc = (ISelectionService)_provider.GetService(typeof(ISelectionService));
                if (selSvc != null)
                {
                    selSvc.SetSelectedComponents(new object[] { _designer.Component });
                }

                //Refresh the Glyph
                DesignerActionUIService actionUIService = (DesignerActionUIService)_provider.GetService(typeof(DesignerActionUIService));
                if (actionUIService != null)
                {
                    actionUIService.Refresh(_designer.Component);
                }

                // this will invalidate the Selection Glyphs.
                SelectionManager selMgr = (SelectionManager)_provider.GetService(typeof(SelectionManager));
                selMgr.Refresh();
            }
        }
        /// <summary>
        ///  Here is where all the fun stuff starts.  We create the structure and apply the naming here.
        /// </summary>
        private void CreateStandardToolStrip(IDesignerHost host, ToolStrip tool)
        {
            // build the static menu items structure.
            //
            string[] menuItemNames = new string[] { SR.StandardMenuNew, SR.StandardMenuOpen, SR.StandardMenuSave, SR.StandardMenuPrint, "-", SR.StandardToolCut, SR.StandardMenuCopy, SR.StandardMenuPaste, "-", SR.StandardToolHelp };

            // build a image list mapping one-one the above menuItems list... this is required so that the in LOCALIZED build we dont use the Localized item string.
            string[] menuItemImageNames = new string[] { "new", "open", "save", "print", "-", "cut", "copy", "paste", "-", "help" };
            Debug.Assert(host != null, "can't create standard menu without designer _host.");

            if (host is null)
            {
                return;
            }

            tool.SuspendLayout();
            ToolStripDesigner.s_autoAddNewItems = false;
            // create a transaction so this happens as an atomic unit.
            DesignerTransaction createMenu = _host.CreateTransaction(SR.StandardMenuCreateDesc);

            try
            {
                INameCreationService nameCreationService = (INameCreationService)_provider.GetService(typeof(INameCreationService));
                string defaultName = "standardMainToolStrip";
                string name        = defaultName;
                int    index       = 1;
                if (host != null)
                {
                    while (_host.Container.Components[name] != null)
                    {
                        name = defaultName + (index++).ToString(CultureInfo.InvariantCulture);
                    }
                }

                //keep an index in the MenuItemImageNames .. so that mapping is maintained.
                int menuItemImageNamesCount = 0;
                // now build the menu items themselves.
                foreach (string itemText in menuItemNames)
                {
                    name = null;
                    // for separators, just use the default name.  Otherwise, remove any non-characters and get the name from the text.
                    defaultName = "ToolStripButton";
                    name        = NameFromText(itemText, typeof(ToolStripButton), nameCreationService, true);
                    ToolStripItem item = null;
                    if (name.Contains("Separator"))
                    {
                        // create the componennt.
                        item = (ToolStripSeparator)_host.CreateComponent(typeof(ToolStripSeparator), name);
                        IDesigner designer = _host.GetDesigner(item);
                        if (designer is ComponentDesigner)
                        {
                            ((ComponentDesigner)designer).InitializeNewComponent(null);
                        }
                    }
                    else
                    {
                        // create the component.
                        item = (ToolStripButton)_host.CreateComponent(typeof(ToolStripButton), name);
                        IDesigner designer = _host.GetDesigner(item);
                        if (designer is ComponentDesigner)
                        {
                            ((ComponentDesigner)designer).InitializeNewComponent(null);
                        }

                        PropertyDescriptor displayStyleProperty = TypeDescriptor.GetProperties(item)["DisplayStyle"];
                        Debug.Assert(displayStyleProperty != null, "Could not find 'Text' property in ToolStripItem.");
                        if (displayStyleProperty != null)
                        {
                            displayStyleProperty.SetValue(item, ToolStripItemDisplayStyle.Image);
                        }

                        PropertyDescriptor textProperty = TypeDescriptor.GetProperties(item)["Text"];
                        Debug.Assert(textProperty != null, "Could not find 'Text' property in ToolStripItem.");
                        if (textProperty != null)
                        {
                            textProperty.SetValue(item, itemText);
                        }

                        Bitmap image = null;
                        try
                        {
                            image = GetImage(menuItemImageNames[menuItemImageNamesCount]);
                        }
                        catch
                        {
                            // eat the exception.. as you may not find image for all MenuItems.
                        }

                        if (image != null)
                        {
                            PropertyDescriptor imageProperty = TypeDescriptor.GetProperties(item)["Image"];
                            Debug.Assert(imageProperty != null, "Could not find 'Image' property in ToolStripItem.");
                            if (imageProperty != null)
                            {
                                imageProperty.SetValue(item, image);
                            }

                            item.ImageTransparentColor = Color.Magenta;
                        }
                    }

                    tool.Items.Add(item);
                    //increment the counter...
                    menuItemImageNamesCount++;
                }

                // finally, add it to the Main ToolStrip.
                MemberDescriptor topMember = TypeDescriptor.GetProperties(tool)["Items"];
                _componentChangeSvc.OnComponentChanging(tool, topMember);
                _componentChangeSvc.OnComponentChanged(tool, topMember, null, null);
            }
            catch (Exception e)
            {
                if (e is InvalidOperationException)
                {
                    IUIService uiService = (IUIService)_provider.GetService(typeof(IUIService));
                    uiService.ShowError(e.Message);
                }

                if (createMenu != null)
                {
                    createMenu.Cancel();
                    createMenu = null;
                }
            }
            finally
            {
                //Reset the AutoAdd state
                ToolStripDesigner.s_autoAddNewItems = true;
                if (createMenu != null)
                {
                    createMenu.Commit();
                    createMenu = null;
                }

                tool.ResumeLayout();
                // Select the Main Menu...
                ISelectionService selSvc = (ISelectionService)_provider.GetService(typeof(ISelectionService));
                if (selSvc != null)
                {
                    selSvc.SetSelectedComponents(new object[] { _designer.Component });
                }

                //Refresh the Glyph
                DesignerActionUIService actionUIService = (DesignerActionUIService)_provider.GetService(typeof(DesignerActionUIService));
                if (actionUIService != null)
                {
                    actionUIService.Refresh(_designer.Component);
                }

                // this will invalidate the Selection Glyphs.
                SelectionManager selMgr = (SelectionManager)_provider.GetService(typeof(SelectionManager));
                selMgr.Refresh();
            }
        }
 private void CreateStandardMenuStrip(IDesignerHost host, MenuStrip tool)
 {
     string[][] strArray   = new string[][] { new string[] { System.Design.SR.GetString("StandardMenuFile"), System.Design.SR.GetString("StandardMenuNew"), System.Design.SR.GetString("StandardMenuOpen"), "-", System.Design.SR.GetString("StandardMenuSave"), System.Design.SR.GetString("StandardMenuSaveAs"), "-", System.Design.SR.GetString("StandardMenuPrint"), System.Design.SR.GetString("StandardMenuPrintPreview"), "-", System.Design.SR.GetString("StandardMenuExit") }, new string[] { System.Design.SR.GetString("StandardMenuEdit"), System.Design.SR.GetString("StandardMenuUndo"), System.Design.SR.GetString("StandardMenuRedo"), "-", System.Design.SR.GetString("StandardMenuCut"), System.Design.SR.GetString("StandardMenuCopy"), System.Design.SR.GetString("StandardMenuPaste"), "-", System.Design.SR.GetString("StandardMenuSelectAll") }, new string[] { System.Design.SR.GetString("StandardMenuTools"), System.Design.SR.GetString("StandardMenuCustomize"), System.Design.SR.GetString("StandardMenuOptions") }, new string[] { System.Design.SR.GetString("StandardMenuHelp"), System.Design.SR.GetString("StandardMenuContents"), System.Design.SR.GetString("StandardMenuIndex"), System.Design.SR.GetString("StandardMenuSearch"), "-", System.Design.SR.GetString("StandardMenuAbout") } };
     string[][] strArray2  = new string[][] { new string[] { "", "new", "open", "-", "save", "", "-", "print", "printPreview", "-", "" }, new string[] { "", "", "", "-", "cut", "copy", "paste", "-", "" }, new string[] { "", "", "" }, new string[] { "", "", "", "", "-", "" } };
     Keys[][]   keysArray2 = new Keys[4][];
     Keys[]     keysArray3 = new Keys[11];
     keysArray3[1] = Keys.Control | Keys.N;
     keysArray3[2] = Keys.Control | Keys.O;
     keysArray3[4] = Keys.Control | Keys.S;
     keysArray3[7] = Keys.Control | Keys.P;
     keysArray2[0] = keysArray3;
     Keys[] keysArray4 = new Keys[9];
     keysArray4[1] = Keys.Control | Keys.Z;
     keysArray4[2] = Keys.Control | Keys.Y;
     keysArray4[4] = Keys.Control | Keys.X;
     keysArray4[5] = Keys.Control | Keys.C;
     keysArray4[6] = Keys.Control | Keys.V;
     keysArray2[1] = keysArray4;
     keysArray2[2] = new Keys[3];
     keysArray2[3] = new Keys[6];
     Keys[][] keysArray = keysArray2;
     if (host != null)
     {
         tool.SuspendLayout();
         ToolStripDesigner._autoAddNewItems = false;
         DesignerTransaction transaction = this._host.CreateTransaction(System.Design.SR.GetString("StandardMenuCreateDesc"));
         try
         {
             INameCreationService nameCreationService = (INameCreationService)this._provider.GetService(typeof(INameCreationService));
             string str  = "standardMainMenuStrip";
             string name = str;
             int    num  = 1;
             if (host != null)
             {
                 while (this._host.Container.Components[name] != null)
                 {
                     name = str + num++.ToString(CultureInfo.InvariantCulture);
                 }
             }
             for (int i = 0; i < strArray.Length; i++)
             {
                 string[]          strArray3 = strArray[i];
                 ToolStripMenuItem component = null;
                 for (int j = 0; j < strArray3.Length; j++)
                 {
                     name = null;
                     string text = strArray3[j];
                     name = this.NameFromText(text, typeof(ToolStripMenuItem), nameCreationService, true);
                     ToolStripItem item2 = null;
                     if (name.Contains("Separator"))
                     {
                         item2 = (ToolStripSeparator)this._host.CreateComponent(typeof(ToolStripSeparator), name);
                         IDesigner designer = this._host.GetDesigner(item2);
                         if (designer is ComponentDesigner)
                         {
                             ((ComponentDesigner)designer).InitializeNewComponent(null);
                         }
                         item2.Text = text;
                     }
                     else
                     {
                         item2 = (ToolStripMenuItem)this._host.CreateComponent(typeof(ToolStripMenuItem), name);
                         IDesigner designer2 = this._host.GetDesigner(item2);
                         if (designer2 is ComponentDesigner)
                         {
                             ((ComponentDesigner)designer2).InitializeNewComponent(null);
                         }
                         item2.Text = text;
                         Keys shortcut = keysArray[i][j];
                         if (((item2 is ToolStripMenuItem) && (shortcut != Keys.None)) && (!ToolStripManager.IsShortcutDefined(shortcut) && ToolStripManager.IsValidShortcut(shortcut)))
                         {
                             ((ToolStripMenuItem)item2).ShortcutKeys = shortcut;
                         }
                         Bitmap image = null;
                         try
                         {
                             image = this.GetImage(strArray2[i][j]);
                         }
                         catch
                         {
                         }
                         if (image != null)
                         {
                             PropertyDescriptor descriptor = TypeDescriptor.GetProperties(item2)["Image"];
                             if (descriptor != null)
                             {
                                 descriptor.SetValue(item2, image);
                             }
                             item2.ImageTransparentColor = Color.Magenta;
                         }
                     }
                     if (j == 0)
                     {
                         component = (ToolStripMenuItem)item2;
                         component.DropDown.SuspendLayout();
                     }
                     else
                     {
                         component.DropDownItems.Add(item2);
                     }
                     if (j == (strArray3.Length - 1))
                     {
                         MemberDescriptor member = TypeDescriptor.GetProperties(component)["DropDownItems"];
                         this.componentChangeSvc.OnComponentChanging(component, member);
                         this.componentChangeSvc.OnComponentChanged(component, member, null, null);
                     }
                 }
                 component.DropDown.ResumeLayout(false);
                 tool.Items.Add(component);
                 if (i == (strArray.Length - 1))
                 {
                     MemberDescriptor descriptor3 = TypeDescriptor.GetProperties(tool)["Items"];
                     this.componentChangeSvc.OnComponentChanging(tool, descriptor3);
                     this.componentChangeSvc.OnComponentChanged(tool, descriptor3, null, null);
                 }
             }
         }
         catch (Exception exception)
         {
             if (exception is InvalidOperationException)
             {
                 ((IUIService)this._provider.GetService(typeof(IUIService))).ShowError(exception.Message);
             }
             if (transaction != null)
             {
                 transaction.Cancel();
                 transaction = null;
             }
         }
         finally
         {
             ToolStripDesigner._autoAddNewItems = true;
             if (transaction != null)
             {
                 transaction.Commit();
                 transaction = null;
             }
             tool.ResumeLayout();
             ISelectionService service = (ISelectionService)this._provider.GetService(typeof(ISelectionService));
             if (service != null)
             {
                 service.SetSelectedComponents(new object[] { this._designer.Component });
             }
             DesignerActionUIService service4 = (DesignerActionUIService)this._provider.GetService(typeof(DesignerActionUIService));
             if (service4 != null)
             {
                 service4.Refresh(this._designer.Component);
             }
             ((SelectionManager)this._provider.GetService(typeof(SelectionManager))).Refresh();
         }
     }
 }
 private void CreateStandardToolStrip(IDesignerHost host, ToolStrip tool)
 {
     string[] strArray  = new string[] { System.Design.SR.GetString("StandardMenuNew"), System.Design.SR.GetString("StandardMenuOpen"), System.Design.SR.GetString("StandardMenuSave"), System.Design.SR.GetString("StandardMenuPrint"), "-", System.Design.SR.GetString("StandardToolCut"), System.Design.SR.GetString("StandardMenuCopy"), System.Design.SR.GetString("StandardMenuPaste"), "-", System.Design.SR.GetString("StandardToolHelp") };
     string[] strArray2 = new string[] { "new", "open", "save", "print", "-", "cut", "copy", "paste", "-", "help" };
     if (host != null)
     {
         tool.SuspendLayout();
         ToolStripDesigner._autoAddNewItems = false;
         DesignerTransaction transaction = this._host.CreateTransaction(System.Design.SR.GetString("StandardMenuCreateDesc"));
         try
         {
             INameCreationService nameCreationService = (INameCreationService)this._provider.GetService(typeof(INameCreationService));
             string str  = "standardMainToolStrip";
             string name = str;
             int    num  = 1;
             if (host != null)
             {
                 while (this._host.Container.Components[name] != null)
                 {
                     name = str + num++.ToString(CultureInfo.InvariantCulture);
                 }
             }
             int index = 0;
             foreach (string str3 in strArray)
             {
                 name = null;
                 str  = "ToolStripButton";
                 name = this.NameFromText(str3, typeof(ToolStripButton), nameCreationService, true);
                 ToolStripItem component = null;
                 if (name.Contains("Separator"))
                 {
                     component = (ToolStripSeparator)this._host.CreateComponent(typeof(ToolStripSeparator), name);
                     IDesigner designer = this._host.GetDesigner(component);
                     if (designer is ComponentDesigner)
                     {
                         ((ComponentDesigner)designer).InitializeNewComponent(null);
                     }
                 }
                 else
                 {
                     component = (ToolStripButton)this._host.CreateComponent(typeof(ToolStripButton), name);
                     IDesigner designer2 = this._host.GetDesigner(component);
                     if (designer2 is ComponentDesigner)
                     {
                         ((ComponentDesigner)designer2).InitializeNewComponent(null);
                     }
                     PropertyDescriptor descriptor = TypeDescriptor.GetProperties(component)["DisplayStyle"];
                     if (descriptor != null)
                     {
                         descriptor.SetValue(component, ToolStripItemDisplayStyle.Image);
                     }
                     PropertyDescriptor descriptor2 = TypeDescriptor.GetProperties(component)["Text"];
                     if (descriptor2 != null)
                     {
                         descriptor2.SetValue(component, str3);
                     }
                     Bitmap image = null;
                     try
                     {
                         image = this.GetImage(strArray2[index]);
                     }
                     catch
                     {
                     }
                     if (image != null)
                     {
                         PropertyDescriptor descriptor3 = TypeDescriptor.GetProperties(component)["Image"];
                         if (descriptor3 != null)
                         {
                             descriptor3.SetValue(component, image);
                         }
                         component.ImageTransparentColor = Color.Magenta;
                     }
                 }
                 tool.Items.Add(component);
                 index++;
             }
             MemberDescriptor member = TypeDescriptor.GetProperties(tool)["Items"];
             this.componentChangeSvc.OnComponentChanging(tool, member);
             this.componentChangeSvc.OnComponentChanged(tool, member, null, null);
         }
         catch (Exception exception)
         {
             if (exception is InvalidOperationException)
             {
                 ((IUIService)this._provider.GetService(typeof(IUIService))).ShowError(exception.Message);
             }
             if (transaction != null)
             {
                 transaction.Cancel();
                 transaction = null;
             }
         }
         finally
         {
             ToolStripDesigner._autoAddNewItems = true;
             if (transaction != null)
             {
                 transaction.Commit();
                 transaction = null;
             }
             tool.ResumeLayout();
             ISelectionService service = (ISelectionService)this._provider.GetService(typeof(ISelectionService));
             if (service != null)
             {
                 service.SetSelectedComponents(new object[] { this._designer.Component });
             }
             DesignerActionUIService service4 = (DesignerActionUIService)this._provider.GetService(typeof(DesignerActionUIService));
             if (service4 != null)
             {
                 service4.Refresh(this._designer.Component);
             }
             ((SelectionManager)this._provider.GetService(typeof(SelectionManager))).Refresh();
         }
     }
 }