public void SetActiveItem(PopupMenuItem item) { if (popupMenu != null) { popupMenu.SelectItem(item); } }
void OnPopupMenuCustomization(object sender, DevExpress.Mobile.DataGrid.PopupMenuEventArgs e) { switch (e.MenuType) { case GridPopupMenuType.DataRow: e.Menu.Items.Clear(); PopupMenuItem item = new PopupMenuItem(); item.Caption = "Send Email"; item.Click += ItemClick; menuRowHandle = e.RowHandle; e.Menu.Items.Insert(0, item); break; case GridPopupMenuType.Header: e.Menu.Items.RemoveRange(2, 4); break; case GridPopupMenuType.TotalSummary: e.Menu.Items.RemoveAt(3); e.Menu.Items.RemoveAt(1); e.Menu.Items.RemoveAt(0); break; default: break; } }
void OnPopupMenuCustomization(object sender, DevExpress.Mobile.DataGrid.PopupMenuEventArgs e) { switch(e.MenuType) { case GridPopupMenuType.DataRow: e.Menu.Items.Clear(); PopupMenuItem item = new PopupMenuItem(); item.Caption = "Send Email"; item.Click += ItemClick; menuRowHandle = e.RowHandle; e.Menu.Items.Insert(0, item); break; case GridPopupMenuType.Header: e.Menu.Items.RemoveRange(2, 4); break; case GridPopupMenuType.TotalSummary: e.Menu.Items.RemoveAt(3); e.Menu.Items.RemoveAt(1); e.Menu.Items.RemoveAt(0); break; default: break; } }
void CreatePopupMenuItem(PopupMenuEventArgs e, string caption, EventHandler eventHandler) { PopupMenuItem item = new PopupMenuItem(); item.Caption = caption; item.Click += eventHandler; e.Menu.Items.Add(item); }
void OnFixedItemClickCore(FixedStyle style, PopupMenuItem item, EventHandler eventHandler) { item.Click -= eventHandler; if (ActiveColumn == null) { return; } ActiveColumn.FixedStyle = style; ActiveColumn = null; }
static void AddMenuItem(GenericMenu menu, PopupMenuItem item, string path, string selectedPath, Action <string> callback) { if (item.Children == null) { var currentPath = $"{path}{item.Name}"; menu.AddItem(new GUIContent(currentPath), currentPath == selectedPath, (data) => callback?.Invoke((string)data), currentPath); } else { var nextPath = $"{path}{item.Name}/"; item.Children.ForEach(i => AddMenuItem(menu, i, nextPath, selectedPath, callback)); } }
void OnPopupMenuCustomization(object sender, PopupMenuEventArgs e) { if (e.MenuType == GridPopupMenuType.DataRow) { e.Menu.Items.Clear(); PopupMenuItem itemDetail = new PopupMenuItem(); itemDetail.Caption = "lihat profil"; itemDetail.Click += ItemDetailClick; e.Menu.Items.Insert(0, itemDetail); PopupMenuItem itemDelete = new PopupMenuItem(); itemDelete.Caption = "delete"; itemDelete.Click += ItemDeleteClick; e.Menu.Items.Insert(1, itemDelete); } }
void OnPopupMenuCustomization(object sender, PopupMenuEventArgs e) { if (e.MenuType == GridPopupMenuType.DataRow) { string idValue; idValue = grid.GetCellValue(e.RowHandle, "ID").ToString(); if (!string.IsNullOrEmpty(idValue)) { _idEvento = Convert.ToInt64(idValue); } e.Menu.Items.Clear(); PopupMenuItem itemFilter = new PopupMenuItem(); itemFilter.Caption = "Ver evento"; itemFilter.Click += VerEventoClick; e.Menu.Items.Insert(0, itemFilter); } }
protected override void GenerateMenuItems() { if (IsInMultiSelectedMode) { if (SelectedItem.CollectionType != BuiltinCollectionName.Projection) { var deleteDocumentsMenuItem = new PopupMenuItem(null, string.Format(DocumentsResources.DocumentMenu_DeleteDocuments, SelectedItems.Count)); deleteDocumentsMenuItem.Click += (s, ea) => IoC.Get <DeleteDocument>().Execute(SelectedItems.Select(document => document.Id).ToList()); Menu.AddItem(deleteDocumentsMenuItem); } } else { var editDocumentMenuItem = new PopupMenuItem(null, DocumentsResources.DocumentMenu_EditDocument); editDocumentMenuItem.Click += (s, ea) => IoC.Get <EditDocument>().Execute(SelectedItem); Menu.AddItem(editDocumentMenuItem); if (SelectedItem.CollectionType == BuiltinCollectionName.Projection) { var copyProjectionMenuItem = new PopupMenuItem(null, DocumentsResources.DocumentMenu_CopyProjection); copyProjectionMenuItem.Click += (s, ea) => IoC.Get <CopyDocumentToClipboard>().Execute(SelectedItem); Menu.AddItem(copyProjectionMenuItem); } else { var copyIdMenuItem = new PopupMenuItem(null, DocumentsResources.DocumentMenu_CopyId); copyIdMenuItem.Click += (s, ea) => IoC.Get <CopyDocumentIdToClipboard>().Execute(SelectedItem.Id); Menu.AddItem(copyIdMenuItem); Menu.AddSeparator(); var deleteDocumentMenuItem = new PopupMenuItem(null, DocumentsResources.DocumentMenu_DeleteDocument); deleteDocumentMenuItem.Click += (s, ea) => IoC.Get <DeleteDocument>().Execute(SelectedItems.Select(document => document.Id).ToList()); Menu.AddItem(deleteDocumentMenuItem); } } }
public PopupMenuGump(PopupMenuData data) : base(0, 0) { CanMove = false; CanCloseWithRightClick = true; ResizePic pic = new ResizePic(0x0A3C) { Alpha = 0.25f }; Add(pic); int offsetY = 10; bool arrowAdded = false; int width = 0, height = 20; for (int i = 0; i < data.Items.Length; i++) { ref PopupMenuItem item = ref data.Items[i]; string text = ClilocLoader.Instance.GetString(item.Cliloc); ushort hue = item.Hue; if (item.ReplacedHue != 0) { uint h = HuesHelper.Color16To32(item.ReplacedHue); (byte b, byte g, byte r, byte a) = HuesHelper.GetBGRA(h); Color c = new Color(r, g, b, a); if (c.A == 0) { c.A = 0xFF; } FontsLoader.Instance.SetUseHTML(true, HuesHelper.RgbaToArgb(c.PackedValue)); } Label label = new Label(text, true, hue, font: 1) { X = 10, Y = offsetY }; FontsLoader.Instance.SetUseHTML(false); HitBox box = new HitBox(10, offsetY, label.Width, label.Height) { Tag = item.Index }; box.MouseUp += (sender, e) => { if (e.Button == MouseButtonType.Left) { HitBox l = (HitBox)sender; GameActions.ResponsePopupMenu(data.Serial, (ushort)l.Tag); Dispose(); } }; Add(box); Add(label); if ((item.Flags & 0x02) != 0 && !arrowAdded) { arrowAdded = true; // TODO: wat? Add ( new Button(0, 0x15E6, 0x15E2, 0x15E2) { X = 20, Y = offsetY } ); height += 20; } offsetY += label.Height; if (!arrowAdded) { height += label.Height; if (width < label.Width) { width = label.Width; } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (String.IsNullOrEmpty(_editor)) { throw new Exception("Editor is a required property. Be sure you set Editor=\"TextBoxName\" in the declaration of the control."); } if (FindControl(_editor) != null) { editorControl = ((Control)FindControl(_editor)).ClientID; } else { throw new Exception(String.Format("The editor with the value \"{0}\" could not be found.", _editor)); } // add the javascript this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "insertElementJS", InsertElementJS, true); // get all of the menu items List <MenuItem> menuItems = MenuItem.GetMenuItems(); StringBuilder mainMenu = new StringBuilder(); // get all the main menu parents List <string> mainMenuParents = new List <string>(); foreach (MenuItem item in menuItems) { if (!mainMenuParents.Contains(item.CommandMenu.Trim())) { mainMenuParents.Add(item.CommandMenu.Trim()); } } // build the menu mainMenu.Append("<ul class=\"MenuHeader\">"); // create a new popupmenu for each menu parent and populate it's children foreach (string mainMenuParent in mainMenuParents) { PopupMenu menu = new PopupMenu(); menu.ID = "mnu" + mainMenuParent; menu.CloseOnMouseOut = true; menu.MenuGroupCssClass = "MenuGroup"; menu.MenuItemCssClass = "MenuItem"; menu.MenuItemSelectedCssClass = "MenuItemSelected"; menu.MenuItemExpandedCssClass = "MenuItemSelected"; List <MenuItem> thisMenuItems = menuItems.FindAll( delegate(MenuItem mi) { return(mi.CommandMenu.Trim() == mainMenuParent); }); foreach (MenuItem mi in thisMenuItems) { PopupMenuItem popupItem = new PopupMenuItem(); popupItem.Text = "<span title=\"" + mi.Description + "\">" + mi.Name + "</span>"; popupItem.OnClickClientFunction = "new Function ('SetText(\\'" + editorControl + "\\', \\'" + mi.Command + "\\')')"; menu.MenuItems.Add(popupItem); } Controls.Add(menu); mainMenu.Append(String.Format("<li><a onmouseover=\"{0}.OpenAtElement(this);\">{1}</a></li>", menu.ClientID, mainMenuParent)); } mainMenu.Append("</ul>"); mainMenuUL = mainMenu.ToString(); }
public void ClearSelection() { this.selectedItem = null; this.gameObject.GetComponentsInChildren <PopupMenuItem>().ToList().ForEach(x => x.DeselectItem()); }
public void SelectItem(PopupMenuItem item) { this.selectedItem = item; }
/// <summary> /// Called when the template's tree is generated. /// </summary> //public override void OnApplyTemplate() //{ // base.OnApplyTemplate(); // OverlayPopup = GetTemplateChild("OverlayPopup") as Popup; // OverlayCanvas = GetTemplateChild("OverlayCanvas") as Canvas; // //ContentRoot = GetTemplateChild("ContentRoot") as Grid; //} void PopupMenu_LayoutUpdated(object sender, EventArgs e) { this.LayoutUpdated -= PopupMenu_LayoutUpdated; if (!DesignerProperties.IsInDesignTool) { if (this.Parent is PopupMenuItem) ParentPopupMenuItem = this.Parent as PopupMenuItem; AddOverlayCanvasEventHandlers(); if (!string.IsNullOrEmpty(AccessKeyElementName)) AccessKeyElement = PopupMenuUtils.FindApplicationElementByName(AccessKeyElementName, "shortcut key"); // If the parent element is a PopupMenuItem then show the menu on the right, disable its 'close on click' behavior and set the parent as the hover trigger if (ParentPopupMenuItem != null) { Orientation = MenuOrientationTypes.Right; ParentPopupMenuItem.CloseOnClick = false; AddTrigger(TriggerTypes.Hover, ParentPopupMenuItem); } // Delay mouse event assignments as far as possible using the MouseMove event to be sure the specified controls have been instanciated AddMarkupAssignedMouseTriggers(); // Add keyboard navigation triggers if (!PopupMenuManager.KeyboardCaptureOn) // Make sure this is called only once { PopupMenuManager.KeyboardCaptureOn = true; var rootVisual = Application.Current.RootVisual as FrameworkElement; rootVisual.KeyDown += PopupMenuManager.AppRoot_KeyDown; rootVisual.KeyUp += PopupMenuManager.AppRoot_KeyUp; } ItemsControl.KeyUp += ItemsControl_KeyUp; } if (!PreserveItemContainerStyle && ItemsControl is ListBox) { ListBox lb = (ItemsControl as ListBox); // If the ItemContainerStyle has a value then clone it for modification(as it cannot be modified directly) else create a new one Style style = lb.ItemContainerStyle != null ? new Style().BasedOn = lb.ItemContainerStyle : new Style(typeof(ListBoxItem)); // Add a 'HorizontalContentAlignment = Stretch' setter if its not already there(note that "3" is the string value for HorizontalAlignment.Stretch) Setter setter = PopupMenuUtils.GetStyleSetter(style, ContentControl.HorizontalContentAlignmentProperty); if (setter == null || setter.Value.ToString() != "3") { setter = new Setter(ListBoxItem.HorizontalContentAlignmentProperty, HorizontalAlignment.Stretch); style.Setters.Add(setter); lb.ItemContainerStyle = style; // Add the horizontal stretch style to the listbox items } } }
public PopupMenuGump(PopupMenuData data) : base(0, 0) { CanMove = false; CanCloseWithRightClick = true; _data = data; ResizePic pic = new ResizePic(0x0A3C) { Alpha = 0.75f }; Add(pic); int offsetY = 10; bool arrowAdded = false; int width = 0, height = 20; for (int i = 0; i < data.Items.Length; i++) { ref PopupMenuItem item = ref data.Items[i]; string text = ClilocLoader.Instance.GetString(item.Cliloc); ushort hue = item.Hue; if (item.ReplacedHue != 0) { uint h = (HuesHelper.Color16To32(item.ReplacedHue) << 8) | 0xFF; FontsLoader.Instance.SetUseHTML(true, h); } Label label = new Label(text, true, hue, font: 1) { X = 10, Y = offsetY }; FontsLoader.Instance.SetUseHTML(false); HitBox box = new HitBox(10, offsetY, label.Width, label.Height) { Tag = item.Index }; box.MouseEnter += (sender, e) => { _selectedItem = (ushort)(sender as HitBox).Tag; }; Add(box); Add(label); if ((item.Flags & 0x02) != 0 && !arrowAdded) { arrowAdded = true; // TODO: wat? Add ( new Button(0, 0x15E6, 0x15E2, 0x15E2) { X = 20, Y = offsetY } ); height += 20; } offsetY += label.Height; if (!arrowAdded) { height += label.Height; if (width < label.Width) { width = label.Width; } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if(String.IsNullOrEmpty(_editor)) throw new Exception("Editor is a required property. Be sure you set Editor=\"TextBoxName\" in the declaration of the control."); if (FindControl(_editor) != null) editorControl = ((Control)FindControl(_editor)).ClientID; else throw new Exception(String.Format("The editor with the value \"{0}\" could not be found.", _editor)); // add the javascript this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "insertElementJS", InsertElementJS, true); // get all of the menu items List<MenuItem> menuItems = MenuItem.GetMenuItems(); StringBuilder mainMenu = new StringBuilder(); // get all the main menu parents List<string> mainMenuParents = new List<string>(); foreach (MenuItem item in menuItems) { if (!mainMenuParents.Contains(item.CommandMenu.Trim())) mainMenuParents.Add(item.CommandMenu.Trim()); } // build the menu mainMenu.Append("<ul class=\"MenuHeader\">"); // create a new popupmenu for each menu parent and populate it's children foreach (string mainMenuParent in mainMenuParents) { PopupMenu menu = new PopupMenu(); menu.ID = "mnu" + mainMenuParent; menu.CloseOnMouseOut = true; menu.MenuGroupCssClass = "MenuGroup"; menu.MenuItemCssClass = "MenuItem"; menu.MenuItemSelectedCssClass = "MenuItemSelected"; menu.MenuItemExpandedCssClass = "MenuItemSelected"; List<MenuItem> thisMenuItems = menuItems.FindAll( delegate(MenuItem mi) { return mi.CommandMenu.Trim() == mainMenuParent; }); foreach (MenuItem mi in thisMenuItems) { PopupMenuItem popupItem = new PopupMenuItem(); popupItem.Text = "<span title=\"" + mi.Description + "\">" + mi.Name + "</span>"; popupItem.OnClickClientFunction = "new Function ('SetText(\\'" + editorControl + "\\', \\'" + mi.Command + "\\')')"; menu.MenuItems.Add(popupItem); } Controls.Add(menu); mainMenu.Append(String.Format("<li><a onmouseover=\"{0}.OpenAtElement(this);\">{1}</a></li>", menu.ClientID, mainMenuParent)); } mainMenu.Append("</ul>"); mainMenuUL = mainMenu.ToString(); }