private void viewMenuItem_DropDown_Closing(object sender, ToolStripDropDownClosingEventArgs e) { if (e.CloseReason != ToolStripDropDownCloseReason.ItemClicked) { return; } ToolStripDropDownMenu menu = sender as ToolStripDropDownMenu; ToolStripItem viewItem = menu != null?menu.GetItemAt(menu.PointToClient(Cursor.Position)) : null; if (viewItem == null) { return; } IMenuModelItem modelItem = this.GetModelItem(viewItem); if (modelItem == null) { return; } if (modelItem.Checkable) { e.Cancel = true; } }
//--------------------------------------------------------------------- private void txt_OnSelectedObjectChanged(object sender, EventArgs args) { if (OnSelectObject != null) { OnSelectObject(this, new CObjetDonneeEventArgs(TextBoxSelection.SelectedObject)); if (AutoClose) { try { ToolStripItem parent = OwnerItem; while (parent != null && parent.OwnerItem != null) { parent = parent.OwnerItem; } ToolStripDropDownMenu menu = parent != null ?parent.Owner as ToolStripDropDownMenu:null; if (menu == null) { menu = Owner as ToolStripDropDownMenu; } if (menu != null) { menu.Close(); } } catch { } } } }
/// <summary> /// Fills submenu File -> Workspace -> Recent. /// </summary> public void ZFillMenuRecentWorkspaces(ToolStripDropDownMenu dd) { void _Add(string path, bool bold) { var mi = dd.Items.Add(path, null, (o, u) => ZLoadWorkspace(o.ToString())); if(bold) mi.Font = Au.Util.AFontsCached_.Bold; } dd.SuspendLayout(); dd.Items.Clear(); _Add(Program.Settings.workspace, true); var ar = Program.Settings.recentWS; int nRemoved = 0; for(int i = 0, n = ar?.Length ?? 0; i < n; i++) { var path = ar[i]; if(dd.Items.Count >= 20 || !AFile.ExistsAsDirectory(path)) { ar[i] = null; nRemoved++; } else _Add(path, false); } if(nRemoved > 0) { var an = new string[ar.Length - nRemoved]; for(int i = 0, j = 0; i < ar.Length; i++) if(ar[i] != null) an[j++] = ar[i]; Program.Settings.recentWS = an; } dd.ResumeLayout(); }
private void MouseEnter(object sender, EventArgs e) { ToolStripMenuItem item2 = (ToolStripMenuItem)sender; ToolStripDropDownMenu menu = (ToolStripDropDownMenu)item2.Owner; menu.Show(); }
private void AddFinalContextMenuStripOptions(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, this.OnHelp)); }
public void InvokeAction(object Sender, string ActionName) { //close the menu // For some reason, if we don't explicitly close the menus they remain open, // and on top of other windows. if (Sender is ContextMenuStrip) { ((ContextMenuStrip)Sender).Close(); } else if (Sender is ToolStripDropDownMenu) { ToolStripDropDownMenu Menu = (ToolStripDropDownMenu)Sender; if ((Menu.OwnerItem != null) && (Menu.OwnerItem.Owner != null) && Menu.OwnerItem.Owner is ContextMenuStrip) { ((ContextMenuStrip)Menu.OwnerItem.Owner).Close(); } Menu.Close(); } //call the method to carry out the action XmlNode ActionInvoke = XmlHelper.Find(ActionFile, "/Folder/Actions/" + ActionName + "/OnInvoke/Call"); //look up the <class> and <method> for the action in the Actions.xml if ((ActionInvoke != null)) { List <object> Arguments = new List <object>(); Arguments.Add(this); //pass the Controller as a parameter to the method CallDll.CallMethodOfClass(ActionInvoke, Arguments); //parameters for this are an XmlNode (with a <class> and <method> tag) and a list of Objects (which are the paramters for the method specified in the XmlNode) } }
public void Render(ToolStripMenuItem mruListMenu, MruMenuListItems mruMenuListItems, int textWidth, EventHandler mruMenuItem_Click) { // Clear existing menu items, if any ToolStripDropDownMenu rootMenu = (ToolStripDropDownMenu)mruListMenu.Owner; int mruListMenuIndex = rootMenu.Items.IndexOf(mruListMenu); for (int index = rootMenu.Items.Count - 1; index > mruListMenuIndex; index--) { if (rootMenu.Items[index] is MruToolStripMenuItem) { rootMenu.Items.RemoveAt(index); } } mruListMenu.Enabled = false; mruListMenu.Visible = true; // Fill MRU menu if (mruMenuListItems.Count > 0) { for (int index = 0; index < mruMenuListItems.Count; index++) { string filename = mruMenuListItems[index]; MruToolStripMenuItem mruMenuItem = new MruToolStripMenuItem(filename, textWidth, index + 1, mruMenuItem_Click); rootMenu.Items.Insert(mruListMenuIndex + index + 1, mruMenuItem); } mruListMenu.Enabled = true; mruListMenu.Visible = false; } }
private void MouseLeave(object sender, EventArgs e) { ToolStripMenuItem item2 = (ToolStripMenuItem)sender; ToolStripDropDownMenu menu = (ToolStripDropDownMenu)item2.Owner; menu.Hide(); }
private void MouseEnter(object sender, EventArgs e) { ToolStripMenuItem item2 = sender as ToolStripMenuItem; ToolStripDropDownMenu menu = item2.Owner as ToolStripDropDownMenu; menu.Show(); }
protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e) { var mc = ColorTable as MyColorTable; if (mc != null && mc.MyColorTheme.UsingSystemColors) { base.OnRenderSeparator(e); return; } ToolStripSeparator item = e.Item as ToolStripSeparator; if (e.Vertical || item == null) { base.OnRenderSeparator(e); } else { ToolStripDropDownMenu dropDownMenu = item.GetCurrentParent() as ToolStripDropDownMenu; Rectangle bounds = new Rectangle(Point.Empty, e.Item.Size); Brush br = new SolidBrush(item.BackColor); Pen pen = new Pen(item.ForeColor); e.Graphics.FillRectangle(br, bounds); bounds.X += dropDownMenu.Padding.Left - 2; bounds.Width = dropDownMenu.Width - bounds.X; int startY = bounds.Height / 2; e.Graphics.FillRectangle(br, bounds); e.Graphics.DrawLine(pen, bounds.Left, startY, bounds.Right - 1, startY); pen.Dispose(); br.Dispose(); } }
private void albumToolStripMenuItem_Click(object sender, EventArgs e) { ToolStripMenuItem submenuItem = (ToolStripMenuItem)sender; ToolStripDropDownMenu submenudrop = (ToolStripDropDownMenu)submenuItem.Owner; ToolStripMenuItem menuItem = (ToolStripMenuItem)submenudrop.OwnerItem; ContextMenuStrip m = (ContextMenuStrip)menuItem.Owner; DataGridView grid = (DataGridView)m.SourceControl; try { Media media = (Media)grid.Rows[SelectedRow].HeaderCell.Value; Artist file = Spotflix.GetPeopleDB[media.GetMetadata().GetArtist()]; Album pl = file.GetAlbums()[media.GetMetadata().GetAlbum()]; Filter f = new Filter(); panelArtist.Hide(); panelQueue.Show(); QueueLabel.Text = pl.GetName(); f.ObjGrid(f.CastToObj(pl.GetSongs()), QGrid, new List <Type>() { typeof(Media), typeof(Song), typeof(Video) }); } catch (Exception) { } }
private void newToolStripMenuItem_Click(object sender, EventArgs e)//new playlist { ToolStripMenuItem subsubmenuItem = (ToolStripMenuItem)sender; ToolStripDropDownMenu subsubmenudrop = (ToolStripDropDownMenu)subsubmenuItem.Owner; ToolStripMenuItem submenuItem = (ToolStripMenuItem)subsubmenudrop.OwnerItem; ToolStripDropDownMenu submenudrop = (ToolStripDropDownMenu)submenuItem.Owner; ToolStripMenuItem menuItem = (ToolStripMenuItem)submenudrop.OwnerItem; ContextMenuStrip m = (ContextMenuStrip)menuItem.Owner; DataGridView grid = (DataGridView)m.SourceControl; Media media = (Media)grid.Rows[SelectedRow].HeaderCell.Value; if (subsubmenuItem == subsubmenudrop.Items[0]) { DialogForm df = new DialogForm(); df.ShowDialog(); bool pvt = ActiveUser.GetPrivate(); if (!pvt) { pvt = df.Privacy; } ActiveUser.NewPlaylist(df.PLName, pvt); ActiveUser.AddToPlaylist(media, df.PLName); } else { string plname = subsubmenuItem.Text; ActiveUser.AddToPlaylist(media, plname); } }
private void RenderInMenu() { // Clear existing menu items, if any ToolStripDropDownMenu rootMenu = (ToolStripDropDownMenu)mruListMenu.Owner; int mruListMenuIndex = rootMenu.Items.IndexOf(mruListMenu); for (int index = rootMenu.Items.Count - 1; index > mruListMenuIndex; index--) { if (rootMenu.Items[index] is MruToolStripMenuItem) { rootMenu.Items.RemoveAt(index); } } // Hide mru list menu mruListMenu.Enabled = false; mruListMenu.Visible = true; // Render mru menu if (mruMenuListItems.Count > 0) { for (int index = 0; index < mruMenuListItems.Count; index++) { string filename = mruMenuListItems[index]; MruToolStripMenuItem mruMenuItem = new MruToolStripMenuItem(filename, textWidth, index + 1, MruMenuItem_Click); rootMenu.Items.Insert(mruListMenuIndex + index + 1, mruMenuItem); } // Show mru list menu mruListMenu.Enabled = true; mruListMenu.Visible = false; } }
/// <summary> /// Scales the MenuStrip and ContextMenuStrip scroll button arrows with the system DPI. /// </summary> /// <param name="menu">The menu.</param> internal static void ScaleScrollButtonArrows(ToolStripDropDownMenu menu) { if (menu != null) { var controls = menu.Controls; for (int i = 0; i < controls.Count; i++) { // The ToolStripDropDownMenu scrolling is implemented by the internal ToolStripScrollButton class, which uses a StickyLabel class to hold the arrow image. if (controls[i].GetType().Name == "StickyLabel") { Label label = controls[i] as Label; if (label != null) { if (label.Image != null && label.Tag == null) { if (label.Image.Size != UI.ScaleSize(label.Image.Size)) { label.Image = ScaleImageWithDPI(label.Image); } label.Tag = string.Empty; } } } } } }
public void OnDropDownOpening(ToolStripDropDownMenu menu) { // Called the dropdown menu is about to open. // No need to call "menu.SuspendLayout" or "menu.ResumeLayout". this.menu = menu; if (fFirstMenuDropDown) { menu.Items.Add(new ToolStripMenuItem("我的文档")); menu.Items.Add(new ToolStripMenuItem("控制面板\\所有控制面板项\\系统")); menu.Items.Add(new ToolStripMenuItem("控制面板\\所有控制面板项\\个性化")); menu.Items.Add(new ToolStripMenuItem("控制面板\\所有控制面板项\\网络连接")); // menu.Items.Add(new ToolStripMenuItem("设置当前目录JAVA_HOME")); // menu.Items.Add(new ToolStripMenuItem("设置当前目录M2_HOME")); menu.Items.Add(new ToolStripMenuItem("查看系统信息")); menu.Items.Add(new ToolStripMenuItem("重启资源管理器")); menu.Items.Add(new ToolStripMenuItem("关机")); // menu.Items.Add(new ToolStripMenuItem("设置当前目录ANT_HOME")); // menu.Items.Add(new ToolStripMenuItem("设置当前目录MVND_HOME")); menu.Items.Add(new ToolStripMenuItem("启动设置Path")); // menu.Items.Add(new ToolStripMenuItem("Test selection")); fFirstMenuDropDown = false; } }
public static BindableTreeNode GetContextMenuTreeviewNode(BindableTreeView treeView, object sender) { BindableTreeNode node = default(BindableTreeNode); if (sender is ContextMenuStrip) { ContextMenuStrip contextMenuStrip = (ContextMenuStrip)sender; TreeViewHitTestInfo testInfo = treeView.HitTest(treeView.PointToClient(new Point(contextMenuStrip.Left, contextMenuStrip.Top))); if (testInfo.Node != default(TreeNode)) { node = (BindableTreeNode)testInfo.Node; } } else if (sender is ToolStripMenuItem) { ToolStripMenuItem menuItem = (ToolStripMenuItem)sender; node = GetContextMenuTreeviewNode(treeView, menuItem.Owner); } else if (sender is ToolStripDropDownMenu) { ToolStripDropDownMenu menu = (ToolStripDropDownMenu)sender; node = GetContextMenuTreeviewNode(treeView, menu.OwnerItem); } return(node); }
private void contextMenuStrip_Opened(object sender, EventArgs e) { // 一覧を作る string dir = System.Environment.CurrentDirectory; string[] files = Directory.GetFiles(dir); ToolStripDropDownMenu statuses = new ToolStripDropDownMenu(); foreach (string file in files) { if (Path.GetExtension(file) != ".exe") { continue; } string name = Path.GetFileNameWithoutExtension(file); bool isMyProcess = (processName == name); // items ToolStripMenuItem item = new ToolStripMenuItem(); item.Text = name; item.Checked = isMyProcess; if (!isMyProcess) { item.Click += new System.EventHandler(selectStatus); } statuses.Items.Add(item); } statusToolStripMenuItem.DropDown = statuses; }
protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e) { ToolStripDropDownMenu currentParent = e.Item.GetCurrentParent() as ToolStripDropDownMenu; int x = currentParent.Padding.Left; int y = e.Item.Height / 2; e.Graphics.DrawLine(new Pen(Color.FromArgb(64, 64, 64)), x, y, e.Item.Bounds.Right, y); }
private ToolStripDropDownMenu createToolStripDropDownMenu() { ToolStripDropDownMenu tsddm = new ToolStripDropDownMenu(); PopulateDropDown(tsddm); return(tsddm); }
private ToolStripDropDown CreateDefaultDropDown() { var tsdd = new ToolStripDropDownMenu { OwnerItem = this }; return(tsdd); }
private void artistToolStripMenuItem_Click(object sender, EventArgs e) { ToolStripMenuItem submenuItem = (ToolStripMenuItem)sender; ToolStripDropDownMenu submenudrop = (ToolStripDropDownMenu)submenuItem.Owner; ToolStripMenuItem menuItem = (ToolStripMenuItem)submenudrop.OwnerItem; ContextMenuStrip m = (ContextMenuStrip)menuItem.Owner; DataGridView grid = (DataGridView)m.SourceControl; Media media; try { media = (Media)grid.Rows[SelectedRow].HeaderCell.Value; } catch (Exception) { return; } Artist file = Spotflix.GetPeopleDB[media.GetMetadata().GetArtist()]; panelArtist.Show(); ArtistNameLabel.Text = file.GetName(); FollowerQLabel.Text = file.GetFollowers().Count().ToString(); JobsBox.Text = ""; string jobs = ""; foreach (string item in file.GetProfessions()) { jobs += $"{item}, "; } string njobs = jobs.Substring(0, jobs.Length - 2); njobs += "."; JobsBox.Text = njobs; Filter f = new Filter(); f.ObjGrid(f.CastToObj(file.GetWork()), ArtistMediaGrid, new List <Type>() { typeof(Media), typeof(Song), typeof(Video) }); try { f.ObjGrid(f.CastToObj(file), ArtistAlbumGrid, new List <Type>() { typeof(Album) }); } catch (Exception) { } if (file.GetFollowers().Contains(ActiveUser)) { //Boton unfollow button6.Text = "Unfollow"; button6.BackColor = Color.CornflowerBlue; } }
private static IEnumerable <ToolStripItem> GetAllChildren(ToolStripDropDownMenu ddm) { foreach (var itm in ddm.Items.OfType <ToolStripItem>()) { foreach (var i in GetAllChildren(itm)) { yield return(i); } } }
/// <summary> /// Event handler included to manage propertly the case where any parent is disabled so /// it shouldn't be displayed. /// </summary> /// <param name="sender">The event sender.</param> /// <param name="e">The Cancel event arguments.</param> private void ToolStripDropDownItem_Opening(object sender, CancelEventArgs e) { if (DesignMode) { return; } ToolStripDropDownMenu source = sender as ToolStripDropDownMenu; e.Cancel = !source.OwnerItem.Enabled || HasParentMenuDisabled(source.OwnerItem); }
/// <summary> /// Shows ToolStripDropDownMenu menu at the cursor or caret position, like it would be a ContextMenuStrip menu. /// </summary> /// <remarks> /// This way is undocumented and possibly will stop working in future .NET versions. I did not find a better way. /// </remarks> public static void ZShowAsContextMenu(this ToolStripDropDownMenu t, bool caret = false) { if (!(caret && Api.GetCaretPosInScreen_(out POINT p))) { Api.GetCursorPos(out p); } var oi = t.OwnerItem; t.OwnerItem = null; //to set position try { t.Show(p); } finally { t.OwnerItem = oi; } }
public void ToolStripDropDownMenu_ConstructorOwnerItemBool() { var owner = new ToolStripButton(); var isAutoGenerated = true; var menu = new ToolStripDropDownMenu(owner, isAutoGenerated); Assert.NotNull(menu); Assert.Equal(owner, menu.OwnerItem); Assert.True(menu.IsAutoGenerated); }
public CheckBoxDropDown() : base() { popup = new ToolStripDropDownMenu(); popup.ShowImageMargin = false; //popup.TopLevel = false; //popup.CanOverflow = true; popup.AutoClose = true; popup.DropShadowEnabled = true; InitializeComponent(); }
protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e) { Rectangle bounds; if (colorTable.PopupForeColor != ToolStripSystemColorTable.DefaultPopupForeColor) { bounds = new Rectangle(Point.Empty, e.Item.Size); //We should probably use the PopupBorderColor for the separator, but in the specific //context of the dark skin, that color is not contrasty enough, so to keep things simple, //we just blend the fore color and the back color. DrawClassicSeparatorInternal( e.Graphics, Core.Utilities.ColorUtils.BlendColors(colorTable.PopupForeColor, 1, colorTable.PopupBackColor, 3), bounds); } else if (ToolStripManager.VisualStylesEnabled) { VisualStyleElement vsElement = VisualStyleElement.CreateElement(vsClass, 15, 0); if (VisualStyleRenderer.IsElementDefined(vsElement)) { VisualStyleRenderer vsRenderer = GetVisualStyleRenderer(vsElement); int partHeight = vsRenderer.GetPartSize(e.Graphics, ThemeSizeType.True).Height; int y = (e.Item.Height - partHeight) / 2; //Vertical center bounds = new Rectangle(0, y, e.Item.Width, partHeight); //here, the rect is full width, and we shrink it when we check for RightToLeft. ToolStripDropDownMenu dropDownMenu = e.Item.GetCurrentParent() as ToolStripDropDownMenu; if (dropDownMenu != null) { if (dropDownMenu.RightToLeft == RightToLeft.No) { bounds.X += dropDownMenu.ImageScalingSize.Width + 6; bounds.Width = dropDownMenu.Width - bounds.X; } else { bounds.X -= 6; bounds.Width = dropDownMenu.Width - bounds.X - dropDownMenu.ImageScalingSize.Width; } } vsRenderer.DrawBackground(e.Graphics, bounds); } else { base.OnRenderSeparator(e); } } else { base.OnRenderSeparator(e); } }
private bool IsRenderingImageCheck(ToolStripItem item) { ToolStripMenuItem menuItem = item as ToolStripMenuItem; if (menuItem == null) { return(false); } ToolStripDropDownMenu menu = menuItem.Owner as ToolStripDropDownMenu; return(menu != null && !menu.ShowCheckMargin && menuItem.Image != null); }
public void OnDropDownOpening(ToolStripDropDownMenu menu) { // Called the dropdown menu is about to open. // No need to call "menu.SuspendLayout" or "menu.ResumeLayout". if (this.fFirstMenuDropDown) { menu.Items.Add(new ToolStripMenuItem("Open folder")); menu.Items.Add(new ToolStripMenuItem("Test selection")); this.fFirstMenuDropDown = false; } }
private void toolStrip_ItemAdded(object sender, ToolStripItemEventArgs e) { ToolStripDropDownItem toolStripDropDownItem = e.Item as ToolStripDropDownItem; if (toolStripDropDownItem != null) { ToolStripDropDownMenu toolStripDropDownMenu = toolStripDropDownItem.DropDown as ToolStripDropDownMenu; if (toolStripDropDownMenu != null) { toolStripDropDownMenu.ShowImageMargin = false; } } }