Пример #1
0
 private void PopulateList()
 {
     this.insertToolStripMenuItem          = new ToolStripMenuItem();
     this.insertToolStripMenuItem.Text     = System.Design.SR.GetString("ToolStripItemContextMenuInsert");
     this.insertToolStripMenuItem.DropDown = ToolStripDesignerUtils.GetNewItemDropDown(this.ParentTool, this.currentItem, new EventHandler(this.AddNewItemClick), false, this.serviceProvider);
     base.Add(this.insertToolStripMenuItem);
 }
        private void PopulateList()
        {
            ToolStripItem currentItem = this.currentItem;

            if (!(currentItem is ToolStripControlHost) && !(currentItem is ToolStripSeparator))
            {
                this.imageToolStripMenuItem       = new ToolStripMenuItem();
                this.imageToolStripMenuItem.Text  = System.Design.SR.GetString("ToolStripItemContextMenuSetImage");
                this.imageToolStripMenuItem.Image = new Bitmap(typeof(ToolStripMenuItem), "image.bmp");
                this.imageToolStripMenuItem.ImageTransparentColor = Color.Magenta;
                this.imageToolStripMenuItem.Click += new EventHandler(this.OnImageToolStripMenuItemClick);
                this.enabledToolStripMenuItem      = this.CreateBooleanItem("E&nabled", "Enabled");
                base.AddRange(new ToolStripItem[] { this.imageToolStripMenuItem, this.enabledToolStripMenuItem });
                if (currentItem is ToolStripMenuItem)
                {
                    this.checkedToolStripMenuItem          = this.CreateBooleanItem("C&hecked", "Checked");
                    this.showShortcutKeysToolStripMenuItem = this.CreateBooleanItem("ShowShortcut&Keys", "ShowShortcutKeys");
                    base.AddRange(new ToolStripItem[] { this.checkedToolStripMenuItem, this.showShortcutKeysToolStripMenuItem });
                }
                else
                {
                    if (currentItem is ToolStripLabel)
                    {
                        this.isLinkToolStripMenuItem = this.CreateBooleanItem("IsLin&k", "IsLink");
                        base.Add(this.isLinkToolStripMenuItem);
                    }
                    if (currentItem is ToolStripStatusLabel)
                    {
                        this.springToolStripMenuItem = this.CreateBooleanItem("Sprin&g", "Spring");
                        base.Add(this.springToolStripMenuItem);
                    }
                    this.leftToolStripMenuItem           = this.CreateEnumValueItem("Alignment", "Left", ToolStripItemAlignment.Left);
                    this.rightToolStripMenuItem          = this.CreateEnumValueItem("Alignment", "Right", ToolStripItemAlignment.Right);
                    this.noneStyleToolStripMenuItem      = this.CreateEnumValueItem("DisplayStyle", "None", ToolStripItemDisplayStyle.None);
                    this.textStyleToolStripMenuItem      = this.CreateEnumValueItem("DisplayStyle", "Text", ToolStripItemDisplayStyle.Text);
                    this.imageStyleToolStripMenuItem     = this.CreateEnumValueItem("DisplayStyle", "Image", ToolStripItemDisplayStyle.Image);
                    this.imageTextStyleToolStripMenuItem = this.CreateEnumValueItem("DisplayStyle", "ImageAndText", ToolStripItemDisplayStyle.ImageAndText);
                    this.alignmentToolStripMenuItem      = this.CreatePropertyBasedItem("Ali&gnment", "Alignment", "alignment.bmp");
                    this.alignmentToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { this.leftToolStripMenuItem, this.rightToolStripMenuItem });
                    this.displayStyleToolStripMenuItem = this.CreatePropertyBasedItem("Displa&yStyle", "DisplayStyle", "displaystyle.bmp");
                    this.displayStyleToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { this.noneStyleToolStripMenuItem, this.textStyleToolStripMenuItem, this.imageStyleToolStripMenuItem, this.imageTextStyleToolStripMenuItem });
                    base.AddRange(new ToolStripItem[] { this.alignmentToolStripMenuItem, this.displayStyleToolStripMenuItem });
                }
                this.toolStripSeparator1 = new ToolStripSeparator();
                base.Add(this.toolStripSeparator1);
            }
            this.convertToolStripMenuItem          = new ToolStripMenuItem();
            this.convertToolStripMenuItem.Text     = System.Design.SR.GetString("ToolStripItemContextMenuConvertTo");
            this.convertToolStripMenuItem.DropDown = ToolStripDesignerUtils.GetNewItemDropDown(this.ParentTool, this.currentItem, new EventHandler(this.AddNewItemClick), true, this.serviceProvider);
            this.insertToolStripMenuItem           = new ToolStripMenuItem();
            this.insertToolStripMenuItem.Text      = System.Design.SR.GetString("ToolStripItemContextMenuInsert");
            this.insertToolStripMenuItem.DropDown  = ToolStripDesignerUtils.GetNewItemDropDown(this.ParentTool, this.currentItem, new EventHandler(this.AddNewItemClick), false, this.serviceProvider);
            base.AddRange(new ToolStripItem[] { this.convertToolStripMenuItem, this.insertToolStripMenuItem });
            if (this.currentItem is ToolStripDropDownItem)
            {
                IDesignerHost service = (IDesignerHost)this.serviceProvider.GetService(typeof(IDesignerHost));
                if (service != null)
                {
                    ToolStripItemDesigner designer = service.GetDesigner(this.currentItem) as ToolStripItemDesigner;
                    if (designer != null)
                    {
                        this.verbManager = new CollectionEditVerbManager(System.Design.SR.GetString("ToolStripDropDownItemCollectionEditorVerb"), designer, TypeDescriptor.GetProperties(this.currentItem)["DropDownItems"], false);
                        this.editItemsToolStripMenuItem        = new ToolStripMenuItem();
                        this.editItemsToolStripMenuItem.Text   = System.Design.SR.GetString("ToolStripDropDownItemCollectionEditorVerb");
                        this.editItemsToolStripMenuItem.Click += new EventHandler(this.OnEditItemsMenuItemClick);
                        this.editItemsToolStripMenuItem.Image  = new Bitmap(typeof(ToolStripMenuItem), "editdropdownlist.bmp");
                        this.editItemsToolStripMenuItem.ImageTransparentColor = Color.Magenta;
                        base.Add(this.editItemsToolStripMenuItem);
                    }
                }
            }
        }