private void ListBoxItemsMouseClick(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Right) { return; } var loc = ListBoxItems.PointToScreen(new Point(e.X, e.Y)); for (int i = 0; i < ListBoxItems.Items.Count; i++) { var rec = ListBoxItems.GetItemRectangle(i); if (rec.X <= e.X && (rec.X + rec.Width) >= e.X && rec.Y <= e.Y && (rec.Y + rec.Height) >= e.Y) { ItemContextMenu.Items[0].Enabled = true; ItemContextMenu.Items[2].Enabled = true; ItemContextMenu.Items[3].Enabled = true; ItemContextMenu.Items[4].Enabled = true; ListBoxItems.ClearSelected(); ListBoxItems.SetSelected(i, true); ItemContextMenu.Show(loc); return; } } ItemContextMenu.Items[0].Enabled = false; ItemContextMenu.Items[3].Enabled = false; ItemContextMenu.Items[4].Enabled = false; ItemContextMenu.Show(loc); }
private void dockManager1_ShowingMenu(object sender, DevExpress.Xpf.Docking.Base.ShowingMenuEventArgs e) { ItemContextMenu menu = (e.Menu as ItemContextMenu); if (menu == null) { return; } // Action 1 - Insert a new About button at the first position in the menu. BarButtonItem actionAddAboutItem = new BarButtonItem(); // Specify the position for the button via the InsertBarItemLinkAction.ItemLinkIndex attached property. InsertBarItemLinkAction.SetItemLinkIndex(actionAddAboutItem, 0); actionAddAboutItem.Content = "About..."; actionAddAboutItem.ItemClick += new ItemClickEventHandler(btnAbout_ItemClick); // Action 2 - Insert a separator InsertBarItemLinkAction actionAddSeparator = new InsertBarItemLinkAction(); actionAddSeparator.ItemLink = new BarItemLinkSeparator(); actionAddSeparator.ItemLinkIndex = 1; // Add the actions to the ActionList e.ActionList.Add(actionAddAboutItem); e.ActionList.Add(actionAddSeparator); }
public CloudContentControl(IEnumerable <UserAccount> userAccounts, IViewerFactory viewerFactory) { this.viewerFactory = viewerFactory; itemContextMenu = new ItemContextMenu(); controlContextMenu = new ControlContextMenu(); InitializeControl(); SizeChanged += (s, e) => splashScreen?.SizeChange(); driveNames = userAccounts.ToDictionary(x => x.DriveEngine, x => x.Name); cloudDriveEngines = userAccounts.Select(x => x.DriveEngine).ToList(); components = new System.ComponentModel.Container(); var resources = new System.ComponentModel.ComponentResourceManager(typeof(CloudContentControl)); foreach (var driveEngine in cloudDriveEngines) { var(listView, folderPanel) = InitializeDrivePanel(components, resources); listViews.Add(driveEngine, listView); folderPanels.Add(driveEngine, folderPanel); listViews[driveEngine].ItemActivate += ViewContentList_ItemActivate; listViews[driveEngine].MouseUp += ViewContentList_MouseUp; AddItems(driveEngine); } currentDirectory = "/"; Name = "CloudContentControl"; }
private void ResultsList_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { int index = ResultsList.IndexFromPoint(e.X, e.Y); if (index == ListBox.NoMatches) { return; } ResultsList.SelectedIndex = index; string file = m_Symbols.GetFileForSymbol((string)ResultsList.SelectedItem); GoToHeaderMenuItem.Enabled = file != null; ItemContextMenu.Show(ResultsList, e.X, e.Y); } }
private void _invokeOnItemClick(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Right || IsCurrentCellInEditMode) { return; } var hti = HitTest(e.X, e.Y); //if (Rows.Count-1 > hti.RowIndex) //index 5 clicked if (_contextMenuMode == ContextMenuDisplayMode.OnCell && hti.RowIndex != -1 && hti.ColumnIndex != -1) { ClearSelection(); Rows[hti.RowIndex].Selected = true; ItemContextMenu.Show(this, e.Location); } else if (_contextMenuMode == ContextMenuDisplayMode.Anywhere) { ItemContextMenu.Show(this, e.Location); } }
private void ThumbnailList_MouseClick(object sender, MouseEventArgs e) { bool imageClicked; int index = GetItemIndexFromCursor(e.Location, out imageClicked); if (index > -1) { if (e.Button != MouseButtons.Right) { selectedItem = index; if (imageClicked) { if (ItemImageClicked != null) { ItemImageClicked.Invoke(this, items[index]); } return; } if (ItemClicked != null) { ItemClicked.Invoke(this, items[index]); } } else { selectedItem = index; // Context Menu if (ItemContextMenu != null) { ItemContextMenu.Invoke(this, items[index]); } } } else if (addButtonHover) { if (AddNewItem != null && ShowAddButton) { AddNewItem.Invoke(this, null); } } }
public override void OnGUI(Rect rect) { if (s_Styles == null) { s_Styles = new Styles(); } Event evt = Event.current; Rect contentRect = new Rect(0, 0, 1, CalcSize().y); m_ScrollPosition = GUI.BeginScrollView(rect, m_ScrollPosition, contentRect); { float curY = 0f; for (int i = 0; i <= maxIndex; ++i) { int itemControlID = i + 1000000; Rect itemRect = new Rect(0, curY, rect.width, lineHeight); bool addSeperator = Array.IndexOf(m_SeperatorIndices, i) >= 0; // Add new preset button if (m_ShowAddNewPresetItem && i == m_ItemProvider.Count()) { CreateNewItemButton(itemRect); continue; } if (m_ShowEditWindowForIndex == i) { m_ShowEditWindowForIndex = -1; EditExistingItem(itemRect, i); } // Handle event switch (evt.type) { case EventType.Repaint: bool hover = false; if (m_HoverIndex == i) { if (itemRect.Contains(evt.mousePosition)) { hover = true; } else { m_HoverIndex = -1; } } // Overwrite if if (m_ModifyItemUI != null && m_ModifyItemUI.IsShowing()) { hover = m_ItemProvider.GetItem(i) == m_ModifyItemUI.m_Object; } s_Styles.menuItem.Draw(itemRect, GUIContent.Temp(m_ItemProvider.GetName(i)), hover, false, i == selectedIndex, false); if (addSeperator) { const float margin = 4f; Rect seperatorRect = new Rect(itemRect.x + margin, itemRect.y + itemRect.height + seperatorHeight * 0.5f, itemRect.width - 2 * margin, 1); DrawRect(seperatorRect, (EditorGUIUtility.isProSkin) ? new Color(0.32f, 0.32f, 0.32f, 1.333f) : new Color(0.6f, 0.6f, 0.6f, 1.333f)); // dark : light } // We delete presets on alt-click if (AllowDeleteClick(i)) { EditorGUIUtility.AddCursorRect(itemRect, MouseCursor.ArrowMinus); } break; case EventType.MouseDown: if (evt.button == 0 && itemRect.Contains(evt.mousePosition)) { GUIUtility.hotControl = itemControlID; if (!IsDeleteModiferPressed() && evt.clickCount == 1) { GUIUtility.hotControl = 0; SelectItem(i); editorWindow.Close(); evt.Use(); } } break; case EventType.MouseUp: if (GUIUtility.hotControl == itemControlID) { GUIUtility.hotControl = 0; if (evt.button == 0 && itemRect.Contains(evt.mousePosition)) { if (AllowDeleteClick(i)) { DeleteItem(i); evt.Use(); } } } break; case EventType.ContextClick: if (itemRect.Contains(evt.mousePosition)) { evt.Use(); if (m_ModifyItemUI != null && m_ItemProvider.IsModificationAllowed(i)) { ItemContextMenu.Show(i, this); } } break; case EventType.MouseMove: if (itemRect.Contains(evt.mousePosition)) { if (m_HoverIndex != i) { m_HoverIndex = i; Repaint(); } } else if (m_HoverIndex == i) { m_HoverIndex = -1; Repaint(); } break; } curY += lineHeight; if (addSeperator) { curY += seperatorHeight; } } // end foreach item } GUI.EndScrollView(); }