Inheritance: ToolStripDropDown
示例#1
0
        protected override ToolStripDropDown CreateDefaultDropDown()
        {
            ToolStripDropDownMenu tsddm = new ToolStripDropDownMenu();

            tsddm.OwnerItem = this;
            return(tsddm);
        }
        /// <devdoc> this takes a native menu and builds up a managed toolstrip around it.
        ///          Scenario: showing the items from the SystemMenu.
        ///          targetWindow is the window to send WM_COMMAND, WM_SYSCOMMAND to
        ///          hmenu is a handle to the native menu
        ///
        ///

        internal static ToolStripDropDownMenu FromHMenu(IntPtr hmenu, IWin32Window targetWindow)
        {
            ToolStripDropDownMenu managedDropDown = new ToolStripDropDownMenu();

            managedDropDown.SuspendLayout();


            HandleRef menuHandle = new HandleRef(null, hmenu);
            int       count      = UnsafeNativeMethods.GetMenuItemCount(menuHandle);

            ToolStripItem itemToAdd;

            // surf through the items in the collection, building up TSMenuItems and TSSeparators
            // corresponding to the native menu.
            for (int i = 0; i < count; i++)
            {
                // peek at the i'th item.
                NativeMethods.MENUITEMINFO_T_RW info = new NativeMethods.MENUITEMINFO_T_RW();
                info.cbSize = Marshal.SizeOf <NativeMethods.MENUITEMINFO_T_RW>();
                info.fMask  = NativeMethods.MIIM_FTYPE;
                info.fType  = NativeMethods.MIIM_FTYPE;
                UnsafeNativeMethods.GetMenuItemInfo(menuHandle, i, /*fByPosition=*/ true, info);

                if (info.fType == NativeMethods.MFT_SEPARATOR)
                {
                    // its a separator.
                    itemToAdd = new ToolStripSeparator();
                }
                else
                {
                    // its a menu item... lets fish out the command id
                    info        = new NativeMethods.MENUITEMINFO_T_RW();
                    info.cbSize = Marshal.SizeOf <NativeMethods.MENUITEMINFO_T_RW>();
                    info.fMask  = NativeMethods.MIIM_ID;
                    info.fType  = NativeMethods.MIIM_ID;
                    UnsafeNativeMethods.GetMenuItemInfo(menuHandle, i, /*fByPosition=*/ true, info);

                    // create the managed object - toolstripmenu item knows how to grok hmenu for information.
                    itemToAdd = new ToolStripMenuItem(hmenu, info.wID, targetWindow);


                    // if there is a submenu fetch it.
                    info        = new NativeMethods.MENUITEMINFO_T_RW();
                    info.cbSize = Marshal.SizeOf <NativeMethods.MENUITEMINFO_T_RW>();
                    info.fMask  = NativeMethods.MIIM_SUBMENU;
                    info.fType  = NativeMethods.MIIM_SUBMENU;
                    UnsafeNativeMethods.GetMenuItemInfo(menuHandle, i, /*fByPosition=*/ true, info);

                    if (info.hSubMenu != IntPtr.Zero)
                    {
                        // set the dropdown to be the items from the submenu
                        ((ToolStripMenuItem)itemToAdd).DropDown = FromHMenu(info.hSubMenu, targetWindow);
                    }
                }

                managedDropDown.Items.Add(itemToAdd);
            }
            managedDropDown.ResumeLayout();
            return(managedDropDown);
        }
示例#3
0
        public override Size GetPreferredSize(Size constrainingSize)
        {
            ToolStrip parentInternal = base.ParentInternal;

            if (parentInternal == null)
            {
                parentInternal = base.Owner;
            }
            if (parentInternal == null)
            {
                return(new Size(6, 6));
            }
            ToolStripDropDownMenu menu = parentInternal as ToolStripDropDownMenu;

            if (menu != null)
            {
                return(new Size(parentInternal.Width - (parentInternal.Padding.Horizontal - menu.ImageMargin.Width), 6));
            }
            if ((parentInternal.LayoutStyle != ToolStripLayoutStyle.HorizontalStackWithOverflow) || (parentInternal.LayoutStyle != ToolStripLayoutStyle.VerticalStackWithOverflow))
            {
                constrainingSize.Width  = 0x17;
                constrainingSize.Height = 0x17;
            }
            if (this.IsVertical)
            {
                return(new Size(6, constrainingSize.Height));
            }
            return(new Size(constrainingSize.Width, 6));
        }
示例#4
0
        public StatusControl(ControlWindow main)
        {
            this.main = main;
            this.SelectionMode = SelectionMode.MultiExtended;
			
            DrawMode = DrawMode.OwnerDrawFixed;

            ItemHeight = 30;
			
            dropDown = new ToolStripDropDownMenu();
            dropDown.Items.Add("Clear Disconnected").Click += HandleClearClick;
            dropDown.Items.Add("Sort").Click += HandleSortClick;
            ;
            dropDown.Items.Add("Group on top").Click += HandleTopClick;
            //dropDown.Items.Add ("History").Click += ShowHistory;
            dropDown.Items.Add("Follow").Click += FollowPlayer;
            //dropDown.Items.Add ("Tp nuxas to ").Click += TpNuxasTo;
            dropDown.Items.Add("Tp Player to ").Click += TpPlayerTo;
            dropDown.Items.Add("Pardon").Click += PardonPlayer;
            dropDown.Items.Add(new ToolStripSeparator());
            dropDown.Items.Add("Kick").Click += KickPlayer;
            dropDown.Items.Add("Ban 30 min").Click += BanPlayer30;
            dropDown.Items.Add("Ban").Click += BanPlayer;
			
        }
示例#5
0
 private void Scroll()
 {
     ToolStripDropDownMenu parentInternal = base.ParentInternal as ToolStripDropDownMenu;
     if ((parentInternal != null) && this.Label.Enabled)
     {
         parentInternal.ScrollInternal(this.up);
     }
 }
        private void Scroll()
        {
            ToolStripDropDownMenu parent = this.ParentInternal as ToolStripDropDownMenu;

            if (parent != null && Label.Enabled)
            {
                parent.ScrollInternal(up);
            }
        }
示例#7
0
 public void InitResultMenu()
 {
     m_resultMenu = new ToolStripDropDownMenu();
     m_resultMenu.Items.Add(new ToolStripMenuItem(Properties.Resources.strAddToClipboard,
         Properties.Resources.imgAddToClipboard));
     m_resultMenu.Items.Add(new ToolStripMenuItem(Properties.Resources.strAddToVarList,
         Properties.Resources.imgAddToVarList));
     m_resultMenu.Items.Add(new ToolStripMenuItem(Properties.Resources.strCancel));
     m_resultMenu.ItemClicked += new ToolStripItemClickedEventHandler(ResultMenuItem_Click);
 }
            internal override Size GetPreferredSize(IArrangedElement container, Size proposedConstraints)
            {
                Size preferredSize = base.GetPreferredSize(container, proposedConstraints);
                ToolStripDropDownMenu dropDownMenu = container as ToolStripDropDownMenu;

                if (dropDownMenu != null)
                {
                    preferredSize.Width = dropDownMenu.MaxItemSize.Width - dropDownMenu.PaddingToTrim;
                }
                return(preferredSize);
            }
示例#9
0
        protected internal override void SetBounds(Rectangle rect)
        {
            ToolStripDropDownMenu owner = base.Owner as ToolStripDropDownMenu;

            if ((owner != null) && (owner != null))
            {
                rect.X     = 2;
                rect.Width = owner.Width - 4;
            }
            base.SetBounds(rect);
        }
示例#10
0
 private void OnSystemMenuDropDownOpening(object sender, EventArgs e)
 {
     if (!system.HasDropDownItems && (target != null))
     {
         system.DropDown = ToolStripDropDownMenu.FromHMenu(UnsafeNativeMethods.GetSystemMenu(new HandleRef(this, Control.GetSafeHandle(target)), /*bRevert=*/ false), target);
     }
     else if (MergedMenu == null)
     {
         system.DropDown.Dispose();
     }
 }
 private void OnSystemMenuDropDownOpening(object sender, EventArgs e)
 {
     if (!this.system.HasDropDownItems && (this.target != null))
     {
         this.system.DropDown = ToolStripDropDownMenu.FromHMenu(System.Windows.Forms.UnsafeNativeMethods.GetSystemMenu(new HandleRef(this, Control.GetSafeHandle(this.target)), false), this.target);
     }
     else if (this.MergedMenu == null)
     {
         this.system.DropDown.Dispose();
     }
 }
示例#12
0
 private void OnSystemMenuDropDownOpening(object sender, EventArgs e)
 {
     if (!system.HasDropDownItems && (target != null))
     {
         system.DropDown = ToolStripDropDownMenu.FromHMenu(User32.GetSystemMenu(new HandleRef(this, Control.GetSafeHandle(target)), bRevert: BOOL.FALSE), target);
     }
     else if (MergedMenu is null)
     {
         system.DropDown.Dispose();
     }
 }
示例#13
0
        public CheckBoxDropDown()
            : base()
        {
            popup = new ToolStripDropDownMenu();
            popup.ShowImageMargin = false;
            //popup.TopLevel = false;
            //popup.CanOverflow = true;
            popup.AutoClose = true;
            popup.DropShadowEnabled = true;

            InitializeComponent();
        }
 public override Size GetPreferredSize(Size constrainingSize)
 {
     if (this.UseMenuLayout)
     {
         ToolStripDropDownMenu owner = this.ownerItem.Owner as ToolStripDropDownMenu;
         if (owner != null)
         {
             return(owner.MaxItemSize);
         }
     }
     return(base.GetPreferredSize(constrainingSize));
 }
示例#15
0
        private void HideContextMenuImageMargin(ToolStripDropDownMenu target)
        {
            target.ShowImageMargin = false;
            foreach (ToolStripItem menuItem in target.Items)
            {
                ToolStripMenuItem item = menuItem as ToolStripMenuItem;

                if (item != null && item.HasDropDownItems)
                {
                    ((ToolStripDropDownMenu)item.DropDown).ShowCheckMargin = true;
                    HideContextMenuImageMargin((ToolStripDropDownMenu)item.DropDown);
                }
            }
        }
示例#16
0
        internal void ShowDropDown(bool mousePush)
        {
            this.ShowDropDownInternal();
            ToolStripDropDownMenu menu = this.dropDown as ToolStripDropDownMenu;

            if (menu != null)
            {
                if (!mousePush)
                {
                    menu.ResetScrollPosition();
                }
                menu.RestoreScrollPosition();
            }
        }
        protected internal override void SetBounds(Rectangle rect)
        {
            ToolStripMenuItemInternalLayout internalLayout = base.InternalLayout as ToolStripMenuItemInternalLayout;

            if ((internalLayout != null) && internalLayout.UseMenuLayout)
            {
                ToolStripDropDownMenu owner = base.Owner as ToolStripDropDownMenu;
                if (owner != null)
                {
                    rect.X -= owner.Padding.Left;
                    rect.X  = Math.Max(rect.X, 0);
                }
            }
            base.SetBounds(rect);
        }
 public void Initialize()
 {
     if (Menu == null)
     {
         Menu = new ToolStripDropDownMenu();
         Menu.Items.AddRange(new ToolStripItem[]
         {
             Item_A1,
             Item_A2,
             Item_A3,
             Item_S1,
             Item_B1,
             Item_B2,
             Item_C1
         });
     }
 }
示例#19
0
        internal static ToolStripDropDownMenu FromHMenu(IntPtr hmenu, IWin32Window targetWindow)
        {
            ToolStripDropDownMenu menu = new ToolStripDropDownMenu();

            menu.SuspendLayout();
            HandleRef hMenu         = new HandleRef(null, hmenu);
            int       menuItemCount = System.Windows.Forms.UnsafeNativeMethods.GetMenuItemCount(hMenu);

            for (int i = 0; i < menuItemCount; i++)
            {
                ToolStripItem item;
                System.Windows.Forms.NativeMethods.MENUITEMINFO_T_RW lpmii = new System.Windows.Forms.NativeMethods.MENUITEMINFO_T_RW {
                    cbSize = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.MENUITEMINFO_T_RW)),
                    fMask  = 0x100,
                    fType  = 0x100
                };
                System.Windows.Forms.UnsafeNativeMethods.GetMenuItemInfo(hMenu, i, true, lpmii);
                if (lpmii.fType == 0x800)
                {
                    item = new ToolStripSeparator();
                }
                else
                {
                    lpmii = new System.Windows.Forms.NativeMethods.MENUITEMINFO_T_RW {
                        cbSize = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.MENUITEMINFO_T_RW)),
                        fMask  = 2,
                        fType  = 2
                    };
                    System.Windows.Forms.UnsafeNativeMethods.GetMenuItemInfo(hMenu, i, true, lpmii);
                    item  = new ToolStripMenuItem(hmenu, lpmii.wID, targetWindow);
                    lpmii = new System.Windows.Forms.NativeMethods.MENUITEMINFO_T_RW {
                        cbSize = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.MENUITEMINFO_T_RW)),
                        fMask  = 4,
                        fType  = 4
                    };
                    System.Windows.Forms.UnsafeNativeMethods.GetMenuItemInfo(hMenu, i, true, lpmii);
                    if (lpmii.hSubMenu != IntPtr.Zero)
                    {
                        ((ToolStripMenuItem)item).DropDown = FromHMenu(lpmii.hSubMenu, targetWindow);
                    }
                }
                menu.Items.Add(item);
            }
            menu.ResumeLayout();
            return(menu);
        }
示例#20
0
        internal protected override void SetBounds(Rectangle rect)
        {
            ToolStripDropDownMenu dropDownMenu = this.Owner as ToolStripDropDownMenu;

            if (dropDownMenu != null)
            {
                // Scooch over by the padding amount.  The padding is added to
                // the ToolStripDropDownMenu to keep the non-menu item riffraff
                // aligned to the text rectangle. When flow layout comes through to set our position
                // via IArrangedElement DEFY IT!
                if (dropDownMenu != null)
                {
                    rect.X     = 2;
                    rect.Width = dropDownMenu.Width - 4;
                }
            }
            base.SetBounds(rect);
        }
        public ToolStripSearchTextBox()
        {
            this.AcceptsReturn = true;
            TextBox.ShortcutsEnabled = true;
            _dropdown = new ToolStripDropDownMenu();
            _dropdown.ShowCheckMargin = false;
            _dropdown.ShowImageMargin = false;
            _dropdown.ItemClicked += new ToolStripItemClickedEventHandler(_dropdown_ItemClicked);

            _searchIcon = new PictureBox();
            _searchIcon.Size = ScaleHelper.Scale(new Size(16, 16));
            _searchIcon.Image = PluginBase.MainForm.FindImage("251");
            _searchIcon.SizeMode = PictureBoxSizeMode.StretchImage;
            _searchIcon.Cursor = Cursors.Default;
            // Clear the search textbox when the icon is clicked.
            _searchIcon.Click += new EventHandler(_searchIcon_Click);
            TextBox.Controls.Add(_searchIcon);

            // Update the icon in the search box
            TextBox.TextChanged += new EventHandler(TextBox_TextChanged);
        }
示例#22
0
        /// <include file='doc\ToolStripSeparator.uex' path='docs/doc[@for="ToolStripSeparator.GetPreferredSize"]/*' />
        public override Size GetPreferredSize(Size constrainingSize)
        {
            ToolStrip parent = this.ParentInternal;

            if (parent == null)
            {
                parent = Owner;
            }
            if (parent == null)
            {
                return(new Size(WINBAR_SEPARATORTHICKNESS, WINBAR_SEPARATORTHICKNESS));
            }

            ToolStripDropDownMenu dropDownMenu = parent as ToolStripDropDownMenu;

            if (dropDownMenu != null)
            {
                return(new Size(parent.Width - (parent.Padding.Horizontal - dropDownMenu.ImageMargin.Width), WINBAR_SEPARATORTHICKNESS));
            }
            else
            {
                if (parent.LayoutStyle != ToolStripLayoutStyle.HorizontalStackWithOverflow || parent.LayoutStyle != ToolStripLayoutStyle.VerticalStackWithOverflow)
                {
                    // we dont actually know what size to make it, so just keep it a stock size.
                    constrainingSize.Width  = WINBAR_SEPARATORHEIGHT;
                    constrainingSize.Height = WINBAR_SEPARATORHEIGHT;
                }
                if (IsVertical)
                {
                    return(new Size(WINBAR_SEPARATORTHICKNESS, constrainingSize.Height));
                }
                else
                {
                    return(new Size(constrainingSize.Width, WINBAR_SEPARATORTHICKNESS));
                }
            }
        }
 public ToolStripDropDownMenuAccessibleObject(ToolStripDropDownMenu owner) : base(owner)
 {
 }
 internal static ToolStripDropDownMenu FromHMenu(IntPtr hmenu, IWin32Window targetWindow)
 {
     ToolStripDropDownMenu menu = new ToolStripDropDownMenu();
     menu.SuspendLayout();
     HandleRef hMenu = new HandleRef(null, hmenu);
     int menuItemCount = System.Windows.Forms.UnsafeNativeMethods.GetMenuItemCount(hMenu);
     for (int i = 0; i < menuItemCount; i++)
     {
         ToolStripItem item;
         System.Windows.Forms.NativeMethods.MENUITEMINFO_T_RW lpmii = new System.Windows.Forms.NativeMethods.MENUITEMINFO_T_RW {
             cbSize = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.MENUITEMINFO_T_RW)),
             fMask = 0x100,
             fType = 0x100
         };
         System.Windows.Forms.UnsafeNativeMethods.GetMenuItemInfo(hMenu, i, true, lpmii);
         if (lpmii.fType == 0x800)
         {
             item = new ToolStripSeparator();
         }
         else
         {
             lpmii = new System.Windows.Forms.NativeMethods.MENUITEMINFO_T_RW {
                 cbSize = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.MENUITEMINFO_T_RW)),
                 fMask = 2,
                 fType = 2
             };
             System.Windows.Forms.UnsafeNativeMethods.GetMenuItemInfo(hMenu, i, true, lpmii);
             item = new ToolStripMenuItem(hmenu, lpmii.wID, targetWindow);
             lpmii = new System.Windows.Forms.NativeMethods.MENUITEMINFO_T_RW {
                 cbSize = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.MENUITEMINFO_T_RW)),
                 fMask = 4,
                 fType = 4
             };
             System.Windows.Forms.UnsafeNativeMethods.GetMenuItemInfo(hMenu, i, true, lpmii);
             if (lpmii.hSubMenu != IntPtr.Zero)
             {
                 ((ToolStripMenuItem) item).DropDown = FromHMenu(lpmii.hSubMenu, targetWindow);
             }
         }
         menu.Items.Add(item);
     }
     menu.ResumeLayout();
     return menu;
 }
示例#25
0
        private void ShowPopupMenu(int x, int y)
        {
            ToolStripDropDownMenu popupMenu = new ToolStripDropDownMenu();

            ToolStripMenuItem copyItem = new ToolStripMenuItem(Messages.COPY);
#if !VNCControl
            copyItem.Image = XenAdmin.Properties.Resources.copy_16;
#endif
            copyItem.Click += copyItem_Click;
            popupMenu.Items.Add(copyItem);
            if (sourceVM != null && sourceVM.power_state == XenAPI.vm_power_state.Running)
            {
                ToolStripMenuItem pasteItem = new ToolStripMenuItem(Messages.PASTE);
#if !VNCControl
                pasteItem.Image = XenAdmin.Properties.Resources.paste_16;
#endif
                pasteItem.Click += pasteItem_Click;

                popupMenu.Items.Add(pasteItem);
            }
            popupMenu.Show(this, x, y);
        }
		private ContextMenuStrip CreateContextMenu()
		{
			var contextMenuStrip = new ContextMenuStrip();

			IEnumerable<ICmPossibility> existingRoles = Record.Roles;
			foreach (ICmPossibility role in m_cache.LanguageProject.RolesOA.PossibilitiesOS)
			{
				// only display add menu options for roles that have not been added yet
				if (!existingRoles.Contains(role))
				{
					string label = string.Format(LexEdStrings.ksAddParticipants, role.Name.BestAnalysisAlternative.Text);
					var item = new ToolStripMenuItem(label, null, AddParticipants) {Tag = role};
					contextMenuStrip.Items.Add(item);
				}
			}

			// display the standard visiblility and help menu items
			var tsdropdown = new ToolStripDropDownMenu();
			var itemAlways = new ToolStripMenuItem(LexEdStrings.ksAlwaysVisible, null, ShowFieldAlwaysVisible);
			var itemIfData = new ToolStripMenuItem(LexEdStrings.ksHiddenUnlessData, null, ShowFieldIfData);
			var itemHidden = new ToolStripMenuItem(LexEdStrings.ksNormallyHidden, null, ShowFieldNormallyHidden);
			itemAlways.CheckOnClick = true;
			itemIfData.CheckOnClick = true;
			itemHidden.CheckOnClick = true;
			itemAlways.Checked = IsVisibilityItemChecked("always");
			itemIfData.Checked = IsVisibilityItemChecked("ifdata");
			itemHidden.Checked = IsVisibilityItemChecked("never");

			tsdropdown.Items.Add(itemAlways);
			tsdropdown.Items.Add(itemIfData);
			tsdropdown.Items.Add(itemHidden);
			var fieldVis = new ToolStripMenuItem(LexEdStrings.ksFieldVisibility) {DropDown = tsdropdown};

			contextMenuStrip.Items.Add(new ToolStripSeparator());
			contextMenuStrip.Items.Add(fieldVis);
			Image imgHelp = ContainingDataTree.SmallImages.GetImage("Help");
			contextMenuStrip.Items.Add(new ToolStripMenuItem(LexEdStrings.ksHelp, imgHelp, ShowHelpTopic));

			return contextMenuStrip;
		}
 private ToolStripDropDownMenu BuildMenu(bool isRow)
 {
     ToolStripMenuItem item = new ToolStripMenuItem();
     ToolStripMenuItem item2 = new ToolStripMenuItem();
     ToolStripMenuItem item3 = new ToolStripMenuItem();
     ToolStripSeparator separator = new ToolStripSeparator();
     ToolStripLabel label = new ToolStripLabel();
     ToolStripMenuItem item4 = new ToolStripMenuItem();
     ToolStripMenuItem item5 = new ToolStripMenuItem();
     ToolStripMenuItem item6 = new ToolStripMenuItem();
     item.Text = System.Design.SR.GetString("TableLayoutPanelDesignerAddMenu");
     item.Tag = isRow;
     item.Name = "add";
     item.Click += new EventHandler(this.OnAddClick);
     item2.Text = System.Design.SR.GetString("TableLayoutPanelDesignerInsertMenu");
     item2.Tag = isRow;
     item2.Name = "insert";
     item2.Click += new EventHandler(this.OnInsertClick);
     item3.Text = System.Design.SR.GetString("TableLayoutPanelDesignerDeleteMenu");
     item3.Tag = isRow;
     item3.Name = "delete";
     item3.Click += new EventHandler(this.OnDeleteClick);
     label.Text = System.Design.SR.GetString("TableLayoutPanelDesignerLabelMenu");
     if (System.Design.SR.GetString("TableLayoutPanelDesignerDontBoldLabel") == "0")
     {
         label.Font = new Font(label.Font, FontStyle.Bold);
     }
     label.Name = "sizemode";
     item4.Text = System.Design.SR.GetString("TableLayoutPanelDesignerAbsoluteMenu");
     item4.Tag = isRow;
     item4.Name = "absolute";
     item4.Click += new EventHandler(this.OnAbsoluteClick);
     item5.Text = System.Design.SR.GetString("TableLayoutPanelDesignerPercentageMenu");
     item5.Tag = isRow;
     item5.Name = "percent";
     item5.Click += new EventHandler(this.OnPercentClick);
     item6.Text = System.Design.SR.GetString("TableLayoutPanelDesignerAutoSizeMenu");
     item6.Tag = isRow;
     item6.Name = "autosize";
     item6.Click += new EventHandler(this.OnAutoSizeClick);
     ToolStripDropDownMenu menu = new ToolStripDropDownMenu();
     menu.Items.AddRange(new ToolStripItem[] { item, item2, item3, separator, label, item4, item5, item6 });
     menu.Tag = isRow;
     menu.Opening += new CancelEventHandler(this.OnRowColMenuOpening);
     IUIService service = this.GetService(typeof(IUIService)) as IUIService;
     if (service != null)
     {
         menu.Renderer = (ToolStripProfessionalRenderer) service.Styles["VsRenderer"];
     }
     return menu;
 }
示例#28
0
        public static ToolStripItem[] RecentMenu(this RecentFiles recent, Action<string> loadFileCallback, bool autoload = false)
        {
            var items = new List<ToolStripItem>();

            if (recent.Empty)
            {
                var none = new ToolStripMenuItem { Enabled = false, Text = "None" };
                items.Add(none);
            }
            else
            {
                foreach (var filename in recent)
                {
                    //TODO - do TSMI and TSDD need disposing? yuck
                    var temp = filename;
                    var item = new ToolStripMenuItem { Text = temp };
                    items.Add(item);

                    item.Click += (o, ev) =>
                    {
                        loadFileCallback(temp);
                    };

                    //TODO - use standard methods to split filename (hawkfile acquire?)
                    var hf = new HawkFile();
                    hf.Parse(temp);
                    bool canExplore = true;
                    if (!File.Exists(hf.FullPathWithoutMember))
                        canExplore = false;

                    var tsdd = new ToolStripDropDownMenu();

                    if (canExplore)
                    {
                        //make a menuitem to show the last modified timestamp
                        var timestamp = File.GetLastWriteTime(hf.FullPathWithoutMember);
                        var tsmiTimestamp = new ToolStripLabel { Text = timestamp.ToString() };

                        tsdd.Items.Add(tsmiTimestamp);
                        tsdd.Items.Add(new ToolStripSeparator());

                        if (hf.IsArchive)
                        {
                            //make a menuitem to let you copy the path
                            var tsmiCopyCanonicalPath = new ToolStripMenuItem { Text = "&Copy Canonical Path" };
                            tsmiCopyCanonicalPath.Click += (o, ev) => { System.Windows.Forms.Clipboard.SetText(temp); };
                            tsdd.Items.Add(tsmiCopyCanonicalPath);

                            var tsmiCopyArchivePath = new ToolStripMenuItem { Text = "Copy Archive Path" };
                            tsmiCopyArchivePath.Click += (o, ev) => { System.Windows.Forms.Clipboard.SetText(hf.FullPathWithoutMember); };
                            tsdd.Items.Add(tsmiCopyArchivePath);

                            var tsmiOpenArchive = new ToolStripMenuItem { Text = "Open &Archive" };
                            tsmiOpenArchive.Click += (o, ev) => { System.Diagnostics.Process.Start(hf.FullPathWithoutMember); };
                            tsdd.Items.Add(tsmiOpenArchive);
                        }
                        else
                        {
                            //make a menuitem to let you copy the path
                            var tsmiCopyPath = new ToolStripMenuItem { Text = "&Copy Path" };
                            tsmiCopyPath.Click += (o, ev) => { System.Windows.Forms.Clipboard.SetText(temp); };
                            tsdd.Items.Add(tsmiCopyPath);
                        }

                        tsdd.Items.Add(new ToolStripSeparator());

                        //make a menuitem to let you explore to it
                        var tsmiExplore = new ToolStripMenuItem { Text = "&Explore" };
                        string explorePath = "\"" + hf.FullPathWithoutMember + "\"";
                        tsmiExplore.Click += (o, ev) => { System.Diagnostics.Process.Start("explorer.exe", "/select, " + explorePath); };
                        tsdd.Items.Add(tsmiExplore);

                        var tsmiCopyFile = new ToolStripMenuItem { Text = "Copy &File" };
                        var lame = new System.Collections.Specialized.StringCollection();
                        lame.Add(hf.FullPathWithoutMember);
                        tsmiCopyFile.Click += (o, ev) => { System.Windows.Forms.Clipboard.SetFileDropList(lame); };
                        tsdd.Items.Add(tsmiCopyFile);

                        var tsmiTest = new ToolStripMenuItem { Text = "&Shell Context Menu" };
                        tsmiTest.Click += (o, ev) => {
                            var si = new GongSolutions.Shell.ShellItem(hf.FullPathWithoutMember);
                            var scm = new GongSolutions.Shell.ShellContextMenu(si);
                            var tsddi = o as ToolStripDropDownItem;
                            tsddi.Owner.Update();
                            scm.ShowContextMenu(tsddi.Owner, new System.Drawing.Point(0, 0));
                        };
                        tsdd.Items.Add(tsmiTest);

                        tsdd.Items.Add(new ToolStripSeparator());
                    }
                    else
                    {
                        //make a menuitem to show the last modified timestamp
                        var tsmiMissingFile = new ToolStripLabel { Text = "-Missing-" };
                        tsdd.Items.Add(tsmiMissingFile);
                        tsdd.Items.Add(new ToolStripSeparator());
                    }

                    //in either case, make a menuitem to let you remove the path
                    var tsmiRemovePath = new ToolStripMenuItem { Text = "&Remove" };
                    tsmiRemovePath.Click += (o, ev) => { recent.Remove(temp); };

                    tsdd.Items.Add(tsmiRemovePath);

                    ////experiment of popping open a submenu. doesnt work well.
                    //item.MouseDown += (o, mev) =>
                    //{
                    //  if (mev.Button != MouseButtons.Right) return;
                    //  //location of the menu containing this item that was just rightclicked
                    //  var pos = item.Owner.Bounds.Location;
                    //  //the offset within that menu of this item
                    //  var tsddi = item as ToolStripDropDownItem;
                    //  pos.Offset(tsddi.Bounds.Location);
                    //  //the offset of the click
                    //  pos.Offset(mev.Location);
                    //	//tsdd.OwnerItem = item; //has interesting promise, but breaks things otherwise
                    //  tsdd.Show(pos);
                    //};

                    //just add it to the submenu for now
                    item.MouseDown += (o, mev) =>
                    {
                        if (mev.Button != MouseButtons.Right) return;
                        if (item.DropDown != null)
                            item.DropDown = tsdd;
                        item.ShowDropDown();
                    };
                }
            }

            items.Add(new ToolStripSeparator());

            var clearitem = new ToolStripMenuItem { Text = "&Clear", Enabled = !recent.Frozen };
            clearitem.Click += (o, ev) => recent.Clear();
            items.Add(clearitem);

            var freezeitem = new ToolStripMenuItem { Text = recent.Frozen ? "&Unfreeze" : "&Freeze" };
            freezeitem.Click += (o, ev) => recent.Frozen ^= true;
            items.Add(freezeitem);

            if (autoload)
            {
                var auto = new ToolStripMenuItem { Text = "&Autoload", Checked = recent.AutoLoad };
                auto.Click += (o, ev) => recent.ToggleAutoLoad();
                items.Add(auto);
            }

            var settingsitem = new ToolStripMenuItem { Text = "&Recent Settings..." };
            settingsitem.Click += (o, ev) =>
            {
                using (var prompt = new InputPrompt
                {
                    TextInputType = InputPrompt.InputType.Unsigned,
                    Message = "Number of recent files to track",
                    InitialValue = recent.MAX_RECENT_FILES.ToString()
                })
                {
                    var result = prompt.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        int val = int.Parse(prompt.PromptText);
                        if (val > 0)
                            recent.MAX_RECENT_FILES = val;
                    }
                }
            };
            items.Add(settingsitem);

            return items.ToArray();
        }
示例#29
0
        public void OnDropDownOpening(ToolStripDropDownMenu menu) {
            // Called the dropdown menu is about to open.
            // No need to call "menu.SuspendLayout" or "menu.ResumeLayout".

            if(fFirstMenuDropDown) {
                menu.Items.Add(new ToolStripMenuItem("Open folder"));
                menu.Items.Add(new ToolStripMenuItem("Test selection"));

                fFirstMenuDropDown = false;
            }
        }
示例#30
0
            /// <devdoc> this takes a native menu and builds up a managed toolstrip around it.
            ///          Scenario: showing the items from the SystemMenu.
            ///          targetWindow is the window to send WM_COMMAND, WM_SYSCOMMAND to
            ///          hmenu is a handle to the native menu
            ///
            ///  

            internal static ToolStripDropDownMenu FromHMenu(IntPtr hmenu, IWin32Window targetWindow) {
                ToolStripDropDownMenu managedDropDown = new ToolStripDropDownMenu();
                managedDropDown.SuspendLayout();
             

                HandleRef menuHandle = new HandleRef(null, hmenu);
                int count = UnsafeNativeMethods.GetMenuItemCount(menuHandle);

                ToolStripItem itemToAdd;

                // surf through the items in the collection, building up TSMenuItems and TSSeparators
                // corresponding to the native menu.
                for (int i = 0; i < count; i++) {
                    // peek at the i'th item.
                    NativeMethods.MENUITEMINFO_T_RW info = new NativeMethods.MENUITEMINFO_T_RW();
                    info.cbSize = Marshal.SizeOf(typeof(NativeMethods.MENUITEMINFO_T_RW));
                    info.fMask = NativeMethods.MIIM_FTYPE;
                    info.fType = NativeMethods.MIIM_FTYPE;
                    UnsafeNativeMethods.GetMenuItemInfo(menuHandle, i, /*fByPosition=*/ true, info);
                    
                    if (info.fType == NativeMethods.MFT_SEPARATOR){
                        // its a separator.
                    	itemToAdd = new ToolStripSeparator();
                    }
                    else {
                        // its a menu item... lets fish out the command id
                     	info = new NativeMethods.MENUITEMINFO_T_RW();
                    	info.cbSize = Marshal.SizeOf(typeof(NativeMethods.MENUITEMINFO_T_RW));
                    	info.fMask = NativeMethods.MIIM_ID;
                    	info.fType = NativeMethods.MIIM_ID;
                    	UnsafeNativeMethods.GetMenuItemInfo(menuHandle, i, /*fByPosition=*/ true, info);

                        // create the managed object - toolstripmenu item knows how to grok hmenu for information.
                    	itemToAdd = new ToolStripMenuItem(hmenu, info.wID, targetWindow);


                    	// if there is a submenu fetch it.
                    	info = new NativeMethods.MENUITEMINFO_T_RW();
                    	info.cbSize = Marshal.SizeOf(typeof(NativeMethods.MENUITEMINFO_T_RW));
                    	info.fMask = NativeMethods.MIIM_SUBMENU;
                    	info.fType = NativeMethods.MIIM_SUBMENU;
                    	UnsafeNativeMethods.GetMenuItemInfo(menuHandle, i, /*fByPosition=*/ true, info);

                    	if (info.hSubMenu != IntPtr.Zero) {
                    	    // set the dropdown to be the items from the submenu
                    		((ToolStripMenuItem)itemToAdd).DropDown = FromHMenu(info.hSubMenu, targetWindow);
                    	}
                    }

                    managedDropDown.Items.Add(itemToAdd);
                }
                managedDropDown.ResumeLayout();
                return managedDropDown;
            }
示例#31
0
		private void AddFinalContextMenuStripOptions(System.Windows.Forms.ContextMenuStrip contextMenuStrip)
		{
			contextMenuStrip.Items.Add(new ToolStripSeparator());
			contextMenuStrip.Items.Add(new ToolStripMenuItem(LexEdStrings.ksCreateLexRefType_, null, new EventHandler(this.HandleMoreMenuItem)));

			ToolStripDropDownMenu tsdropdown = new ToolStripDropDownMenu();
			ToolStripMenuItem itemAlways = new ToolStripMenuItem(LexEdStrings.ksAlwaysVisible, null, new EventHandler(this.OnShowFieldAlwaysVisible1));
			ToolStripMenuItem itemIfData = new ToolStripMenuItem(LexEdStrings.ksHiddenUnlessData, null, new EventHandler(this.OnShowFieldIfData1));
			ToolStripMenuItem itemHidden = new ToolStripMenuItem(LexEdStrings.ksNormallyHidden, null, new EventHandler(this.OnShowFieldNormallyHidden1));
			itemAlways.CheckOnClick = true;
			itemIfData.CheckOnClick = true;
			itemHidden.CheckOnClick = true;
			itemAlways.Checked = IsVisibilityItemChecked("always");
			itemIfData.Checked = IsVisibilityItemChecked("ifdata");
			itemHidden.Checked = IsVisibilityItemChecked("never");

			tsdropdown.Items.Add(itemAlways);
			tsdropdown.Items.Add(itemIfData);
			tsdropdown.Items.Add(itemHidden);
			ToolStripMenuItem fieldVis = new ToolStripMenuItem(LexEdStrings.ksFieldVisibility);
			fieldVis.DropDown = tsdropdown;

			contextMenuStrip.Items.Add(new ToolStripSeparator());
			contextMenuStrip.Items.Add(fieldVis);
			Image imgHelp = ContainingDataTree.SmallImages.GetImage("Help");
			contextMenuStrip.Items.Add(new ToolStripMenuItem(LexEdStrings.ksHelp, imgHelp, new EventHandler(this.OnHelp)));
		}
        private void InitForm()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(PrintPreviewDialog));

            this.toolStrip1                   = new ToolStrip();
            this.printToolStripButton         = new ToolStripButton();
            this.zoomToolStripSplitButton     = new ToolStripSplitButton();
            this.autoToolStripMenuItem        = new ToolStripMenuItem();
            this.toolStripMenuItem1           = new ToolStripMenuItem();
            this.toolStripMenuItem2           = new ToolStripMenuItem();
            this.toolStripMenuItem3           = new ToolStripMenuItem();
            this.toolStripMenuItem4           = new ToolStripMenuItem();
            this.toolStripMenuItem5           = new ToolStripMenuItem();
            this.toolStripMenuItem6           = new ToolStripMenuItem();
            this.toolStripMenuItem7           = new ToolStripMenuItem();
            this.toolStripMenuItem8           = new ToolStripMenuItem();
            this.separatorToolStripSeparator  = new ToolStripSeparator();
            this.onepageToolStripButton       = new ToolStripButton();
            this.twopagesToolStripButton      = new ToolStripButton();
            this.threepagesToolStripButton    = new ToolStripButton();
            this.fourpagesToolStripButton     = new ToolStripButton();
            this.sixpagesToolStripButton      = new ToolStripButton();
            this.separatorToolStripSeparator1 = new ToolStripSeparator();
            this.closeToolStripButton         = new ToolStripButton();
            this.pageCounter                  = new NumericUpDown();
            this.pageToolStripLabel           = new ToolStripLabel();
            this.toolStrip1.SuspendLayout();
            this.pageCounter.BeginInit();
            base.SuspendLayout();
            manager.ApplyResources(this.toolStrip1, "toolStrip1");
            this.toolStrip1.Items.AddRange(new ToolStripItem[] { this.printToolStripButton, this.zoomToolStripSplitButton, this.separatorToolStripSeparator, this.onepageToolStripButton, this.twopagesToolStripButton, this.threepagesToolStripButton, this.fourpagesToolStripButton, this.sixpagesToolStripButton, this.separatorToolStripSeparator1, this.closeToolStripButton });
            this.toolStrip1.Name                   = "toolStrip1";
            this.toolStrip1.RenderMode             = ToolStripRenderMode.System;
            this.toolStrip1.GripStyle              = ToolStripGripStyle.Hidden;
            this.printToolStripButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
            this.printToolStripButton.Name         = "printToolStripButton";
            manager.ApplyResources(this.printToolStripButton, "printToolStripButton");
            this.zoomToolStripSplitButton.DisplayStyle       = ToolStripItemDisplayStyle.Image;
            this.zoomToolStripSplitButton.DoubleClickEnabled = true;
            this.zoomToolStripSplitButton.DropDownItems.AddRange(new ToolStripItem[] { this.autoToolStripMenuItem, this.toolStripMenuItem1, this.toolStripMenuItem2, this.toolStripMenuItem3, this.toolStripMenuItem4, this.toolStripMenuItem5, this.toolStripMenuItem6, this.toolStripMenuItem7, this.toolStripMenuItem8 });
            this.zoomToolStripSplitButton.Name          = "zoomToolStripSplitButton";
            this.zoomToolStripSplitButton.SplitterWidth = 1;
            manager.ApplyResources(this.zoomToolStripSplitButton, "zoomToolStripSplitButton");
            this.autoToolStripMenuItem.CheckOnClick       = true;
            this.autoToolStripMenuItem.DoubleClickEnabled = true;
            this.autoToolStripMenuItem.Checked            = true;
            this.autoToolStripMenuItem.Name = "autoToolStripMenuItem";
            manager.ApplyResources(this.autoToolStripMenuItem, "autoToolStripMenuItem");
            this.toolStripMenuItem1.CheckOnClick       = true;
            this.toolStripMenuItem1.DoubleClickEnabled = true;
            this.toolStripMenuItem1.Name = "toolStripMenuItem1";
            manager.ApplyResources(this.toolStripMenuItem1, "toolStripMenuItem1");
            this.toolStripMenuItem2.CheckOnClick       = true;
            this.toolStripMenuItem2.DoubleClickEnabled = true;
            this.toolStripMenuItem2.Name = "toolStripMenuItem2";
            manager.ApplyResources(this.toolStripMenuItem2, "toolStripMenuItem2");
            this.toolStripMenuItem3.CheckOnClick       = true;
            this.toolStripMenuItem3.DoubleClickEnabled = true;
            this.toolStripMenuItem3.Name = "toolStripMenuItem3";
            manager.ApplyResources(this.toolStripMenuItem3, "toolStripMenuItem3");
            this.toolStripMenuItem4.CheckOnClick       = true;
            this.toolStripMenuItem4.DoubleClickEnabled = true;
            this.toolStripMenuItem4.Name = "toolStripMenuItem4";
            manager.ApplyResources(this.toolStripMenuItem4, "toolStripMenuItem4");
            this.toolStripMenuItem5.CheckOnClick       = true;
            this.toolStripMenuItem5.DoubleClickEnabled = true;
            this.toolStripMenuItem5.Name = "toolStripMenuItem5";
            manager.ApplyResources(this.toolStripMenuItem5, "toolStripMenuItem5");
            this.toolStripMenuItem6.CheckOnClick       = true;
            this.toolStripMenuItem6.DoubleClickEnabled = true;
            this.toolStripMenuItem6.Name = "toolStripMenuItem6";
            manager.ApplyResources(this.toolStripMenuItem6, "toolStripMenuItem6");
            this.toolStripMenuItem7.CheckOnClick       = true;
            this.toolStripMenuItem7.DoubleClickEnabled = true;
            this.toolStripMenuItem7.Name = "toolStripMenuItem7";
            manager.ApplyResources(this.toolStripMenuItem7, "toolStripMenuItem7");
            this.toolStripMenuItem8.CheckOnClick       = true;
            this.toolStripMenuItem8.DoubleClickEnabled = true;
            this.toolStripMenuItem8.Name = "toolStripMenuItem8";
            manager.ApplyResources(this.toolStripMenuItem8, "toolStripMenuItem8");
            this.separatorToolStripSeparator.Name    = "separatorToolStripSeparator";
            this.onepageToolStripButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
            this.onepageToolStripButton.Name         = "onepageToolStripButton";
            manager.ApplyResources(this.onepageToolStripButton, "onepageToolStripButton");
            this.twopagesToolStripButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
            this.twopagesToolStripButton.Name         = "twopagesToolStripButton";
            manager.ApplyResources(this.twopagesToolStripButton, "twopagesToolStripButton");
            this.threepagesToolStripButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
            this.threepagesToolStripButton.Name         = "threepagesToolStripButton";
            manager.ApplyResources(this.threepagesToolStripButton, "threepagesToolStripButton");
            this.fourpagesToolStripButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
            this.fourpagesToolStripButton.Name         = "fourpagesToolStripButton";
            manager.ApplyResources(this.fourpagesToolStripButton, "fourpagesToolStripButton");
            this.sixpagesToolStripButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
            this.sixpagesToolStripButton.Name         = "sixpagesToolStripButton";
            manager.ApplyResources(this.sixpagesToolStripButton, "sixpagesToolStripButton");
            this.separatorToolStripSeparator1.Name = "separatorToolStripSeparator1";
            this.closeToolStripButton.DisplayStyle = ToolStripItemDisplayStyle.Text;
            this.closeToolStripButton.Name         = "closeToolStripButton";
            manager.ApplyResources(this.closeToolStripButton, "closeToolStripButton");
            manager.ApplyResources(this.pageCounter, "pageCounter");
            this.pageCounter.Text             = "1";
            this.pageCounter.TextAlign        = HorizontalAlignment.Right;
            this.pageCounter.DecimalPlaces    = 0;
            this.pageCounter.Minimum          = 0M;
            this.pageCounter.Maximum          = 1000M;
            this.pageCounter.ValueChanged    += new EventHandler(this.UpdownMove);
            this.pageCounter.Name             = "pageCounter";
            this.pageToolStripLabel.Alignment = ToolStripItemAlignment.Right;
            this.pageToolStripLabel.Name      = "pageToolStripLabel";
            manager.ApplyResources(this.pageToolStripLabel, "pageToolStripLabel");
            this.previewControl.Size                  = new System.Drawing.Size(0x318, 610);
            this.previewControl.Location              = new Point(0, 0x2b);
            this.previewControl.Dock                  = DockStyle.Fill;
            this.previewControl.StartPageChanged     += new EventHandler(this.previewControl_StartPageChanged);
            this.printToolStripButton.Click          += new EventHandler(this.OnprintToolStripButtonClick);
            this.autoToolStripMenuItem.Click         += new EventHandler(this.ZoomAuto);
            this.toolStripMenuItem1.Click            += new EventHandler(this.Zoom500);
            this.toolStripMenuItem2.Click            += new EventHandler(this.Zoom250);
            this.toolStripMenuItem3.Click            += new EventHandler(this.Zoom150);
            this.toolStripMenuItem4.Click            += new EventHandler(this.Zoom100);
            this.toolStripMenuItem5.Click            += new EventHandler(this.Zoom75);
            this.toolStripMenuItem6.Click            += new EventHandler(this.Zoom50);
            this.toolStripMenuItem7.Click            += new EventHandler(this.Zoom25);
            this.toolStripMenuItem8.Click            += new EventHandler(this.Zoom10);
            this.onepageToolStripButton.Click        += new EventHandler(this.OnonepageToolStripButtonClick);
            this.twopagesToolStripButton.Click       += new EventHandler(this.OntwopagesToolStripButtonClick);
            this.threepagesToolStripButton.Click     += new EventHandler(this.OnthreepagesToolStripButtonClick);
            this.fourpagesToolStripButton.Click      += new EventHandler(this.OnfourpagesToolStripButtonClick);
            this.sixpagesToolStripButton.Click       += new EventHandler(this.OnsixpagesToolStripButtonClick);
            this.closeToolStripButton.Click          += new EventHandler(this.OncloseToolStripButtonClick);
            this.closeToolStripButton.Paint          += new PaintEventHandler(this.OncloseToolStripButtonPaint);
            this.toolStrip1.ImageList                 = this.imageList;
            this.printToolStripButton.ImageIndex      = 0;
            this.zoomToolStripSplitButton.ImageIndex  = 1;
            this.onepageToolStripButton.ImageIndex    = 2;
            this.twopagesToolStripButton.ImageIndex   = 3;
            this.threepagesToolStripButton.ImageIndex = 4;
            this.fourpagesToolStripButton.ImageIndex  = 5;
            this.sixpagesToolStripButton.ImageIndex   = 6;
            this.previewControl.TabIndex              = 0;
            this.toolStrip1.TabIndex                  = 1;
            this.zoomToolStripSplitButton.DefaultItem = this.autoToolStripMenuItem;
            ToolStripDropDownMenu dropDown = this.zoomToolStripSplitButton.DropDown as ToolStripDropDownMenu;

            if (dropDown != null)
            {
                dropDown.ShowCheckMargin = true;
                dropDown.ShowImageMargin = false;
                dropDown.RenderMode      = ToolStripRenderMode.System;
            }
            ToolStripControlHost host = new ToolStripControlHost(this.pageCounter)
            {
                Alignment = ToolStripItemAlignment.Right
            };

            this.toolStrip1.Items.Add(host);
            this.toolStrip1.Items.Add(this.pageToolStripLabel);
            manager.ApplyResources(this, "$this");
            base.Controls.Add(this.previewControl);
            base.Controls.Add(this.toolStrip1);
            base.ClientSize    = new System.Drawing.Size(400, 300);
            this.MinimizeBox   = false;
            this.ShowInTaskbar = false;
            this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
            this.toolStrip1.ResumeLayout(false);
            this.pageCounter.EndInit();
            base.ResumeLayout(false);
            base.PerformLayout();
        }
示例#33
0
 private void ApplyMultiLangueToDDMenu(ToolStripDropDownMenu dropDMenu)
 {
     // Set global langage for menu
     foreach (ToolStripItem menu in dropDMenu.Items)
     {
         menu.Text = Globalisation.GetString(menu.Text.ToString());
         if (menu is ToolStripMenuItem)
         {
             ToolStripMenuItem m = (ToolStripMenuItem)menu;
             if (m.DropDownItems.Count > 0)
             {
                 foreach (ToolStripItem tsi in m.DropDownItems)
                 {
                     tsi.Text = Globalisation.GetString(tsi.Text);
                 }
             }
         }
     }
 }
示例#34
0
        public void OnDropDownOpening(ToolStripDropDownMenu menu) {
            if(menu.Items.Count != this.dicPresets.Count + 4) {
                menu.Items.Clear();
                menu.ShowImageMargin = false;

                //7,12,13,14,presets

                menu.Items.Add(this.ResStrs[7]);
                menu.Items.Add(this.ResStrs[12]);
                menu.Items.Add(this.ResStrs[13]);
                menu.Items.Add(this.ResStrs[14]);
                menu.Items.Add("Tile");

                foreach(string name in this.dicPresets.Keys) {
                    ToolStripMenuItem tsmi = new ToolStripMenuItem(name);
                    tsmi.Tag = true;
                    menu.Items.Add(tsmi);
                }
            }
        }
示例#35
0
        public void TestBindingToToolStripDropDownMenu()
        {
            ToolStripDropDownMenu control = new ToolStripDropDownMenu();
            IBusinessObject obj = new BusinessObject();

            using(BindingScope scope = new BindingScope())
            {
                IBusinessObject bindableSource = scope.CreateSource(obj);

                if(control is Control)
                    ((Control)control).CreateControl();
                control.BindingContext = new BindingContext();

                ToolStripDropDownMenu bindableTarget = scope.CreateTarget(control);

            }
        }
示例#36
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates one of three different types of drop-down toolbar items.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private ToolStripItem CreateDropDownToolBarItem(XmlNode node, int type)
		{
			ToolStripItem item;

			// True if the drop-down button is split into two segments, one for the arrow and
			// one for the icon. False if there is no behavioral distinction between the arrow
			// and icon portions of the button.
			bool split = GetBoolFromAttribute(node, "split", true);

			if (split)
			{
				item = ToolStripItemExtender.CreateSplitButton();
				((ToolStripSplitButton)item).ButtonClick += HandleItemClicks;
				((ToolStripSplitButton)item).DropDown.Closed += HandleToolBarItemDropDownClosed;

				if (type == 3)
					((ToolStripSplitButton)item).DropDownOpening += HandleToolBarItemDropDownOpened;
				else
					((ToolStripSplitButton)item).DropDownOpened += HandleToolBarItemDropDownOpened;
			}
			else
			{
				item = ToolStripItemExtender.CreateDropDownButton();
				((ToolStripDropDownButton)item).DropDown.Opened += HandleToolBarItemDropDownOpened;
				((ToolStripDropDownButton)item).DropDown.Closed += HandleToolBarItemDropDownClosed;
			}

			switch (type)
			{
				case 1:
					// Create a drop-down that will act like a drop-down toolbar.
					ToolStripDropDown dropDown = new ToolStripDropDown();
					dropDown.LayoutStyle = ToolStripLayoutStyle.StackWithOverflow;
					((ToolStripDropDownItem)item).DropDown = dropDown;
					break;

				case 2:
					// Create a drop-down that will act like a drop-down menu.
					ToolStripDropDownMenu dropDownMenu = new ToolStripDropDownMenu();
					dropDownMenu.ShowImageMargin = GetBoolFromAttribute(node, "showimagemargin", true);
					dropDownMenu.ShowCheckMargin = GetBoolFromAttribute(node, "showcheckmargin", false);
					((ToolStripDropDownItem)item).DropDown = dropDownMenu;
					break;

				case 3:
					// Create a drop-down for a custom control.
					CustomDropDown cdd = new CustomDropDown();
					cdd.AutoCloseWhenMouseLeaves = false;
					((ToolStripDropDownItem)item).DropDown = cdd;
					break;
			}

			item.DisplayStyle = ToolStripItemDisplayStyle.Image;
			return item;
		}
		protected override ToolStripDropDown CreateDefaultDropDown ()
		{
			ToolStripDropDownMenu tsdd = new ToolStripDropDownMenu ();
			tsdd.OwnerItem = this;
			return tsdd;
		}