当前位置: 首页>>代码示例>>C#>>正文


C# ContextMenuStrip.Show方法代码示例

本文整理汇总了C#中System.Windows.Forms.ContextMenuStrip.Show方法的典型用法代码示例。如果您正苦于以下问题:C# ContextMenuStrip.Show方法的具体用法?C# ContextMenuStrip.Show怎么用?C# ContextMenuStrip.Show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.ContextMenuStrip的用法示例。


在下文中一共展示了ContextMenuStrip.Show方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowContextMenu

        public static void ShowContextMenu(ContextMenuStrip contextMenu, DTE dte)
        {
            try
            {
                var serviceProvider = new ServiceProvider(dte as IServiceProvider);

                IVsUIShellOpenDocument sod = (IVsUIShellOpenDocument)serviceProvider.GetService(typeof(SVsUIShellOpenDocument));
                IVsUIHierarchy targetHier;
                uint[] targetId = new uint[1];
                IVsWindowFrame targetFrame;
                int isOpen;
                Guid viewId = new Guid(LogicalViewID.Primary);
                sod.IsDocumentOpen(null, 0, dte.ActiveWindow.Document.FullName,
                                   ref viewId, 0, out targetHier, targetId,
                                   out targetFrame, out isOpen);

                IVsTextView textView = VsShellUtilities.GetTextView(targetFrame);
                TextSelection selection = (TextSelection)dte.ActiveWindow.Document.Selection;
                Microsoft.VisualStudio.OLE.Interop.POINT[] interopPoint = new Microsoft.VisualStudio.OLE.Interop.POINT[1];
                textView.GetPointOfLineColumn(selection.ActivePoint.Line, selection.ActivePoint.LineCharOffset, interopPoint);

                POINT p = new POINT(interopPoint[0].x, interopPoint[0].y);

                ClientToScreen(textView.GetWindowHandle(), p);

                contextMenu.Show(new Point(p.x, p.y));
            }
            catch (Exception)
            {
                contextMenu.Show();
            }
        }
开发者ID:Galad,项目名称:SpecFlow,代码行数:32,代码来源:VsContextMenuManager.cs

示例2: snapShotDataTree_NodeMouseClick

        private void snapShotDataTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (e.Button != MouseButtons.Right) { return; }
            snapShotDataTree.SelectedNode = e.Node;
            if (!(e.Node is CallNode)) return;
            CallNode tmpNode = (CallNode)e.Node;
            Csta.ConnectionID_t selectedConnId = tmpNode.connection;
            ContextMenuStrip snapShotDataTreeContextMenu = new ContextMenuStrip();
            ToolStripItem cstaClearCallContextMenuItem = snapShotDataTreeContextMenu.Items.Add("cstaClearCall");
            ToolStripItem cstaClearConnectionContextMenuItem = snapShotDataTreeContextMenu.Items.Add("cstaClearConnection");
            cstaClearCallContextMenuItem.Click += (s, ev) =>
            {
                Csta.EventBuffer_t evtbuf = Csta.clearCall(this.parentForm.acsHandle, selectedConnId);
                if (evtbuf.evt.eventHeader.eventClass.eventClass == Csta.CSTACONFIRMATION && evtbuf.evt.eventHeader.eventType.eventType == Csta.CSTA_CLEAR_CALL_CONF)
                {
                    snapShotDataTree.Nodes.Remove(tmpNode);
                }
            };

            cstaClearConnectionContextMenuItem.Click += (s, ev) =>
            {
                Csta.EventBuffer_t evtbuf = Csta.clearConnection(parentForm.acsHandle, parentForm.privData, selectedConnId);
                if (evtbuf.evt.eventHeader.eventClass.eventClass == Csta.CSTACONFIRMATION && evtbuf.evt.eventHeader.eventType.eventType == Csta.CSTA_CLEAR_CONNECTION_CONF)
                {
                    snapShotDataTree.Nodes.Remove(tmpNode);
                }
            };

            snapShotDataTreeContextMenu.Show(Cursor.Position);
        }
开发者ID:shizenghua,项目名称:TSAPIDemo,代码行数:30,代码来源:SnapShotDevicePopup.cs

示例3: requestColorDialog

        public static Color requestColorDialog(Control sender)
        {
            Color res = Color.Empty;
            ContextMenuStrip cm = new ContextMenuStrip();
            var ColorDic = new Dictionary<string, Color>();

            ColorDic.Add("Red", Color.Red);
            ColorDic.Add("Blue", Color.Blue);
            ColorDic.Add("Yellow", Color.Yellow);
            ColorDic.Add("Green", Color.Green);
            ColorDic.Add("Transparent", Color.FromArgb(0, 255, 255, 255));

            foreach ( KeyValuePair<string, Color> pair in ColorDic)
            {
                Bitmap bmp = new Bitmap(10, 10);
                for(int k = 0; k < bmp.Width; k++)
                {
                    for(int v = 0; v < bmp.Height; v++)
                    {
                        bmp.SetPixel(k, v, pair.Value);
                    }
                }
                cm.Items.Add(new ToolStripMenuItem(pair.Key, bmp, (s, e) => { res = pair.Value; }));
            }
            cm.Items.Add(new ToolStripMenuItem("Custom...", new Bitmap(1, 1), (s, e) => { res = oldDialogPicker(); }));

            cm.Show(sender, sender.PointToClient(new Point(Cursor.Position.X, Cursor.Position.Y)));
            cm.Focus();
            while (cm.Visible == true) { Application.DoEvents(); }
            return res;
        }
开发者ID:Enoz,项目名称:InfiniPad,代码行数:31,代码来源:Globals.cs

示例4: ListBox_MouseDown

        private void ListBox_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                ListBox.SelectedIndex = ListBox.IndexFromPoint(e.Location);

                if (ListBox.SelectedIndex != -1)
                {
                    ContextMenuStrip contextMenuStrip = new ContextMenuStrip();

                    contextMenuStrip.Items.Add(mMoveToTop);
                    contextMenuStrip.Items.Add(mMoveUp);
                    contextMenuStrip.Items.Add(mMoveDown);
                    contextMenuStrip.Items.Add(mMoveToBottom);

                    Point point = new Point(
                        System.Windows.Forms.Cursor.Position.X,
                        System.Windows.Forms.Cursor.Position.Y);

                    contextMenuStrip.Show(point);
                }
            }
            else if(this.ListBox.SelectedItem != null)
            {
                // Code from:
                // http://stackoverflow.com/questions/805165/reorder-a-winforms-listbox-using-drag-and-drop
                this.ListBox.DoDragDrop(this.ListBox.SelectedItem, DragDropEffects.Move);
            }
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:29,代码来源:ReferencedFileFlatListWindow.cs

示例5: InterlinDocForAnalysis_RightMouseClickedEvent

		void InterlinDocForAnalysis_RightMouseClickedEvent(SimpleRootSite sender, FwRightMouseClickEventArgs e)
		{
			e.EventHandled = true;
			// for the moment we always claim to have handled it.
			ContextMenuStrip menu = new ContextMenuStrip();

			// Add spelling items if any (i.e., if we clicked a squiggle word).
			int hvoObj, tagAnchor;
			if (GetTagAndObjForOnePropSelection(e.Selection, out hvoObj, out tagAnchor) &&
				(tagAnchor == SegmentTags.kflidFreeTranslation || tagAnchor == SegmentTags.kflidLiteralTranslation ||
				tagAnchor == NoteTags.kflidContent))
			{
				var helper = new SpellCheckHelper(Cache);
				helper.MakeSpellCheckMenuOptions(e.MouseLocation, this, menu);
			}

			int hvoNote;
			if (CanDeleteNote(e.Selection, out hvoNote))
			{
				if (menu.Items.Count > 0)
				{
					menu.Items.Add(new ToolStripSeparator());
				}
				// Add the delete item.
				string sMenuText = ITextStrings.ksDeleteNote;
				ToolStripMenuItem item = new ToolStripMenuItem(sMenuText);
				item.Click += OnDeleteNote;
				menu.Items.Add(item);
			}
			if (menu.Items.Count > 0)
			{
				e.Selection.Install();
				menu.Show(this, e.MouseLocation);
			}
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:35,代码来源:InterlinDocForAnalysis.cs

示例6: ShowContextMenu

        public static void ShowContextMenu(IMenuCommandService service, Control owner, int x, int y)
        {
            var menu = new ContextMenuStrip();
            menu.Items.AddRange(GetMenuItems(service.Verbs));
            menu.Show(owner, x, y);

        }
开发者ID:die-Deutsche-Orthopaedie,项目名称:LiteDevelop,代码行数:7,代码来源:MenuService.cs

示例7: gridKursUebersicht_MouseDown

        private void gridKursUebersicht_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right) // Rechtsklick
            {
                // ContextMenuStrip mit ToolStipMenuItem erzeugen
                ContextMenuStrip myContextMenu = new ContextMenuStrip();
                ToolStripMenuItem toolStripItemUebersichtAktualisieren = new ToolStripMenuItem("Aktualisieren (F5)");

                // Items hinzufügen
                myContextMenu.Items.Add(toolStripItemUebersichtAktualisieren);

                // Bild hinzufuegen
                toolStripItemUebersichtAktualisieren.Image = PuG_Verwaltungssoftware.Properties.Resources.pug_refresh;

                // Handler der Items
                toolStripItemUebersichtAktualisieren.Click += new EventHandler(toolStripItemUebersichtAktualisieren_Click);

                int currentMouseOverRow = gridKursUebersicht.HitTest(e.X, e.Y).RowIndex;

                if (currentMouseOverRow >= 0) // In der Tabelle
                {
                    // Nix
                }

                myContextMenu.Show(gridKursUebersicht, new Point(e.X, e.Y));
            }
        }
开发者ID:pug-tefm,项目名称:verwaltungssoftware,代码行数:27,代码来源:winPartialKursUebersicht.cs

示例8: Show

        public static void Show(int iPosX, int iPosY)
        {
            EntryMenu.Destroy();

            m_ctx = EntryMenu.Construct();
            m_ctx.Show(iPosX, iPosY);
        }
开发者ID:ashwingj,项目名称:keepass2,代码行数:7,代码来源:EntryMenu.cs

示例9: ShowMenu

 void ShowMenu()
 {
     ContextMenuStrip menu = new ContextMenuStrip();
     menu.Items.Add(defaultText).Click += new EventHandler(defaultItem_Click);
     foreach (TreeNode n in TopResource.Node.Nodes)
         menu.Items.Add(CreateItem(n.Tag as IResourceView));
     menu.Show(MousePosition);
 }
开发者ID:MilesBoulanger,项目名称:game-creator,代码行数:8,代码来源:ResourceSelector.cs

示例10: ShowContextMenu

		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Creates and shows a context menu with spelling suggestions.
		/// </summary>
		/// <param name="pt">The location on the screen of the word for which we want spelling
		/// suggestions (usually the mouse position)</param>
		/// <param name="rootsite">The focused rootsite</param>
		/// <returns><c>true</c> if a menu was created and shown (with at least one item);
		/// <c>false</c> otherwise</returns>
		/// -----------------------------------------------------------------------------------
		public bool ShowContextMenu(Point pt, SimpleRootSite rootsite)
		{
			ContextMenuStrip menu = new ContextMenuStrip();
			MakeSpellCheckMenuOptions(pt, rootsite, menu);
			if (menu.Items.Count == 0)
				return false;
			menu.Show(rootsite, pt);
			return true;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:19,代码来源:SpellCheckHelper.cs

示例11: btnSaveAs_Click

 private void btnSaveAs_Click(object sender, EventArgs e)
 {
     var toolStrip = new ContextMenuStrip();
     foreach (var transposer in _transposers)
     {
         toolStrip.Items.Add(transposer.GetType().Name);
     }
     toolStrip.Show(btnSaveAs, new Point(0, btnSaveAs.Height));
 }
开发者ID:shibafu528,项目名称:CapBucket,代码行数:9,代码来源:Bucket.cs

示例12: ShowContextMenu

		private static void ShowContextMenu(ContextMenuStrip contextMenuStrip, ActionModelNode actionModel, Point screenPoint, int minWidth, bool alignRight)
		{
			ToolStripBuilder.Clear(contextMenuStrip.Items);
			if (actionModel != null)
			{
				ToolStripBuilder.BuildMenu(contextMenuStrip.Items, actionModel.ChildNodes);
				if (alignRight)
					screenPoint.Offset(-contextMenuStrip.Width, 0);
				contextMenuStrip.Show(screenPoint);
			}
		}
开发者ID:nhannd,项目名称:Xian,代码行数:11,代码来源:StudyFilterTableView.cs

示例13: ShowContextMenu

        public System.Windows.Forms.ContextMenuStrip ShowContextMenu(System.Windows.Forms.Control parent, List<MySQL.Base.MenuItem> items, int x, int y)
        {
            System.Windows.Forms.ContextMenuStrip menu = new System.Windows.Forms.ContextMenuStrip();
              System.Windows.Forms.ToolStripItem[] itemList;

              itemList = buildMenu(items, new EventHandler(menuItem_Click));
              menu.Items.AddRange(itemList);

              menu.Show(parent, new System.Drawing.Point(x, y), ToolStripDropDownDirection.BelowRight);

              return menu;
        }
开发者ID:abibell,项目名称:mysql-workbench,代码行数:12,代码来源:WorkbenchMenuManager.cs

示例14: button9_Click

 private void button9_Click(object sender, EventArgs e)
 {
     System.Windows.Forms.ContextMenuStrip menu = new ContextMenuStrip();
     foreach (ObjectResourceView res in Program.Objects.Values)
     {
         ToolStripMenuItem collisionObjectMenuItem = new ToolStripMenuItem(res.Name);
         collisionObjectMenuItem.Tag = res;
         collisionObjectMenuItem.Click += new EventHandler(collisionObjectMenuItem_Click);
         menu.Items.Add(collisionObjectMenuItem);
     }
     menu.Show(MousePosition);
 }
开发者ID:MilesBoulanger,项目名称:game-creator,代码行数:12,代码来源:EventForm.cs

示例15: chart_MouseDown

        private void chart_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                CompleteMenu = new ContextMenuStrip();

                ToolStripMenuItem ToolStripMenuItem_DisplayTable = new ToolStripMenuItem("Clear");
                CompleteMenu.Items.Add(ToolStripMenuItem_DisplayTable);
                ToolStripMenuItem_DisplayTable.Click += new System.EventHandler(this.ClearPanel);

                CompleteMenu.Show(Control.MousePosition);
            }
        }
开发者ID:cyrenaique,项目名称:HCSA,代码行数:13,代码来源:cViewerText.cs


注:本文中的System.Windows.Forms.ContextMenuStrip.Show方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。