private void typeLegendPanel_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if ((e.Button & MouseButtons.Left) != MouseButtons.None) { for (int i = 0; i < buckets.Length; i++) { if (buckets[i].selected) { graphPanel.Invalidate(); typeLegendPanel.Invalidate(); buckets[i].selected = false; } } if (sortedTypeTable != null) { foreach (TypeDesc t in sortedTypeTable) { if (t.rect.Contains(e.X, e.Y) != t.selected) { t.selected = !t.selected; graphPanel.Invalidate(); typeLegendPanel.Invalidate(); } } } } else if ((e.Button & MouseButtons.Right) != MouseButtons.None) { Point p = new Point(e.X, e.Y); contextMenu.Show(typeLegendPanel, p); } }
protected void TreeView_NodeMouseClickAsm(object sender, TreeNodeMouseClickEventArgs e) { try { if (e.Button == MouseButtons.Right) { if (!TreeView.IsNodeSelected(e.Node)) { TreeView.ClearSelection(); TreeView.SetSelected(e.Node, true, false); } SelectInventorFeatures(); if (e.Node.Tag is PartFeature) { _ctxMenuTree.MenuItems[0].Enabled = FeatureUtilities.IsSupportedFeature(e.Node.Tag as PartFeature); _ctxMenuTree.Show(TreeView, e.Location); } } else { SelectInventorFeatures(); } } catch { //Exception here means that the browser //is out-ot-sync with the features state. RefreshControl(AdnInventorUtilities.InvApplication.ActiveDocument); } }
private void textEditorControl_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Right) { System.Drawing.Point wPoint = new Point(e.X, e.Y); Menu.Show(this, wPoint); } }
/// <summary> /// Show menu for left button /// </summary> private void linkLeft_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { m_EditLeft = true; if (e.Button == MouseButtons.Right && m_Def.Left != null) { EditDef(); } else { cMenu.Show(linkLeft, new Point(e.X, e.Y)); } }
/// ////////////////////////////////////////////////////////// private void m_lnkAjoutParFiltre_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { m_menuPopup.MenuItems.Clear(); CListeObjetsDonnees liste = new CListeObjetsDonnees(CSc2iWin32DataClient.ContexteCourant, typeof(CFiltreDynamiqueInDb)); liste.Filtre = new CFiltreData(CFiltreDynamiqueInDb.c_champTypeElements + "=@1", m_typElements.ToString()); foreach (CFiltreDynamiqueInDb filtre in liste) { MenuItem item = new CMenuItemFiltre(filtre); item.Click += new EventHandler(ItemFiltreClick); m_menuPopup.MenuItems.Add(item); } m_menuPopup.Show(m_lnkAjoutParFiltre, new Point(0, m_lnkAjoutParFiltre.Height)); }
public override void ShowContextMenu(CommandID menuID, int x, int y) { base.ShowContextMenu(menuID, x, y); if (menuID == WorkflowMenuCommands.SelectionMenu) { ContextMenu contextMenu = new ContextMenu(); foreach (DesignerVerb verb in Verbs) { MenuItem menuItem = new MenuItem(verb.Text, new EventHandler(OnMenuClicked)); menuItem.Tag = verb; contextMenu.MenuItems.Add(menuItem); } foreach (MenuItem menu in BuildItemsForSeletion()) { contextMenu.MenuItems.Add(menu); } WorkflowView workflowView = GetService(typeof(WorkflowView)) as WorkflowView; if (workflowView != null) { contextMenu.Show(workflowView, workflowView.PointToClient(new Point(x, y))); } } }
private void dgrdProjects_MouseDown(object sender, MouseEventArgs e) { // if editing is in progress if (textEdit.Visible && e.Button == MouseButtons.Right) { // if ( the user tapped in the row header of the row // being edited, display the Update/Cancel context // menu to the user. if (dgrdProjects.HitTest(e.X, e.Y).Type == DataGrid.HitTestType.RowHeader && dgrdProjects.HitTest(e.X, e.Y).Row == dgrdProjects.CurrentRowIndex) { cmenuEdit.Show(textEdit, new Point(0, 0)); } } // When the user taps on a data cell or a row // header, the current cell will change. // Our CurrentCellChanged event will need to // know that this was caused by a mouse tap, // rather than by a Tab or programatically. boolMouseDriven = ((dgrdProjects.HitTest(e.X, e.Y).Type == DataGrid.HitTestType.Cell) || (dgrdProjects.HitTest(e.X, e.Y).Type == DataGrid.HitTestType.RowHeader)); }
private void PictureBox_MouseDown(Object sender, MouseEventArgs e) { Control ctlSelected = (Control)sender; if (!Globals.IsKit()) { if (e.Button == MouseButtons.Right) { contextMenuTiles.Show(ctlSelected, new Point(e.X, e.Y)); return; } } Tile tile = (Tile)((PictureBox)sender).Tag; Globals.PropertyGrid.SelectedObject = tile.GetTemplate(m_tmpdActive); // Start drag drop LevelData ldat = new LevelData(); IMapItem mi = (IMapItem)ctlSelected.Tag; ldat.ami = new IMapItem[] { mi }; Size sizTile = m_tmpdActive.TileSize; ldat.txMouse = e.X / (double)sizTile.Width; ldat.tyMouse = e.Y / (double)sizTile.Height; ldat.Grid.Width = mi.Grid.Width; ldat.Grid.Height = mi.Grid.Height; DoDragDrop(ldat, DragDropEffects.Copy); }
private void userName_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { int cursorX = userName.Width - 20; //left edge of button int cursorY = userName.Height; //below button contextMenu.Show(userName, new System.Drawing.Point(cursorX, cursorY)); }
//------------------------------------------------------------------------- private void m_lnkFiltrer_LinkClicked(object sender, System.EventArgs e) { if (m_elementsAAgenda.Length == 0) { return; } CListeObjetsDonnees liste = new CListeObjetsDonnees(m_elementsAAgenda[0].ContexteDonnee, typeof(CFiltreDynamiqueInDb)); liste.Filtre = new CFiltreData( CFiltreDynamiqueInDb.c_champTypeElements + "=@1", typeof(CRelationEntreeAgenda_ElementAAgenda).ToString()); if (liste.Count == 0) { CFormAlerte.Afficher(I.T("No filter exists on|30081") + DynamicClassAttribute.GetNomConvivial(typeof(CRelationEntreeAgenda_ElementAAgenda)), EFormAlerteType.Exclamation); return; } if (m_menuFiltrer.MenuItems.Count == 0) { CMenuItemAFiltreDynamique menu = new CMenuItemAFiltreDynamique(null); menu.Text = "None|30082"; menu.Click += new EventHandler(OnMenuFiltrer); m_menuFiltrer.MenuItems.Add(menu); foreach (CFiltreDynamiqueInDb filtre in liste) { menu = new CMenuItemAFiltreDynamique(filtre); menu.Text = filtre.Libelle; menu.Click += new EventHandler(OnMenuFiltrer); m_menuFiltrer.MenuItems.Add(menu); } } m_menuFiltrer.Show(m_lnkFiltrer, new Point(0, m_lnkFiltrer.Height)); }
// The user clicked on the status bar. // If the status bar has just one panel (e.g. Selectable), display // the dialog associated with that panel. // If the status bar has multiple panels, display a context menu to let the // user choose which dialog to display (Selectable, Editable, Drawable). private void statusBarPanelClick( object sender, System.Windows.Forms.StatusBarPanelClickEventArgs e) { if (_selectFilter != null && _editFilter == null && _insertFilter == null) { MenuItemSelect_Click(null, null); } else if (_selectFilter == null && _editFilter != null && _insertFilter == null) { MenuItemEdit_Click(null, null); } else if (_selectFilter == null && _editFilter == null && _insertFilter != null) { MenuItemInsert_Click(null, null); } else { contextMenu.MenuItems.Clear(); if (_selectFilter != null) { contextMenu.MenuItems.Add(_menuItemSelect); } if (_editFilter != null) { contextMenu.MenuItems.Add(_menuItemEdit); } if (_insertFilter != null) { contextMenu.MenuItems.Add(_menuItemInsert); } contextMenu.Show(this, new Point(e.X, e.Y)); } }
private void logTree_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Right) { TreeNode clickedNode = logTree.GetNodeAt(new Point(e.X, e.Y)); if (clickedNode != null) { // store the right-clicked node (this sucks!!) _rightClickedNode = clickedNode; bool isMachineNode = (clickedNode.Parent == null); connectToComputerMenuItem.Visible = isMachineNode; openLogFileMenuItem.Visible = true; treeContextMenuSeparator1.Visible = !isMachineNode; clearEventsMenuItem.Visible = !isMachineNode; refreshEntriesMenuItem.Visible = !isMachineNode; treeContextMenuSeparator2.Visible = !isMachineNode; logPropertiesMenuItem.Visible = !isMachineNode; treeContextMenuSeparator3.Visible = true; helpMenuItem.Visible = true; treeContextMenu.Show(logTree, logTree.PointToClient(TreeView.MousePosition)); } else { foreach (MenuItem menuItem in treeContextMenu.MenuItems) { menuItem.Visible = false; } } } }
private void OnRightClickNode(TreeNode node) { if (node is CategoryNode || node is SubsectionNode) { _mnuExportDesigns.Text = "Export Designs"; _mnuDeleteDesigns.Text = "Delete Designs"; } else { _mnuExportDesigns.Text = "Export"; _mnuDeleteDesigns.Text = "Delete"; } contextMenu1.MenuItems.Clear(); if (node is DesignNode) { contextMenu1.MenuItems.Add(_mnuBuildDesign); contextMenu1.MenuItems.Add(_mnuPreviewDesign); contextMenu1.MenuItems.Add(new MenuItem("-")); contextMenu1.MenuItems.Add(_mnuEditDesign); } contextMenu1.MenuItems.Add(_mnuDeleteDesigns); if (node is DesignNode) { contextMenu1.MenuItems.Add(new MenuItem("-")); } contextMenu1.MenuItems.Add(_mnuExportDesigns); contextMenu1.Show(tvwDesigns, tvwDesigns.MouseCoords); }
//------------------------------------------------------------------------- public void ShowMenuAjout(Point pt) { if (!m_lnkAjouter.Visible) { return; } CObjetDonneeAIdNumerique element = m_elementsAAgenda[0]; //cherche les entrées qui collent avec des acteurs CListeObjetsDonnees liste = new CListeObjetsDonnees(element.ContexteDonnee, typeof(CTypeEntreeAgenda)); CFiltreDataAvance filtre = new CFiltreDataAvance(CTypeEntreeAgenda.c_nomTable, CRelationTypeEntreeAgenda_TypeElementAAgenda.c_nomTable + "." + CRelationTypeEntreeAgenda_TypeElementAAgenda.c_champTypeElement + "=@1 and " + CRelationTypeEntreeAgenda_TypeElementAAgenda.c_nomTable + "." + CRelationTypeEntreeAgenda_TypeElementAAgenda.c_champLienMaitre + "=@2", element.GetType().ToString(), true); liste.Filtre = filtre; if (liste.Count == 0) { CFormAlerte.Afficher(I.T("No Agenda entry type can be applied on this element type|30080"), EFormAlerteType.Exclamation); return; } m_menuAjouterAgenda.MenuItems.Clear(); foreach (CTypeEntreeAgenda typeEntree in liste) { CMenuItemATypeEntreeAgenda item = new CMenuItemATypeEntreeAgenda(typeEntree); item.Text = typeEntree.Libelle; item.Click += new EventHandler(OnMenuAjouterAgenda); m_menuAjouterAgenda.MenuItems.Add(item); } pt = PointToClient(pt); m_menuAjouterAgenda.Show(this, pt); }
private void LoadButton_Click(object sender, System.EventArgs e) { try { RecentDefMenu.MenuItems.Clear(); System.Windows.Forms.MenuItem BrowseItem = RecentDefMenu.MenuItems.Add("&Browse..."); BrowseItem.Click += new System.EventHandler(this.BrowseJobDefMenuItem_Click); string[] RecentJobDefFilePaths = ReadRecentJobDefFilePaths(); foreach (string JobDefFilePath in RecentJobDefFilePaths) { if (JobDefFilePath.ToUpper() != m_JobDefSet.FilePath.ToUpper()) { System.Windows.Forms.MenuItem NewItem = RecentDefMenu.MenuItems.Add(JobDefFilePath); NewItem.Click += new System.EventHandler(this.LoadRecentJobDefMenuItem_Click); } } System.Drawing.Point pt = new System.Drawing.Point(); pt.X = LoadButton.Location.X; pt.Y = LoadButton.Location.Y + LoadButton.Height; RecentDefMenu.Show(this, pt); } catch (Exception x) { m_Prefs.ShowError(x.Message); } }
private void m_lvPEs_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { try { System.Windows.Forms.ListViewItem lvItemSelecionado = m_lvPEs.GetItemAt(e.X, e.Y); if ((lvItemSelecionado != null) && (e.Button == System.Windows.Forms.MouseButtons.Right)) { this.Cursor = System.Windows.Forms.Cursors.WaitCursor; bool bConcluido = false; int nQdeConcluidos = 0; foreach (System.Windows.Forms.ListViewItem lvItemPEs in m_lvPEs.SelectedItems) { if (lvItemPEs.ImageIndex == 0) { nQdeConcluidos++; } } if (nQdeConcluidos > (int)(m_lvPEs.SelectedItems.Count / 2)) { bConcluido = true; } m_mnitPEConcluido.Checked = bConcluido; m_cnmnPEConcluido.Show(m_lvPEs, new System.Drawing.Point(e.X, e.Y)); this.Cursor = System.Windows.Forms.Cursors.Default; } } catch (Exception err) { Object erro = err; m_cls_ter_tratadorErro.trataErro(ref erro); } }
private void tvModel_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Right) { ctmChip.Show(tvModel, new Point(e.X, e.Y)); } }
/// <summary> /// The DragDrop event of the target control fires when a drop actually occurs over /// the target control. This is where the data being dragged is actually processed. /// /// This event will fire only if the AllowDrop property of the target control has /// been set to true. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">A DragEventArgs that contains the event data.</param> private void listBox1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { // Store the data as a string so that it can be accessed from the // mnuCopy and mnuMove click events. sourceData = e.Data.GetData(DataFormats.Text, true).ToString(); // If the right mouse button was used, provide a context menu to allow // the user to select a DragDrop effect. The mouseButton is recorded in the // MouseDown event of the source control. if (mouseButton == MouseButtons.Right) { // Show a context menu, asking which operation to perform. // The ProcessData() call is then made in the click event // of the mnuCopy and mnuMove menu items. Show only those // menu items that correspond to an allowed effect. mnuCopy.Visible = ((e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy); mnuMove.Visible = ((e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move); contextMenu1.Show(listBox1, new Point(20, 20)); } else { // Set the deleteSource member field based on the Effect. // The Effect is preset in the DragEnter event handler. deleteSource = (e.Effect == DragDropEffects.Move); // The processing of the data is done in a separate call, since // this is also called from the click event of the contextMenu1 items. ProcessData(); } }
private void graphControl1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { if (SelectedShape == null) { return; } if (e.Button == MouseButtons.Right) { if (SelectedShape.ARDescriptor is ActiveRecordDescriptorSubClass) { removeMenu.Enabled = true; addJoinedSubclassMenu.Enabled = false; addSubClassMenu.Enabled = false; } else { removeMenu.Enabled = false; // False cause we haven't implemented it :-) addJoinedSubclassMenu.Enabled = false; addSubClassMenu.Enabled = true; } contextMenu.Show(sender as Control, new Point(e.X, e.Y)); } }
/// //////////////////////////////////////////////////// private void OnClickMenu(object sender, LinkLabelLinkClickedEventArgs args) { if (DesignMode) { return; } if (!(sender is Control)) { return; } CMenuCustom menu = (CMenuCustom)args.Link.LinkData; if (menu.ListeMenusFils.Count == 0) { CResultAErreur result = CExecuteurActionSur2iLink.ExecuteAction(sender, menu.Action, null); if (!result) { CFormAlerte.Afficher(result.Erreur); } } else { //Crée le menu CreateSousMenu(m_sousMenu.MenuItems, menu); m_sousMenu.Show((Control)sender, new Point(0, ((Control)sender).Height)); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void panelTop_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { _ctxMenuSettings.Show(panelTop, this.PointToClient(Cursor.Position)); } }
public void ShowContextMenu(ContextMenuParams parameters) { System.Windows.Forms.ContextMenu popupMenu = new System.Windows.Forms.ContextMenu(); if (!String.IsNullOrEmpty(parameters.LinkText)) { popupMenu.MenuItems.Add(new MenuItem("Open link in new window", delegate { String linkURL = parameters.LinkURL; Console.Out.WriteLine("linkURL = " + linkURL); })); } Browser browser = parameters.Browser; popupMenu.MenuItems.Add(new MenuItem("Reload", delegate { browser.Reload(); })); Point location = parameters.Location; view.Invoke(new Action(() => { popupMenu.Show(view, location); })); }
//The OnContextMenu event is fired when a user right clicks within the // IEngineNetworkAnalystEnvironment::NAWindow and can be used to supply a context menu. public bool OnContextMenu(int x, int y) { System.Drawing.Point pt = this.PointToClient(System.Windows.Forms.Cursor.Position); // Get the active category var activeCategory = m_naWindow.ActiveCategory as IEngineNAWindowCategory2; if (activeCategory == null) { return(false); } MenuItem separator = new MenuItem("-"); miLoadLocations.Enabled = false; miClearLocations.Enabled = false; // in order for the AddItem choice to appear in the context menu, the class // should be an input class, and it should not be editable INAClassDefinition pNAClassDefinition = activeCategory.NAClass.ClassDefinition; if (pNAClassDefinition.IsInput) { miLoadLocations.Enabled = true; miClearLocations.Enabled = true; // canEditShape should be false for AddItem to Apply (default is false) // if it's a StandaloneTable canEditShape is implicitly false (there's no shape to edit) bool canEditShape = false; IFields pFields = pNAClassDefinition.Fields; int nField = -1; nField = pFields.FindField("Shape"); if (nField >= 0) { int naFieldType = 0; naFieldType = pNAClassDefinition.get_FieldType("Shape"); // determining whether or not the shape field can be edited consists of running a bitwise comparison // on the FieldType of the shape field. See the online help for a list of the possible field types. // For our case, we want to verify that the shape field is an input field. If it is an input field, // then we do NOT want to display the Add Item menu option. canEditShape = ((naFieldType & (int)esriNAFieldType.esriNAFieldTypeInput) == (int)esriNAFieldType.esriNAFieldTypeInput) ? true : false; } if (!canEditShape) { contextMenu1.MenuItems.Add(separator); contextMenu1.MenuItems.Add(miAddItem); } } contextMenu1.Show(this, pt); // even if the miAddItem menu item has not been added, Remove() won't crash. contextMenu1.MenuItems.Remove(separator); contextMenu1.MenuItems.Remove(miAddItem); return(true); }
private void scrollableListView_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Right) { lastRightClickPoint = new System.Drawing.Point(e.X, e.Y); createTestPopupMenu.Show(this, lastRightClickPoint); } }
private void labelHelp_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { HelpActive = true; contextMenu2.Show(labelHelp, new Point(0, labelHelp.Height)); HelpActive = false; labelHelp.ForeColor = SystemColors.MenuText; Invalidate(); }
private void labelFile_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { FileActive = true; contextMenu1.Show(labelFile, new Point(0, labelFile.Height)); FileActive = false; labelFile.ForeColor = SystemColors.MenuText; Invalidate(); }
// Click on the page protected override void OnMouseDown(MouseEventArgs e) { HasFocus = true; if (e.Button == MouseButtons.Right) { mousePositionOnRightClick = ParentTest.Paper.ScreenPointToGridPoint(e.Location); pageMenu.Show(this, new Point(e.X, e.Y)); } }
private void lstUsers_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Right) { if ((lstUsers.Items.Count > 0) && (lstUsers.SelectedItems.Count > 0)) { mnuUser.Show(lstUsers, new Point(e.X, e.Y)); } } }
public void Contmenus() { MenuItem m1 = new MenuItem("添加"); MenuItem m2 = new MenuItem("修改"); MenuItem[] menuitems = new MenuItem[] { m1, m2 }; ContextMenu button1ctm = new ContextMenu(menuitems); Point p = new Point(0, button3.Size.Height); button1ctm.Show(button3,p); m1.Click += new System.EventHandler(tianj_click);//选择添加按钮时,添加事件 m2.Click += new System.EventHandler(tianj1_click);//同上,选择修改按钮 }
private void Form1_MouseDown(object sender, MouseEventArgs e) { // Check for a right mouse click. if (e.Button == MouseButtons.Right) // Display a merged menu containing items from mainMenu1 // and contextMenu1. { contextMenu1.Show(this, new System.Drawing.Point(30, 30)); } }
private void changeTeamButton_Click(object sender, EventArgs e) { ContextMenu menu = new ContextMenu(); if (Program.TasClient.MyBattle != null) { menu.MenuItems.AddRange(ZeroKLobby.MicroLobby.ContextMenus.GetSetAllyItems()); } menu.Show(btnChangeTeam, new Point(0, 0)); }
private void Map_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Right) { cmMap.Show((Control)sender, new Point(e.X, e.Y)); } else { Map.Center = Map.ControlToMap(new Point(e.X, e.Y)); } }
private void GraphForm_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { if (m_selection == null) { return; } //connect request Monitor.Enter(m_graph); GraphNodeSelectionVisitor gnsv = new GraphNodeSelectionVisitor(new Point(e.X, e.Y)); GraphNode target = (GraphNode)m_graph.getVisited(gnsv); if (target != null) { //it was clicked on a node m_graph.connect(m_selection, target); } else { m_selection = null; } Monitor.Exit(m_graph); } else if (e.Button == MouseButtons.Left) { GraphNodeSelectionVisitor gnsv = new GraphNodeSelectionVisitor(new Point(e.X, e.Y)); m_selection = (GraphNode)m_graph.getVisited(gnsv); if (m_selection != null) { //it was clicked on a node if (e.Clicks > 1) { //double click if (m_selection.LowerGraph == null) { m_selection.LowerGraph = m_gen_graph(); } m_selection.LowerGraph.Parent = m_graph; m_graph = m_selection.LowerGraph; string tmp = graph_level.Text.Substring(6); int level = Convert.ToInt32(tmp); graph_level.Text = "level " + Convert.ToString(level + 1); //m_selection.Name = "dc"; } m_left_down = true; } else { m_click = new Point(e.X, e.Y); NodeMenu.Show(this, m_click); } } Invalidate(); }
private void propertyGrid1_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { var selectedObj = propertyGrid1.SelectedGridItem; var mainFrm = Application.OpenForms.OfType<MainForm>().FirstOrDefault(); var contextMenu = new ContextMenu(mainFrm.GetMenuItems(selectedObj.Value.GetType())); contextMenu.Show(sender as Control, e.Location); } }
private void addAIButton_Click(object sender, EventArgs e) { var enabled = Program.TasClient.MyBattle != null; // && Program.ModStore.Ais != null && Program.ModStore.Ais.Any(); ContextMenu menu = new ContextMenu(); if (!enabled) { // TODO return; } menu.MenuItems.AddRange(ZeroKLobby.MicroLobby.ContextMenus.GetAddBotItems()); menu.Show(btnAddAI, new Point(0, 0)); }
private void bookGridView_MouseClick(Object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { ContextMenu m = new ContextMenu(); MenuItem miEdit = new MenuItem("Edit"); MenuItem miDelete = new MenuItem("Delete"); MenuItem miAdd = new MenuItem("Add"); m.MenuItems.Add(miDelete); m.MenuItems.Add(miAdd); m.MenuItems.Add(miEdit); miEdit.Click += new System.EventHandler(this.editMenuItem_Click); miAdd.Click += new System.EventHandler(this.addMenuItem_Click); miDelete.Click += new System.EventHandler(this.deleteMenuItem_Click); int currentMouseOverRow = bookGridView.HitTest(e.X, e.Y).RowIndex; m.Show(bookGridView,new Point(e.X,e.Y)); } }
private void dataGridViewAlunos_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Right) { ContextMenu m = new ContextMenu(); m.MenuItems.Add(new MenuItem("Ver")); m.MenuItems.Add(new MenuItem("Copiar")); /*int currentMouseOverRow = dataGridViewAlunos.HitTest(e.X, e.Y).RowIndex; if (currentMouseOverRow >= 0) { m.MenuItems.Add(new MenuItem(string.Format("Do something to row {0}", currentMouseOverRow.ToString()))); }*/ m.Show(dataGridViewAlunos, new Point(e.X, e.Y)); } }
private void SzBox_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { int indexOfItem; indexOfItem = SzBox.IndexFromPoint(e.X, e.Y); //(2) if (indexOfItem < SzBox.Items.Count) { SuppressChange = true; SzBox.SelectedIndex = indexOfItem; MenuItem[] Y = new MenuItem[2]; Y[0] = new MenuItem("Delete Seizure"); Y[0].Click += new System.EventHandler(DeleteSz); Y[1] = new MenuItem("Edit Notes"); ContextMenu X = new ContextMenu(Y); X.Show(SzBox, new Point(e.X, e.Y)); } } }
private void mModelTree_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Right) { var treeNode = tvwModel.GetNodeAt(e.X, e.Y); if (treeNode != null) { var controller = ((ModelObjectTreeNode)treeNode).Controller; var cm = new ContextMenu(); var commands = controller.GetMenuCommands(); if (commands != null) { foreach (var tmpMenuCommand in controller.GetMenuCommands()) { cm.MenuItems.Add(tmpMenuCommand); } } cm.Show(this, new Point(e.X, e.Y)); } } }
private void DGVProperties_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { ContextMenu m = new ContextMenu(); m.MenuItems.Add(new MenuItem("Cut")); m.MenuItems.Add(new MenuItem("Copy")); m.MenuItems.Add(new MenuItem("Paste")); m.MenuItems[0].Click += DGVProperties_Cut; int currentMouseOverRow = DGVProperties.HitTest(e.X, e.Y).RowIndex; if (currentMouseOverRow >= 0) { m.MenuItems.Add(new MenuItem(string.Format("Do something to row {0}", currentMouseOverRow.ToString()))); } m.Show(DGVProperties, new Point(e.X, e.Y)); } }
public void Click(ScreenDrawingSurface surface, Point location) { ContextMenu menu = new ContextMenu(); // find a join to modify var nearest = NearestJoin(surface, location); if (nearest != null) { string typeText = (nearest.type == JoinType.Vertical)? "Left-Right" : "Up-Down"; menu.MenuItems.Add("Modify " + typeText + " Join from " + nearest.screenOne + " to " + nearest.screenTwo, (s, e) => EditJoin(surface, nearest)); menu.MenuItems.Add("Delete " + typeText + " Join from " + nearest.screenOne + " to " + nearest.screenTwo, (s, e) => DeleteJoin(surface, nearest)); } else { if (location.X > surface.Width - surface.Screen.Tileset.TileSize) { menu.MenuItems.Add(new MenuItem("New Rightward Join from " + surface.Screen.Name, (s, e) => NewJoin(surface, surface.Screen.Name, "", JoinType.Vertical, location.Y / surface.Screen.Tileset.TileSize))); } if (location.X < surface.Screen.Tileset.TileSize) { menu.MenuItems.Add(new MenuItem("New Leftward Join from " + surface.Screen.Name, (s, e) => NewJoin(surface, "", surface.Screen.Name, JoinType.Vertical, location.Y / surface.Screen.Tileset.TileSize))); } if (location.Y > surface.Height - surface.Screen.Tileset.TileSize) { menu.MenuItems.Add(new MenuItem("New Downward Join from " + surface.Screen.Name, (s, e) => NewJoin(surface, surface.Screen.Name, "", JoinType.Horizontal, location.X / surface.Screen.Tileset.TileSize))); } if (location.Y < surface.Screen.Tileset.TileSize) { menu.MenuItems.Add(new MenuItem("New Upward Join from " + surface.Screen.Name, (s, e) => NewJoin(surface, "", surface.Screen.Name, JoinType.Horizontal, location.X / surface.Screen.Tileset.TileSize))); } } menu.Show(surface, location); }
private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.Button != MouseButtons.Right) return; if (e.RowIndex < 0 || e.ColumnIndex < 0) return; var row = dataGridView1.Rows[e.RowIndex].DataBoundItem as BreakPointEntry; breakPointEntry = row; var relativeMousePosition = dataGridView1.PointToClient(Cursor.Position); MenuItem menu = new MenuItem(row.Name); menu.Enabled = false; ContextMenu m = new ContextMenu(); m.MenuItems.Add(menu); m.MenuItems.Add(new MenuItem("Copy to &Clipboard", new EventHandler(MenuItem3_Click))); m.MenuItems.Add(new MenuItem("&Delete breakpoint", new EventHandler(MenuItem1_Click))); m.Show(dataGridView1, relativeMousePosition); }
private void CheckSuitsGrid_MouseClick(object sender, MouseEventArgs e) { switch (e.Button) { case MouseButtons.Right: ContextMenu contextMenu = new ContextMenu(); MenuItem menuItemEdit = new MenuItem("&Edit", MenuItemEdit_Click); MenuItem menuItemDelete = new MenuItem("&Delete", MenuItemDelete_Click); var hti = checkSuitsGrid.HitTest(e.X, e.Y); if (hti.RowIndex >= 0) { checkSuitsGrid.ClearSelection(); checkSuitsGrid.Rows[hti.RowIndex].Selected = true; } contextMenu.MenuItems.Add(menuItemEdit); contextMenu.MenuItems.Add(menuItemDelete); checkSuitsGrid.ContextMenu = contextMenu; contextMenu.Show(checkSuitsGrid, new Point(e.X, e.Y)); break; } }
protected override void OnMouseUp(MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Right) { cm = new ContextMenu(); cm.MenuItems.AddRange(new MenuItem[]{ new MenuItem("Add", new EventHandler(addOnClick)), new MenuItem("Rename", new EventHandler(renameOnClick)), new MenuItem("Delete", new EventHandler(deleteOnClick)) }); for (int i = 0; i < TabCount; i++) { Rectangle r = GetTabRect(i); if (r.Contains(e.Location)) { cm.Tag = i; break; } } cm.Show(this, e.Location); } base.OnMouseUp(e); }
//컨텍스트 메뉴(context menu) // 마우스 우측 버튼이 눌린 경우 실행되는 Form 재정의 메서드 protected override void OnMouseClick(MouseEventArgs e) { base.OnMouseClick(e); // 마우스 우측 버튼이 눌린 경우 if (e.Button == System.Windows.Forms.MouseButtons.Right) { // 컨텍스트 메뉴 객체를 만들고 ContextMenu ctxMenu = new ContextMenu(); // 컨텍스트 메뉴에 들어갈 2개의 MenuItem을 생성해서 추가 MenuItem menuItem = new MenuItem("새로 고침"); menuItem.Click += msRefresh_Click; ctxMenu.MenuItems.Add(menuItem); menuItem = new MenuItem("종료"); //해당 메뉴에 이벤트 처리기 연결 menuItem.Click += msClose_Click; ctxMenu.MenuItems.Add(menuItem); // 최종적으로 구성된 컨텍스트 메뉴를 마우스가 눌린 위치에서 팝업 ctxMenu.Show(this, e.Location); } }
private void MapNotification_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { ReleaseCapture(); SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0); } else if (e.Button == MouseButtons.Right) { ContextMenu contextMenu = new ContextMenu(); MenuItem reloadMenuItem = new MenuItem(); MenuItem closeMenuItem = new MenuItem(); MenuItem minimizeMenuItem = new MenuItem(); if (!mapLoaded) { // Initialize reloadMenuItem reloadMenuItem.Index = 0; reloadMenuItem.Text = "Reload"; reloadMenuItem.Click += new EventHandler(ReloadMenuItem_Click); contextMenu.MenuItems.Add(reloadMenuItem); } // Initialize closeMenuItem closeMenuItem.Index = 1; closeMenuItem.Text = "Close"; closeMenuItem.Click += new EventHandler(CloseMenuItem_Click); // Initialize minimizeMenuItem minimizeMenuItem.Index = 2; minimizeMenuItem.Text = "Minimize"; minimizeMenuItem.Click += new EventHandler(MinimizeMenuItem_Click); // Set Start and Exit as startup options. contextMenu.MenuItems.Add(closeMenuItem); contextMenu.MenuItems.Add(minimizeMenuItem); contextMenu.Show(this, e.Location); } else if (e.Button == MouseButtons.Middle) { NotificationsController.Instance.EndBattleNotification(); } }
private void richWsdl_MouseUp(object sender, MouseEventArgs e) { if (!string.IsNullOrEmpty(richWsdl.SelectedText)) { string text = richWsdl.SelectedText.Trim(); if (e.Button == MouseButtons.Right) { ContextMenu cm = new ContextMenu(); EventHandler eh1 = new EventHandler(delegate(object s, EventArgs ev) { finder(richWsdl.SelectionStart+1, text); }); cm.MenuItems.Add(new MenuItem("Find: \""+text+"\"", eh1)); EventHandler eh2 = new EventHandler(delegate(object s, EventArgs ev) { Clipboard.SetText(richWsdl.SelectedText); }); cm.MenuItems.Add(new MenuItem("Copy \"" + text + "\" to clipboard", eh2)); EventHandler eh3 = new EventHandler(delegate(object s, EventArgs ev) { textBoxFind.Text = richWsdl.SelectedText; }); cm.MenuItems.Add(new MenuItem("Copy \"" + text + "\" to find box", eh3)); cm.Show(richWsdl, e.Location); } } }
private void treeMethods_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { TreeNode nodeUnderMouse = treeMethods.GetNodeAt(e.X, e.Y); if (nodeUnderMouse != null) { ContextMenu cm = new ContextMenu(); EventHandler eh1 = new EventHandler(delegate(object s, EventArgs ev) { Clipboard.SetText(nodeUnderMouse.Text); }); cm.MenuItems.Add(new MenuItem("Copy \"" + nodeUnderMouse.Text + "\" to clipboard", eh1)); EventHandler eh2 = new EventHandler(delegate(object s, EventArgs ev) { Clipboard.SetText(createTextDesciption(null, nodeUnderMouse, 0).ToString()); }); cm.MenuItems.Add(new MenuItem("Copy all to clipboard", eh2)); EventHandler eh3 = new EventHandler(delegate(object s, EventArgs ev) { tabMain.SelectedTab = tabPageWsdl; finder(0, nodeUnderMouse.Text); }); cm.MenuItems.Add(new MenuItem("Find in WSDL: \"" + nodeUnderMouse.Text + "\"", eh3)); cm.Show(treeMethods, e.Location); } } }
private void monitorToolStripMenuItem_Click(object sender, EventArgs e) { List<MenuItem> items = new List<MenuItem>(); if (File.Exists(tn2_file())) items.Add(new MenuItem("TableNinja II", (o, args) => on_file_drop(tn2_file()))); if (File.Exists(hm2_file())) items.Add(new MenuItem("HM2", (o, args) => on_file_drop(hm2_file()))); if (File.Exists(hm3_file())) items.Add(new MenuItem("HM3", (o, args) => on_file_drop(hm3_file()))); var monitor_menu = new ContextMenu(items.ToArray()); monitor_menu.Show(this, PointToClient(Cursor.Position)); }
public override void MouseUp(MouseButtons b) { if( scroll_active ) { StopScrolling(); } parent.SetDefaultDrawingMode(); original_selected = null; switch( action ) { case MouseAction.Scroll: Cursor.Current = Cursors.Arrow; if( first_move ) { System.Windows.Forms.ContextMenu m = new ContextMenu(); parent.AddMenuItems( m ); if( m.MenuItems.Count > 0 ) m.Show( parent.cview, new Point( menurealx, menurealy ) ); } break; case MouseAction.CreateConnection: if( conn.second.item == null ) conn.Invalidate(); else { conn.ConnectionCreated( parent, null, null, null, null ); parent.Undo.Push( new CreateOperation( conn ), false ); } conn = null; break; case MouseAction.Move: ArrayList movedobjects = new ArrayList(); foreach( GuiObject o in movestates.Keys ) if( o is IAroundObject ) movedobjects.Add( o ); if( movedobjects.Count > 0 ) parent.AroundObjectsMoved( movedobjects, movestates ); foreach( IMoveable o in movestates.Keys ) o.Moved(); if( movestates.Count == 1 ) { foreach( IStateObject t in movestates.Keys ) parent.Undo.Push( new StateOperation( t, movestates[t] as ObjectState, t.GetState() ), false ); } else if( movestates.Count > 1 ) { MultipleOperation p = new MultipleOperation(); foreach( IStateObject t in movestates.Keys ) p.l.Add( new StateOperation( t, movestates[t] as ObjectState, t.GetState() ) ); parent.Undo.Push( p, false ); } movestates.Clear(); moveitem = null; movelist = null; break; case MouseAction.Select: parent.SelectedObjects.Clear(); parent.SelectInRectangle( selrect ); parent.cview.InvalidatePage( selrect ); selrect = Rectangle.Empty; break; } action = MouseAction.None; }
public override void MouseDown( int x, int y, MouseButtons b, Keys modif, int realx, int realy ) { // Left mouse button if( action != MouseAction.None ) return; if( b == MouseButtons.Left ) { if( current_operation == MouseOperation.DrawComment || current_operation == MouseOperation.DrawPackage ) { switch( current_operation ) { case MouseOperation.DrawComment: moveitem = GuiElementFactory.CreateMemo( parent, x, y ); break; case MouseOperation.DrawPackage: moveitem = GuiElementFactory.CreatePackage( parent, x, y ); break; } first_move = true; moveux = 0; moveuy = 0; action = MouseAction.Move; } else if( (modif & Keys.Control) == Keys.Control || current_operation == MouseOperation.DrawConnection ) { conn_item = parent.FindItem( x, y, out moveux, out moveuy, true ) as IAcceptConnection; if( conn_item == null ) { action = MouseAction.Scroll; selx = x; sely = y; return; } int ux; float uy; conn_item.coord_nearest( x, y, out ux, out uy ); action = MouseAction.CreateConnection; conn = new GuiConnection( new GuiConnectionPoint( conn_item, ux, uy, 0 ), new GuiConnectionPoint( x, y, 1 ), conn_type, parent, conn_type == UmlRelationType.Attachment ? GuiConnectionStyle.Line : conn_style ); conn.first.item.coord_nearest( x, y, out conn.first.ux, out conn.first.uy ); conn.first.UpdatePosition( true ); conn.DoCreationFixup(); conn.InvalidateTemporary(); conn.Invalidate(); } else if( ( modif & Keys.Shift) == Keys.Shift ) { GuiObject obj = parent.FindItem( x, y, false ); if( obj != null ) { parent.SelectedObjects.Add( obj ); obj.Invalidate(); } } else { // Left button click: // select // move, move multiple GuiObject s = parent.FindItem( x, y, out moveux, out moveuy, false ); if( s == null ) { parent.SelectedObjects.Clear(); action = MouseAction.Select; selx = x; sely = y; return; } if( !s.selected ) { parent.SelectedObjects.Clear(); parent.SelectedObjects.Add( s ); } // deciding: to move, or not ... moveitem = null; movelist = null; movestates.Clear(); original_selected = null; GuiObject t = parent.FindItem( x, y, out moveux, out moveuy, true ); if( t != null ) { if( t is IMoveRedirect ) { if( t.selected ) original_selected = t; moveitem = (t as IMoveRedirect).MoveRedirect( ref moveux, ref moveuy ); } else if( t is IMoveMultiple && (t as IMoveMultiple).CanMoveInGroup ) { movelist = new ArrayList(); if( !t.selected ) movelist.Add( t ); foreach( GuiObject o in parent.SelectedObjects ) if( o is IMoveMultiple && (o as IMoveMultiple).CanMoveInGroup ) movelist.Add( o ); selx = x; sely = y; } else if( t is IMoveable && (t as IMoveable).IsMoveable( x, y ) ) moveitem = t as IMoveable; if( moveitem != null || movelist != null ) { first_move = true; action = MouseAction.Move; } else if( t is IClickable ) { (t as IClickable).LeftClick( false, x, y ); } } } } else if( b == MouseButtons.Right ) { ISelectable obj = parent.FindItem( x, y, true ) as ISelectable; if( obj != null ) { if( obj is IDropMenu ) { parent.SelectedObjects.Clear(); parent.SelectedObjects.Add( obj as GuiObject ); System.Windows.Forms.ContextMenu m = new ContextMenu(); (obj as IDropMenu).AddMenuItems( m, x, y ); if( m.MenuItems.Count > 0 ) m.Show( parent.cview, new Point( realx, realy ) ); } } else { action = MouseAction.Scroll; Cursor.Current = Cursors.Hand; selx = x; sely = y; menurealx = realx; menurealy = realy; first_move = true; } } }
private void buttonFilter_Click(object sender, EventArgs e) { ContextMenu menu = new ContextMenu(); foreach (ColumnHeader ch in listResults.Columns) { MenuItem columnMenu = new MenuItem(ch.Text); MenuItem item; columnMenu.Tag = ch.Index; item = new MenuItem("Contains...", new EventHandler(filterMenuItem_Clicked)); item.Tag = new Matcher(delegate(string s1, string s2) { return s1.Contains(s2); }); columnMenu.MenuItems.Add(item); item = new MenuItem("Contains (case-insensitive)...", new EventHandler(filterMenuItem_Clicked)); item.Tag = new Matcher(delegate(string s1, string s2) { return s1.ToLower().Contains(s2.ToLower()); }); columnMenu.MenuItems.Add(item); item = new MenuItem("Regex...", new EventHandler(filterMenuItem_Clicked)); item.Tag = new Matcher(delegate(string s1, string s2) { try { System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(s2); return r.IsMatch(s1); } catch { return false; } }); columnMenu.MenuItems.Add(item); item = new MenuItem("Regex (case-insensitive)...", new EventHandler(filterMenuItem_Clicked)); item.Tag = new Matcher(delegate(string s1, string s2) { try { System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(s2, System.Text.RegularExpressions.RegexOptions.IgnoreCase); return r.IsMatch(s1); } catch { return false; } }); columnMenu.MenuItems.Add(item); columnMenu.MenuItems.Add(new MenuItem("-")); item = new MenuItem("Numerical relation...", new EventHandler(filterMenuItem_Clicked)); item.Tag = new Matcher(delegate(string s1, string s2) { if (s2.Contains("!=")) { decimal n1 = BaseConverter.ToNumberParse(s1); decimal n2 = BaseConverter.ToNumberParse(s2.Split(new string[] { "!=" }, StringSplitOptions.None)[1]); return n1 != n2; } else if (s2.Contains("<=")) { decimal n1 = BaseConverter.ToNumberParse(s1); decimal n2 = BaseConverter.ToNumberParse(s2.Split(new string[] { "<=" }, StringSplitOptions.None)[1]); return n1 <= n2; } else if (s2.Contains(">=")) { decimal n1 = BaseConverter.ToNumberParse(s1); decimal n2 = BaseConverter.ToNumberParse(s2.Split(new string[] { ">=" }, StringSplitOptions.None)[1]); return n1 >= n2; } else if (s2.Contains("<")) { decimal n1 = BaseConverter.ToNumberParse(s1); decimal n2 = BaseConverter.ToNumberParse(s2.Split(new string[] { "<" }, StringSplitOptions.None)[1]); return n1 < n2; } else if (s2.Contains(">")) { decimal n1 = BaseConverter.ToNumberParse(s1); decimal n2 = BaseConverter.ToNumberParse(s2.Split(new string[] { ">" }, StringSplitOptions.None)[1]); return n1 > n2; } else if (s2.Contains("=")) { decimal n1 = BaseConverter.ToNumberParse(s1); decimal n2 = BaseConverter.ToNumberParse(s2.Split(new string[] { "=" }, StringSplitOptions.None)[1]); return n1 == n2; } else { return false; } }); columnMenu.MenuItems.Add(item); menu.MenuItems.Add(columnMenu); } menu.Show(buttonFilter, new System.Drawing.Point(buttonFilter.Size.Width, 0)); }
void helpButton_MouseUp(object sender, MouseEventArgs ea) { var menu = new ContextMenu(); var joinItem = new MenuItem("Ask in the ZK channel (#zk)"); joinItem.Click += (s, e) => Program.MainWindow.navigationControl.Path = "chat/channel/zk"; menu.MenuItems.Add(joinItem); var helpForumItem = new MenuItem("Ask in the Help Forum"); helpForumItem.Click += helpForumItem_Click; menu.MenuItems.Add(helpForumItem); var adminsItem = new MenuItem("Ask an Administrator"); foreach (var admin in Program.TasClient.ExistingUsers.Values.Where(u => (u.IsAdmin)&& !u.IsBot).OrderBy(u => u.IsAway ? 1 : 0)) { var item = new MenuItem(admin.Name + (admin.IsAway ? " (Idle)" : String.Empty)); var adminName = admin.Name; item.Click += (s, e) => Program.MainWindow.navigationControl.Path = "chat/user/" + adminName; adminsItem.MenuItems.Add(item); } menu.MenuItems.Add(adminsItem); menu.Show(helpButton, ea.Location); }
private void tvwEntity_MouseUp(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Right) { var node = tvwEntity.HitTest(e.X, e.Y).Node; if (node != null) { if (node.Tag is EntityHasEntities && node.Checked) { var relation = node.Tag as EntityHasEntities; var module = _model.Modules.FirstOrDefault(x => x.Name == (string)cboModule.SelectedItem); var relationModule = _model.RelationModules.FirstOrDefault(x => x.RelationID == relation.Id && x.ModuleId == module.Id); var enforced = _relationEnforcement[relation]; var contextMenu = new ContextMenu(); var menuEnforce = new MenuItem() { Checked = enforced, Text = "Enforced", Tag = relation }; menuEnforce.Click += new EventHandler(MenuEnforce_Click); contextMenu.MenuItems.Add(menuEnforce); var menuNotEnforce = new MenuItem() { Checked = !enforced, Text = "Not Enforced", Tag = relation }; menuNotEnforce.Click += new EventHandler(MenuNotEnforce_Click); contextMenu.MenuItems.Add(menuNotEnforce); contextMenu.Show(tvwEntity, new Point(e.X, e.Y)); } } } }
// 左上角的一个label上右鼠标键popupmenu private void label_topleft_MouseUp(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Right) return; ContextMenu contextMenu = new ContextMenu(); MenuItem menuItem = null; bool bHasClipboardObject = false; IDataObject ido = Clipboard.GetDataObject(); if (ido.GetDataPresent(DataFormats.Text) == true) bHasClipboardObject = true; // menuItem = new MenuItem("后插新行(&A)"); menuItem.Click += new System.EventHandler(this.menu_appendElement_Click); contextMenu.MenuItems.Add(menuItem); // --- menuItem = new MenuItem("-"); contextMenu.MenuItems.Add(menuItem); // menuItem = new MenuItem("复制所有行(&C)"); menuItem.Click += new System.EventHandler(this.menu_copyRecord_Click); contextMenu.MenuItems.Add(menuItem); menuItem = new MenuItem("粘贴替换所有行(&P)"); menuItem.Click += new System.EventHandler(this.menu_pasteRecord_Click); if (bHasClipboardObject == true) menuItem.Enabled = true; else menuItem.Enabled = false; contextMenu.MenuItems.Add(menuItem); contextMenu.Show(this.label_topleft, new Point(e.X, e.Y)); }
void label_color_MouseUp(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Right) return; ContextMenu contextMenu = new ContextMenu(); MenuItem menuItem = null; int nSelectedCount = this.Container.SelectedIndices.Count; bool bHasClipboardObject = false; IDataObject ido = Clipboard.GetDataObject(); if (ido.GetDataPresent(DataFormats.Text) == true) bHasClipboardObject = true; // menuItem = new MenuItem("前插(&I)"); menuItem.Click += new System.EventHandler(this.menu_insertElement_Click); contextMenu.MenuItems.Add(menuItem); // menuItem = new MenuItem("后插(&A)"); menuItem.Click += new System.EventHandler(this.menu_appendElement_Click); contextMenu.MenuItems.Add(menuItem); // --- menuItem = new MenuItem("-"); contextMenu.MenuItems.Add(menuItem); // menuItem = new MenuItem("删除(&D)"); menuItem.Click += new System.EventHandler(this.menu_deleteElements_Click); contextMenu.MenuItems.Add(menuItem); // --- menuItem = new MenuItem("-"); contextMenu.MenuItems.Add(menuItem); menuItem = new MenuItem("剪切(&T)"); menuItem.Click += new System.EventHandler(this.menu_cut_Click); if (nSelectedCount > 0) menuItem.Enabled = true; else menuItem.Enabled = false; contextMenu.MenuItems.Add(menuItem); menuItem = new MenuItem("复制(&C)"); menuItem.Click += new System.EventHandler(this.menu_copy_Click); if (nSelectedCount > 0) menuItem.Enabled = true; else menuItem.Enabled = false; contextMenu.MenuItems.Add(menuItem); menuItem = new MenuItem("粘贴插入[前](&P)"); menuItem.Click += new System.EventHandler(this.menu_pasteInsert_Click); if (bHasClipboardObject == true && nSelectedCount > 0) menuItem.Enabled = true; else menuItem.Enabled = false; contextMenu.MenuItems.Add(menuItem); menuItem = new MenuItem("粘贴插入[后](&P)"); menuItem.Click += new System.EventHandler(this.menu_pasteInsertAfter_Click); if (bHasClipboardObject == true && nSelectedCount > 0) menuItem.Enabled = true; else menuItem.Enabled = false; contextMenu.MenuItems.Add(menuItem); menuItem = new MenuItem("粘贴替换(&R)"); menuItem.Click += new System.EventHandler(this.menu_pasteReplace_Click); if (bHasClipboardObject == true && nSelectedCount > 0) menuItem.Enabled = true; else menuItem.Enabled = false; contextMenu.MenuItems.Add(menuItem); // --- menuItem = new MenuItem("-"); contextMenu.MenuItems.Add(menuItem); menuItem = new MenuItem("全选(&A)"); menuItem.Click += new System.EventHandler(this.menu_selectAll_Click); contextMenu.MenuItems.Add(menuItem); contextMenu.Show(this.label_color, new Point(e.X, e.Y)); }
private void lvSharePage_MouseUp(object sender, MouseEventArgs e) { ListView lvSender = sender as ListView; if (lvSender != null && e.Button == MouseButtons.Right && lvSharePage.SelectedItems.Count == 1) { ListViewHitTestInfo hti = lvSender.HitTest(e.X, e.Y); if (hti != null && hti.Item != null) { ListViewItem lvitem = hti.Item; if (!lvitem.Selected) { lvitem.Selected = true; } ContextMenu cm = new ContextMenu(); MenuItem m_item = new MenuItem("&Properties", new EventHandler(On_MenuClick)); cm.MenuItems.Add(m_item); cm.Show(lvSender, new Point(e.X, e.Y)); } } }
private void lvTaskList_MouseDown(object sender, MouseEventArgs e) { //Check to see if this is a right-click event if (e.Button == MouseButtons.Right) { //determine which item was clicked ListViewHitTestInfo htInfo = lvTaskList.HitTest(e.Location); if (null != htInfo.Item) { //make sure the right-clicked item is selected // (right-clicking does not always select the item, which makes // usage a little clunky) htInfo.Item.Selected = true; //create the context menu and figure out which item(s) to show MenuItem enableTask; WlbScheduledTask task = TaskFromItem(htInfo.Item); ContextMenu menu = new ContextMenu(); if (task.Enabled) { enableTask = new MenuItem(Messages.DISABLE, EnableTask_Click); } else { enableTask = new MenuItem(Messages.ENABLE, EnableTask_Click); } menu.MenuItems.Add(enableTask); menu.Show(lvTaskList, e.Location); } } }
private void dataGridView1_MouseUp(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Right) return; ContextMenu contextMenu = new ContextMenu(); MenuItem menuItem = null; // --- menuItem = new MenuItem("-"); contextMenu.MenuItems.Add(menuItem); int nCount = this.dataGridView1.SelectedRows.Count; if (nCount == 0 && this.dataGridView1.CurrentRow != null) nCount = 1; menuItem = new MenuItem("删除 [" + nCount.ToString() + "] (&D)"); menuItem.Click += new System.EventHandler(this.menu_deleteSelectedRow_Click); if (nCount == 0) menuItem.Enabled = false; contextMenu.MenuItems.Add(menuItem); contextMenu.Show(this.dataGridView1, new Point(e.X, e.Y)); }
public virtual void mousePressed(System.Object event_sender, System.Windows.Forms.MouseEventArgs e) { if (event_sender == toolButtons[TOOL_SETATOM] && e.Button == MouseButtons.Middle) { //UPGRADE_ISSUE: Method 'javax.swing.AbstractButton.setSelected' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaxswingAbstractButtonsetSelected_boolean'" toolButtons[TOOL_SETATOM].Select(); // TODO: Same functionality? .setSelected(true); //UPGRADE_ISSUE: Class hierarchy differences between 'javax.swing.JPopupMenu' and 'System.Windows.Forms.ContextMenu' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1186'" System.Windows.Forms.ContextMenu popup = new System.Windows.Forms.ContextMenu(); popup.MenuItems.Add(MenuItem("C", 0)); popup.MenuItems.Add(MenuItem("N", 0)); popup.MenuItems.Add(MenuItem("O", 0)); popup.MenuItems.Add(MenuItem("H", 0)); popup.MenuItems.Add(MenuItem("F", 0)); popup.MenuItems.Add(MenuItem("Cl", 0)); popup.MenuItems.Add(MenuItem("Br", 0)); popup.MenuItems.Add(MenuItem("I", 0)); popup.MenuItems.Add(MenuItem("S", 0)); popup.MenuItems.Add(MenuItem("P", 0)); //UPGRADE_TODO: Method 'javax.swing.JPopupMenu.show' was converted to 'System.Windows.Forms.ContextMenu.Show' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaxswingJPopupMenushow_javaawtComponent_int_int'" popup.Show(toolButtons[TOOL_SETATOM], new System.Drawing.Point(0, 0)); } if (event_sender == toolButtons[TOOL_TEMPLATE] && e.Button == MouseButtons.Middle) { //UPGRADE_TODO: Method 'javax.swing.AbstractButton.getModel' was converted to 'ToolStripButtonBase' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'" SupportClass.ButtonGroupSupport.SetSelected(toolGroup, toolButtons[TOOL_TEMPLATE], true); TemplateSelect(); } }