private Virtualtray() { _virtualbox = (IVirtualBox) new VirtualBox.VirtualBox(); /* the generated VirtualBox.dll COM library doesn't work with the C# event * system, so we handle events by registering callbacks */ _virtualbox.RegisterCallback(this); _icon = GetIcon("icon/icon-16.ico"); _idleIcon = GetIcon("icon/icon-gray-16.ico"); _notifyIcon = new NotifyIcon(); _notifyIcon.Icon = _idleIcon; _notifyIcon.Text = "Virtualtray"; _notifyIcon.Visible = true; _vms = new Hashtable(); ContextMenu menu = new ContextMenu(); foreach (IMachine machine in _virtualbox.Machines) { MachineMenu mm = new MachineMenu(machine, menu); mm.StateChange += new EventHandler(MachineStateChangeEventHandler); _vms.Add(machine.Id, mm); } menu.MenuItems.Add(new MenuItem("-") {Name = "-"}); menu.MenuItems.Add(new MenuItem("Open VirtualBox...", new EventHandler( MenuLaunchVirtualBoxEventHandler))); menu.MenuItems.Add(new MenuItem("Exit", new EventHandler(MenuExitEventHandler))); _notifyIcon.ContextMenu = menu; ToggleIcon(); _notifyIcon.MouseClick += new MouseEventHandler(IconClickEventHandler); Application.ApplicationExit += new EventHandler(ApplicationExitEventHandler); }
Inline CreateBaseLink(string content, string contextHeader, string contextTag, MenuItem customButton = null) { var link = new HyperlinkButton { Content = content, FontSize = Text.FontSize, FontWeight = Text.FontWeight, FontStretch = Text.FontStretch, FontFamily = Text.FontFamily, TargetName = contextTag, Margin = new Thickness(-10, -5, -10, -8) }; link.Click += new RoutedEventHandler(link_Click); MenuItem item = new MenuItem { Header = contextHeader, Tag = contextTag, Foreground = new SolidColorBrush(Colors.Black) }; item.Click += new RoutedEventHandler(CopyLink); ContextMenu menu = new ContextMenu(); menu.Items.Add(item); if (customButton != null) menu.Items.Add(customButton); ContextMenuService.SetContextMenu(link, menu); InlineUIContainer container = new InlineUIContainer(); container.Child = link; return container; }
/// <summary> /// Display the popup menu for this row /// </summary> /// <param name="parent">The parent control</param> /// <param name="x">X coordinate of menu</param> /// <param name="y">Y coordinate of menu</param> public void PopupMenu( System.Windows.Forms.Control parent , int x , int y ) { // Use reflection to get the list of popup menu commands MemberInfo[] members = this.GetType().FindMembers ( MemberTypes.Method , BindingFlags.Public | BindingFlags.Instance , new System.Reflection.MemberFilter ( Filter ) , null ) ; if ( members.Length > 0 ) { // Create a context menu ContextMenu menu = new ContextMenu ( ) ; // Now loop through those members and generate the popup menu // Note the cast to MethodInfo in the foreach foreach ( MethodInfo meth in members ) { // Get the caption for the operation from the ContextMenuAttribute ContextMenuAttribute[] ctx = (ContextMenuAttribute[]) meth.GetCustomAttributes ( typeof ( ContextMenuAttribute ) , true ) ; MenuCommand callback = new MenuCommand ( this , meth ) ; MenuItem item = new MenuItem ( ctx[0].Caption , new EventHandler ( callback.Execute ) ) ; item.DefaultItem = ctx[0].Default ; menu.MenuItems.Add ( item ) ; } System.Drawing.Point pt = new System.Drawing.Point ( x , y ) ; menu.Show ( parent , pt ) ; } }
public MainWindow() : base(Gtk.WindowType.Toplevel) { oXbmc = new XBMC_Communicator(); oXbmc.SetIp("10.0.0.5"); oXbmc.SetConnectionTimeout(4000); oXbmc.SetCredentials("", ""); oXbmc.Status.StartHeartBeat(); Build (); this.AllowStaticAccess(); //Create objects used oPlaylist = new Playlist(this); oControls = new Controls(this); oMenuItems = new MenuItems(this); oContextMenu = new ContextMenu(this); oShareBrowser = new ShareBrowser(this); oTrayicon = new SysTrayIcon(this); oStatusUpdate = new StatusUpdate(this); oMediaInfo = new MediaInfo(this); oNowPlaying = new NowPlaying(this); oGuiConfig = new GuiConfig(this); nbDataContainer.CurrentPage = 0; }
public void Execute(TabbedExplorerPresenter tabbedExplorerPresenter) { // Open test.apsimx in a tab tabbedExplorerPresenter.OpenApsimXFileInTab(@"..\Tests\Test.apsimx"); // Get the presenter for this tab. ExplorerPresenter presenter = tabbedExplorerPresenter.Presenters[0]; // Select the field model. presenter.SelectNode(".Simulations.Test"); // Copy the simulation model. ContextMenu menu = new ContextMenu(presenter); menu.OnCopyClick(null, null); // Select the top model presenter.SelectNode(".Simulations"); // Paste the model. menu.OnPasteClick(null, null); // Make sure the paste has worked by clicking on a child. presenter.SelectNode(".Simulations.Test1.Clock"); // Make sure the parenting of children has worked correctly. Clock clock = Apsim.Get(presenter.ApsimXFile, ".Simulations.Test1.Clock") as Clock; if (clock.Parent == null) throw new Exception("Parenting of models after copy/paste hasn't worked"); // Close the user interface. tabbedExplorerPresenter.Close(false); }
private void AddContextMenuIfDoesNotExist(ContextMenu contextMenu) { if (!this.menuItems.ContainsKey(contextMenu)) { this.menuItems.Add(contextMenu, new RadContextMenu()); } }
public MainForm () { // // _contextMenu // _contextMenu = new ContextMenu (); _contextMenu.MenuItems.Add (new MenuItem ("Close")); // // _customControl // _customControl = new CustomControl (); _customControl.Dock = DockStyle.Fill; _customControl.BackColor = Color.LightBlue; _customControl.ContextMenu = _contextMenu; Controls.Add (_customControl); // // _listBox // _listBox = new ListBox (); _listBox.Dock = DockStyle.Bottom; _listBox.Height = 150; _customControl.ListBox = _listBox; Controls.Add (_listBox); // // MainForm // ClientSize = new Size (300, 200); Location = new Point (250, 100); StartPosition = FormStartPosition.Manual; Text = "bug #325535"; Load += new EventHandler (MainForm_Load); }
public MainForm () { // // _contextMenu // _contextMenu = new ContextMenu (); // // _notifyIcon // _notifyIcon = new NotifyIcon (); _notifyIcon.ContextMenu = _contextMenu; _notifyIcon.Click += new EventHandler (NotifyIcon_Click); // // _bringToFrontMenuItem // _bringToFrontMenuItem = new MenuItem (); _bringToFrontMenuItem.Text = "Bring to front..."; _bringToFrontMenuItem.Click += new EventHandler (BringToFrontMenuItem_Click); _contextMenu.MenuItems.Add (_bringToFrontMenuItem); // // _activateMenuItem // _activateMenuItem = new MenuItem (); _activateMenuItem.Text = "Activate..."; _activateMenuItem.Click += new EventHandler (ActivateMenuItem_Click); _contextMenu.MenuItems.Add (_activateMenuItem); // // _tabControl // _tabControl = new TabControl (); _tabControl.Dock = DockStyle.Fill; Controls.Add (_tabControl); // // _bugDescriptionText1 // _bugDescriptionText1 = new TextBox (); _bugDescriptionText1.Dock = DockStyle.Fill; _bugDescriptionText1.Multiline = true; _bugDescriptionText1.Text = string.Format (CultureInfo.InvariantCulture, "Steps to execute:{0}{0}" + "1. Right-click the notify icon.{0}{0}" + "2. Click any of the menu items in the context menu.{0}{0}" + "Expected result:{0}{0}" + "1. The form is closed after the menu item is clicked.", Environment.NewLine); // // _tabPage1 // _tabPage1 = new TabPage (); _tabPage1.Text = "#1"; _tabPage1.Controls.Add (_bugDescriptionText1); _tabControl.Controls.Add (_tabPage1); // // MainForm // ClientSize = new Size (300, 170); StartPosition = FormStartPosition.CenterScreen; Text = "bug #82162"; Load += new EventHandler (MainForm_Load); }
public MainForm () { // // ContextMenu // ContextMenu = new ContextMenu (); ContextMenu.MenuItems.Add (new MenuItem ("Format1")); ContextMenu.MenuItems.Add (new MenuItem ("Format2")); ContextMenu.MenuItems.Add (new MenuItem ("Format3")); ContextMenu.MenuItems.Add (new MenuItem ("Format4")); ContextMenu.MenuItems.Add (new MenuItem ("Format5")); ContextMenu.MenuItems.Add (new MenuItem ("Format6")); ContextMenu.MenuItems.Add (new MenuItem ("Format7")); ContextMenu.MenuItems.Add (new MenuItem ("Format8")); ContextMenu.MenuItems.Add (new MenuItem ("Format9")); ContextMenu.MenuItems.Add (new MenuItem ("Format10")); ContextMenu.MenuItems.Add (new MenuItem ("-")); ContextMenu.MenuItems.Add (new MenuItem ("Format11")); ContextMenu.MenuItems.Add (new MenuItem ("Format12")); ContextMenu.MenuItems.Add (new MenuItem ("Format13")); ContextMenu.MenuItems.Add (new MenuItem ("Format14")); ContextMenu.MenuItems.Add (new MenuItem ("Format15")); ContextMenu.MenuItems.Add (new MenuItem ("Format15")); ContextMenu.MenuItems.Add (new MenuItem ("Format16")); ContextMenu.MenuItems.Add (new MenuItem ("Format17")); ContextMenu.MenuItems.Add (new MenuItem ("Format18")); ContextMenu.MenuItems.Add (new MenuItem ("Format19")); ContextMenu.MenuItems.Add (new MenuItem ("Format20")); ContextMenu.MenuItems.Add (new MenuItem ("-")); ContextMenu.MenuItems.Add (new MenuItem ("Format21")); ContextMenu.MenuItems.Add (new MenuItem ("Format22")); ContextMenu.MenuItems.Add (new MenuItem ("Format23")); ContextMenu.MenuItems.Add (new MenuItem ("Format24")); ContextMenu.MenuItems.Add (new MenuItem ("Format25")); ContextMenu.MenuItems.Add (new MenuItem ("Format26")); ContextMenu.MenuItems.Add (new MenuItem ("Format27")); ContextMenu.MenuItems.Add (new MenuItem ("Format28")); ContextMenu.MenuItems.Add (new MenuItem ("Format29")); ContextMenu.MenuItems.Add (new MenuItem ("Format30")); ContextMenu.MenuItems.Add (new MenuItem ("-")); ContextMenu.MenuItems.Add (new MenuItem ("Format31")); ContextMenu.MenuItems.Add (new MenuItem ("Format32")); ContextMenu.MenuItems.Add (new MenuItem ("Format33")); ContextMenu.MenuItems.Add (new MenuItem ("Format34")); ContextMenu.MenuItems.Add (new MenuItem ("Format35")); ContextMenu.MenuItems.Add (new MenuItem ("Format36")); ContextMenu.MenuItems.Add (new MenuItem ("Format37")); ContextMenu.MenuItems.Add (new MenuItem ("Format38")); ContextMenu.MenuItems.Add (new MenuItem ("Format39")); ContextMenu.MenuItems.Add (new MenuItem ("Format40")); // // MainForm // Location = new Point (250, 100); Size = new Size (300, 100); StartPosition = FormStartPosition.Manual; Text = "bug #82349"; Load += new EventHandler (MainForm_Load); }
public override void Execute(CommandContext context) { SheerResponse.DisableOutput(); var subMenu = new ContextMenu(); var menuItems = new List<Control>(); var menuItemId = "iseSettingsDropdown"; //context.Parameters["Id"]; if (string.IsNullOrEmpty(menuItemId)) { // a bit of a hacky way to determine the caller so we can display the menu // in proximity to the triggering control var parameters = new UrlString("?" + Context.Items["SC_FORM"]); menuItemId = parameters.Parameters["__EVENTTARGET"]; } var menuRootItem = Factory.GetDatabase("core") .GetItem("/sitecore/content/Applications/PowerShell/PowerShellIse/Menus/Settings"); GetMenuItems(menuItems, menuRootItem); foreach (var item in menuItems) { var menuItem = item as MenuItem; if (menuItem != null) { var subItem = subMenu.Add(menuItem.ID, menuItem.Header, menuItem.Icon, menuItem.Hotkey, menuItem.Click, menuItem.Checked, menuItem.Radiogroup, menuItem.Type); subItem.Disabled = menuItem.Disabled; } } SheerResponse.EnableOutput(); subMenu.Visible = true; SheerResponse.ShowContextMenu(menuItemId, "down", subMenu); }
public override void Execute(CommandContext context) { SheerResponse.DisableOutput(); var subMenu = new ContextMenu(); var menuItems = new List<Control>(); string menuItemId = context.Parameters["menuItemId"]; Item contextItem = context.Items.Length == 1 ? context.Items[0] : string.IsNullOrEmpty(context.Parameters["db"]) || string.IsNullOrEmpty(context.Parameters["id"]) ? null : Database.GetDatabase(context.Parameters["db"]).GetItem(new ID(context.Parameters["id"])); GetLibraryMenuItems(contextItem, menuItems, context.Parameters["scriptDB"], context.Parameters["scriptPath"]); foreach (Control item in menuItems) { var menuItem = item as MenuItem; if (menuItem != null) { var subItem = subMenu.Add(menuItem.ID, menuItem.Header, menuItem.Icon, menuItem.Hotkey, menuItem.Click, menuItem.Checked, menuItem.Radiogroup, menuItem.Type); subItem.Disabled = menuItem.Disabled; } } SheerResponse.EnableOutput(); subMenu.Visible = true; SheerResponse.ShowContextMenu(menuItemId, "right", subMenu); }
private void btnRecord_Click( object sender, EventArgs e ) { StopwatchListItem item = new StopwatchListItem (); item.SetValue ( TiltEffect.IsTiltEnabledProperty, true ); item.Number = String.Format ( "{0:00}", lstRecord.Items.Count + 1 ); item.Hour = txtHour.Text; item.Minute = txtMinute.Text; item.Second = txtSecond.Text; item.Millisecond = txtMillisec.Text; ContextMenu menu = new ContextMenu (); MenuItem menuItem = new MenuItem () { Header = "삭제" }; menuItem.Tap += ( object s, System.Windows.Input.GestureEventArgs ee ) => { if ( MessageBox.Show ( "이 기록을 삭제하시겠습니까?\n이 기록보다 뒤의 순위가 있어도 순위가 변경되지는 않습니다.", "스톱워치", MessageBoxButton.OKCancel ) == MessageBoxResult.OK ) { lstRecord.Items.Remove ( item ); } }; menu.Items.Add ( menuItem ); ContextMenuService.SetContextMenu ( item, menu ); lstRecord.Items.Insert ( 0, item ); }
public OldContextMenu() { this.Text = "Menu 예제. 닷넷 1.x 형태"; ContextMenu menu = new ContextMenu(); this.ContextMenu = menu; MenuItem country = new MenuItem("&국가"); menu.MenuItems.Add(country); MenuItem korea = new MenuItem(); korea.Text = "&대한민국"; korea.Click += new EventHandler(MenuEvent); korea.Shortcut = Shortcut.CtrlK; country.MenuItems.Add(korea); MenuItem canada = new MenuItem("&캐나다", new EventHandler(MenuEvent), Shortcut.CtrlC); country.MenuItems.Add(canada); MenuItem france = new MenuItem("&프랑스", new EventHandler(MenuEvent), Shortcut.CtrlF); country.MenuItems.Add(france); MenuItem sep = new MenuItem("-"); menu.MenuItems.Add(sep); MenuItem coninent = new MenuItem("대륙"); menu.MenuItems.Add(coninent); MenuItem asia = new MenuItem("&아시아", new EventHandler(MenuEvent), Shortcut.Alt1); coninent.MenuItems.Add(asia); MenuItem euro = new MenuItem("유&럽", new EventHandler(MenuEvent), Shortcut.Alt2); coninent.MenuItems.Add(euro); }
public void InitializeComponent() { //text text = new TextBox(); text.Name = "textBox1"; text.Location = new Point(0, 50); text.Size = new Size(120, 30); //text text1 = new TextBox(); text1.Name = "text1Box1"; text1.Location = new Point(0, 80); text1.Size = new Size(120, 30); //context menu ContextMenu textcon = new ContextMenu(); text.ContextMenu = textcon; text1.ContextMenu = textcon; MenuItem item1 = new MenuItem(); MenuItem item2 = new MenuItem(); MenuItem item3 = new MenuItem(); item1.Text = "&Copy"; item2.Text = "&Paste"; item3.Text = "&Delete"; item1.Click += new EventHandler(CopyMenuItem1_Clicked); item2.Click += new EventHandler(CopyMenuItem2_Clicked); item3.Click += new EventHandler(CopyMenuItem3_Clicked); textcon.MenuItems.Add(item1); textcon.MenuItems.Add(item2); textcon.MenuItems.Add(item3); ContextMenu con = new ContextMenu(); this.ContextMenu = con; // con += new EventHandler(contextMenuClicked); MenuItem menu1 = new MenuItem(); MenuItem menu2 = new MenuItem(); MenuItem close = new MenuItem(); menu1.Click += new EventHandler(menu1ItemClicked); menu2.Click += new EventHandler(menu2ItemClicked); close.Click += new EventHandler(menu3ItemClicked); menu1.Text = "&Add"; menu2.Text = "&Delete"; close.Text = "&Close"; con.MenuItems.Add(menu1); con.MenuItems.Add(menu2); con.MenuItems.Add(close); this.Text = "This is Clip box example"; this.Name = "Form1"; this.Controls.Add(text); this.Controls.Add(text1); }
/// <summary> /// Sets the value of the ContextMenu property of the specified object. /// </summary> /// <param name="element">Object to set the property on.</param> /// <param name="value">Value to set.</param> public static void SetContextMenu(DependencyObject element, ContextMenu value) { if (element == null) { throw new ArgumentNullException("element"); } element.SetValue(ContextMenuProperty, value); }
public GTrello(ContextMenu menustrip, NotifyIcon icon) { menu = menustrip; app = icon; isUpdating = false; InitMenu(); InitIcon(); Initialized = InitServices(); }
void MainForm_Load (object sender, EventArgs e) { InstructionsForm instructionsForm = new InstructionsForm (); instructionsForm.Show (); ContextMenu context = new ContextMenu (); context.MenuItems.Add (new MenuItem ("&Close")); _propertyGrid.ContextMenu = context; _propertyGrid.SelectedObject = new Config (); }
//========================================================================== public static void Main(string[] astrArg) { ContextMenu cm; MenuItem miCurr; int iIndex = 0; string status = "running"; // Kontextmenü erzeugen cm = new ContextMenu(); // Kontextmenüeinträge erzeugen miCurr = new MenuItem(); miCurr.Index = iIndex++; miCurr.Text = "&Aktion 1"; // Eigenen Text einsetzen miCurr.Click += new System.EventHandler(Action1Click); cm.MenuItems.Add(miCurr); // Kontextmenüeinträge erzeugen miCurr = new MenuItem(); miCurr.Index = iIndex++; miCurr.Text = "&Beenden"; miCurr.Click += new System.EventHandler(ExitClick); cm.MenuItems.Add(miCurr); // NotifyIcon selbst erzeugen notico = new NotifyIcon(); notico.Icon = new Icon("git.ico"); // Eigenes Icon einsetzen notico.Text = "OVEye-Server | "+ status; // Eigenen Text einsetzen notico.Visible = true; notico.ContextMenu = cm; Console.WriteLine("Erstelle Server"); Server x = new Server(); database y = new database(); //Erstellt Thread prüfen = new Thread(delegate() { y.renewActiveConnections(x.clientList); }); // Ohne Appplication.Run geht es nicht Application.Run(); }
/// <summary> /// Default constructor /// </summary> public BackstageTabControl() { this.Loaded += this.OnLoaded; this.Unloaded += this.OnUnloaded; // Fixed incoreect menu showing ContextMenu = new ContextMenu { Width = 0, Height = 0, HasDropShadow = false }; ContextMenu.Opened += delegate { ContextMenu.IsOpen = false; }; }
public override void Execute(CommandContext context) { SheerResponse.DisableOutput(); var subMenu = new ContextMenu(); var menuItems = new List<Control>(); var menuItemId = context.Parameters["menuItemId"]; if (string.IsNullOrEmpty(menuItemId)) { // a bit of a hacky way to determine the caller so we can display the menu // in proximity to the triggering control var parameters = new UrlString("?" + Context.Items["SC_FORM"]); menuItemId = parameters.Parameters["__EVENTTARGET"]; } SetupIntegrationPoint(context); var contextItem = context.Items.Length == 1 ? context.Items[0] : string.IsNullOrEmpty(context.Parameters["db"]) || string.IsNullOrEmpty(context.Parameters["id"]) ? null : Database.GetDatabase(context.Parameters["db"]).GetItem(new ID(context.Parameters["id"])); if (string.IsNullOrEmpty(IntegrationPoint)) { var submenu = Factory.GetDatabase(context.Parameters["scriptDB"]).GetItem(context.Parameters["scriptPath"]); GetLibraryMenuItems(contextItem, menuItems, submenu); } else { foreach (var root in ModuleManager.GetFeatureRoots(IntegrationPoint)) { GetLibraryMenuItems(contextItem, menuItems, root); } } foreach (var item in menuItems) { var menuItem = item as MenuItem; if (menuItem != null) { var subItem = subMenu.Add(menuItem.ID, menuItem.Header, menuItem.Icon, menuItem.Hotkey, menuItem.Click, menuItem.Checked, menuItem.Radiogroup, menuItem.Type); subItem.Disabled = menuItem.Disabled; } } SheerResponse.EnableOutput(); subMenu.Visible = true; SheerResponse.ShowContextMenu(menuItemId, "right", subMenu); }
public static ContextMenu ToContextMenu(this IContextMenu source, ContextMenu menu) { menu.Items.Clear(); foreach(var item in source.Items) { MenuItem contextmenuItem = new MenuItem(); contextmenuItem.Header = item.Header; contextmenuItem.Command = item.Command; contextmenuItem.CommandParameter = item.CommandParameter; menu.Items.Add(contextmenuItem); } return menu; }
public void AddMenuItem(ContextMenu contextMenu, string parentMenuItemText, RadMenuItem menuItem) { if (!this.menuItems.ContainsKey(contextMenu)) { return; } var item = this.menuItems[contextMenu].FindItemByText(parentMenuItemText); if (item == null) { return; } item.Items.Add(menuItem); }
public ChatBubble() { // Create context menu ContextMenu menu = new ContextMenu(); menu.IsZoomEnabled = false; MenuItem copy = new MenuItem(); copy.Header = "copy"; copy.Click += (s, e) => { System.Windows.Clipboard.SetText(Text); }; menu.Items.Add(copy); ContextMenuService.SetContextMenu(this, menu); }
private ContextMenu CreateSymbolContextMenu(string Symbol) { ContextMenu ContextMenu = new ContextMenu(); // Add "edit" entry MenuItem menuItem = new MenuItem() { Header = "delete", Tag = "delete", }; menuItem.Click += new RoutedEventHandler(this._DeleteSymbolClicked); menuItem.Tag = Symbol; ContextMenu.Items.Add(menuItem); return ContextMenu; }
public SmartImage() { InitializeComponent(); SizeChanged += (o, e) => SmartImageSizeChanged(e.NewSize); ImageHolder.DataContext = this; #if S1Nyan var menu = new ContextMenu(); menu.BorderBrush = (SolidColorBrush)Application.Current.Resources["PhoneBorderBrush"]; menu.Background = (SolidColorBrush)Application.Current.Resources["PhoneForegroundBrush"]; var menuItem = new MenuItem(); menuItem.Header = AppResources.ImageShowInBrowser; menuItem.Click += OpenInBrowser; menu.ItemsSource = new List<MenuItem> { menuItem }; MenuHolder.SetValue(ContextMenuService.ContextMenuProperty, menu); #endif Unloaded += OnUnload; }
public ThreadsPad() { var res = new CommonResources(); res.InitializeComponent(); ContextMenu contextMenu = new ContextMenu(); contextMenu.Opened += FillContextMenuStrip; listView = new ListView(); listView.View = (GridView)res["threadsGridView"]; listView.ContextMenu = contextMenu; listView.MouseDoubleClick += listView_MouseDoubleClick; listView.SetValue(GridViewColumnAutoSize.AutoWidthProperty, "70;100%;75;75"); WindowsDebugger.RefreshingPads += RefreshPad; RefreshPad(); }
public DockNotebook () { pagesCol = new ReadOnlyCollection<DockNotebookTab> (pages); AddEvents ((Int32)(EventMask.AllEventsMask)); tabStrip = new TabStrip (this); PackStart (tabStrip, false, false, 0); contentBox = new EventBox (); PackStart (contentBox, true, true, 0); ShowAll (); contentBox.NoShowAll = true; tabStrip.DropDownButton.Sensitive = false; tabStrip.DropDownButton.ContextMenuRequested = delegate { ContextMenu menu = new ContextMenu (); foreach (var tab in pages) { var item = new ContextMenuItem (tab.Markup ?? tab.Text); var locTab = tab; item.Clicked += (object sender, ContextMenuItemClickedEventArgs e) => { CurrentTab = locTab; }; menu.Items.Add (item); } return menu; }; Gtk.Drag.DestSet (this, Gtk.DestDefaults.Motion | Gtk.DestDefaults.Highlight | Gtk.DestDefaults.Drop, targetEntryTypes, Gdk.DragAction.Copy); DragDataReceived += new Gtk.DragDataReceivedHandler (OnDragDataReceived); DragMotion += delegate { // Bring this window to the front. Otherwise, the drop may end being done in another window that overlaps this one if (!Platform.IsWindows) { var window = ((Gtk.Window)Toplevel); if (window is DockWindow) window.Present (); } }; allNotebooks.Add (this); }
public SysTrayApp() { // Create a simple tray menu with only one item. trayMenu = new ContextMenu(); trayMenu.MenuItems.Add("Configure", OnConfigure); trayMenu.MenuItems.Add("Exit", OnExit); // Create a tray icon. In this example we use a // standard system icon for simplicity, but you // can of course use your own custom icon too. trayIcon = new NotifyIcon(); trayIcon.Text = "MyTrayApp"; trayIcon.Icon = new Icon(SystemIcons.Application, 40, 40); // Add menu to tray icon and show it. trayIcon.ContextMenu = trayMenu; trayIcon.Visible = true; }
private void _onOptionMenuOpen(object sender, RoutedEventArgs e) { var menu = new ContextMenu(); menu.Placement = PlacementMode.Bottom; menu.PlacementTarget = OptionsMenu; Action<string, object, bool, bool> addToggle = (header, tag, isChecked, isEnabled) => { var menuitem = new MenuItem() { Header = header, Tag = tag, IsChecked = isChecked, IsEnabled = isEnabled }; menuitem.Click += new RoutedEventHandler(_onOptionsMenuClick); menu.Add(menuitem); }; addToggle("UML Extensions", INCLUDE_UML_EXT, this.isUmlExtensionIncluded, true); addToggle("Tool Extensions", INCLUDE_TOOL_EXT, this.isToolExtensionIncluded, true); addToggle("Profile Definitions", INCLUDE_PROFILE, this.isProfileIncluded, true); OptionsMenu.ContextMenu = menu; OptionsMenu.ContextMenu.IsOpen = true; }
void Awake() { Assert.IsNotNull(observeObj); Assert.IsNotNull(useObj); Assert.IsNotNull(pickObj); Assert.IsNotNull(talkObj); contextMenu = LevelManager.Instance().GetContextMenu(); renderer = GetComponent<SpriteRenderer>(); observeObj = Instantiate(observeObj); observeObj.SetActive(false); useObj = Instantiate(useObj); useObj.SetActive(false); pickObj = Instantiate(pickObj); pickObj.SetActive(false); talkObj = Instantiate(talkObj); talkObj.SetActive(false); }
private ContextMenu CreateModListContextMenu(ModEntry m, OLVListItem currentItem) { var menu = new ContextMenu(); if (m?.ID == null) { return(menu); } var selectedMods = ModList.SelectedObjects.ToList(); var selectedModCount = ModList.SelectedObjects.Count; MenuItem renameItem = null; MenuItem addTagItem = null; MenuItem showInExplorerItem = null; MenuItem showOnSteamItem = null; MenuItem showInBrowser = null; MenuItem fetchWorkshopTagsItem = null; // create items that appear only when a single mod is selected if (selectedMods.Count == 1) { renameItem = new MenuItem("Rename"); renameItem.Click += (a, b) => { modlist_ListObjectListView.EditSubItem(currentItem, olvcName.Index); }; showInExplorerItem = new MenuItem("Show in Explorer", delegate { m.ShowInExplorer(); }); menu.MenuItems.Add(showInExplorerItem); if (m.WorkshopID > 0) { showOnSteamItem = new MenuItem("Show on Steam", delegate { m.ShowOnSteam(); }); menu.MenuItems.Add(showOnSteamItem); showInBrowser = new MenuItem("Show in Browser", delegate { m.ShowInBrowser(); }); menu.MenuItems.Add(showInBrowser); } } addTagItem = new MenuItem("Add tag(s)..."); addTagItem.Click += (sender, args) => { var newTag = Interaction.InputBox($"Please specify one or more tags (separated by a semicolon) that should be added to {selectedModCount} selected mod(s).", "Add tag(s)"); if (newTag == "") { return; } var tags = newTag.Split(';'); foreach (ModEntry mod in modlist_ListObjectListView.SelectedObjects) { foreach (string tag in tags) { AddTag(mod, tag.Trim()); } } }; // Move to ... var moveToCategoryItem = new MenuItem("Move to category..."); // ... new category moveToCategoryItem.MenuItems.Add("New category", delegate { var category = Interaction.InputBox("Please enter the name of the new category", "Create category", "New category"); if (string.IsNullOrEmpty(category)) { return; } MoveSelectedModsToCategory(category); }); moveToCategoryItem.MenuItems.Add("-"); // ... existing category foreach (var category in Settings.Mods.Categories.OrderBy(c => c)) { if (category == Mods.GetCategory(m)) { continue; } moveToCategoryItem.MenuItems.Add(category, delegate { MoveSelectedModsToCategory(category); }); } // Hide/unhide var toggleVisibility = new MenuItem { Text = m.isHidden ? "Unhide" : "Hide" }; toggleVisibility.Click += delegate { // save as new list so we can remove mods if they are being hidden foreach (var mod in selectedMods) { mod.isHidden = !m.isHidden; if (!Settings.ShowHiddenElements && mod.isHidden) { modlist_ListObjectListView.RemoveObject(mod); } else { modlist_ListObjectListView.UpdateObject(mod); } } }; // Update mods var updateItem = new MenuItem("Update", delegate { System.ComponentModel.BackgroundWorker singleWorker = new System.ComponentModel.BackgroundWorker { WorkerReportsProgress = true }; singleWorker.ProgressChanged += Updater_SingleUpdateProgress; List <ModEntry> modsToUpdate = new List <ModEntry>(ModList.SelectedObjects); singleWorker.DoWork += delegate { System.Threading.Tasks.Parallel.ForEach(modsToUpdate, selItem => { Settings.Mods.UpdateMod(selItem, Settings); lock (singleWorker) { singleWorker.ReportProgress(0, selItem); } }); }; singleWorker.RunWorkerAsync(); }); if (ModList.SelectedObjects.Any(mod => mod.WorkshopID > 0)) { List <ModEntry> modsToUpdate = new List <ModEntry>(ModList.SelectedObjects.Where(mod => mod.Source == ModSource.SteamWorkshop)); fetchWorkshopTagsItem = new MenuItem("Use workshop tags"); fetchWorkshopTagsItem.Click += delegate { if (modsToUpdate.Count > 1) { var result = MessageBox.Show($"Tags from the workshop will replace the existing tags for {modsToUpdate.Count} mods." + Environment.NewLine + "Do you want to continue?", "Use workshop tags", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result != DialogResult.Yes) { return; } } Log.Info($"Fetching workshop tags for {modsToUpdate.Count} mods."); System.ComponentModel.BackgroundWorker singleWorker = new System.ComponentModel.BackgroundWorker { WorkerReportsProgress = true }; singleWorker.ProgressChanged += Updater_SingleUpdateProgress; singleWorker.DoWork += delegate { System.Threading.Tasks.Parallel.ForEach(modsToUpdate, selItem => { var tags = selItem.GetSteamTags(); if (tags.Any()) { selItem.Tags.Clear(); foreach (string tag in tags) { AddTag(selItem, tag); } lock (singleWorker) { singleWorker.ReportProgress(0, selItem); } } }); }; singleWorker.RunWorkerAsync(); }; } var deleteItem = new MenuItem("Delete / Unsubscribe", delegate { DeleteMods(); }); // create menu structure if (renameItem != null) { menu.MenuItems.Add(renameItem); } menu.MenuItems.Add(updateItem); menu.MenuItems.Add("-"); menu.MenuItems.Add(addTagItem); if (fetchWorkshopTagsItem != null) { menu.MenuItems.Add(fetchWorkshopTagsItem); } menu.MenuItems.Add(moveToCategoryItem); menu.MenuItems.Add("-"); if (showInExplorerItem != null) { menu.MenuItems.Add(showInExplorerItem); } if (showOnSteamItem != null) { menu.MenuItems.Add(showOnSteamItem); } if (showInBrowser != null) { menu.MenuItems.Add(showInBrowser); } // prevent double separator if (menu.MenuItems[menu.MenuItems.Count - 1].Text != @"-") { menu.MenuItems.Add("-"); } menu.MenuItems.Add(toggleVisibility); menu.MenuItems.Add(deleteItem); return(menu); }
public override void PopupContextMenu(UnitTestLocation unitTest, int x, int y) { var debugModeSet = Runtime.ProcessService.GetDebugExecutionMode(); var project = ext?.DocumentContext?.Project; if (project == null) { return; } var menu = new ContextMenu(); if (unitTest.IsFixture) { var menuItem = new ContextMenuItem(GettextCatalog.GetString("_Run All")); menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier, project, false).Run; menu.Add(menuItem); if (debugModeSet != null) { menuItem = new ContextMenuItem(GettextCatalog.GetString("_Debug All")); menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier, project, true).Run; menu.Add(menuItem); } menuItem = new ContextMenuItem(GettextCatalog.GetString("_Select in Test Pad")); menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier, project, true).Select; menu.Add(menuItem); } else { if (unitTest.TestCases.Count == 0) { var menuItem = new ContextMenuItem(GettextCatalog.GetString("_Run")); menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier, project, false).Run; menu.Add(menuItem); if (debugModeSet != null) { menuItem = new ContextMenuItem(GettextCatalog.GetString("_Debug")); menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier, project, true).Run; menu.Add(menuItem); } menuItem = new ContextMenuItem(GettextCatalog.GetString("_Select in Test Pad")); menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier, project, true).Select; menu.Add(menuItem); } else { var menuItem = new ContextMenuItem(GettextCatalog.GetString("_Run All")); menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier, project, false).Run; menu.Add(menuItem); if (debugModeSet != null) { menuItem = new ContextMenuItem(GettextCatalog.GetString("_Debug All")); menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier, project, true).Run; menu.Add(menuItem); } menu.Add(new SeparatorContextMenuItem()); foreach (var id in unitTest.TestCases) { var submenu = new ContextMenu(); menuItem = new ContextMenuItem(GettextCatalog.GetString("_Run")); menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier + id, project, false).Run; submenu.Add(menuItem); if (debugModeSet != null) { menuItem = new ContextMenuItem(GettextCatalog.GetString("_Debug")); menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier + id, project, true).Run; submenu.Add(menuItem); } var label = "Test" + id; string tooltip = null; var test = UnitTestService.SearchTestById(unitTest.UnitTestIdentifier + id); if (test != null) { var result = test.GetLastResult(); if (result != null && result.IsFailure) { tooltip = result.Message; label += "!"; } } menuItem = new ContextMenuItem(GettextCatalog.GetString("_Select in Test Pad")); menuItem.Clicked += new TestRunner(unitTest.UnitTestIdentifier + id, project, true).Select; submenu.Add(menuItem); var subMenuItem = new ContextMenuItem(label); // if (!string.IsNullOrEmpty (tooltip)) // subMenuItem.TooltipText = tooltip; subMenuItem.SubMenu = submenu; menu.Add(subMenuItem); } } } menu.Show(ext.Editor, x, y); }
void ITreeViewItem.SetTools(ITreeView TV) { //Set Context Menu mContextMenu = new ContextMenu(); }
public static void AddMenuItem(ContextMenu menu, string Header, RoutedEventHandler RoutedEventHandler, object CommandParameter = null, eImageType imageType = eImageType.Null) { MenuItem mnuItem = CreateMenuItem(Header, RoutedEventHandler, CommandParameter, imageType); menu.Items.Add(mnuItem); }
//</SnippetCommandingOverviewCommandDefinition> public Window1() { InitializeComponent(); //<SnippetCommandingOverviewKeyBinding> KeyGesture OpenKeyGesture = new KeyGesture( Key.B, ModifierKeys.Control); KeyBinding OpenCmdKeybinding = new KeyBinding( ApplicationCommands.Open, OpenKeyGesture); this.InputBindings.Add(OpenCmdKeybinding); //</SnippetCommandingOverviewKeyBinding> //<SnippetCommandingOverviewKeyGestureOnCmd> KeyGesture OpenCmdKeyGesture = new KeyGesture( Key.B, ModifierKeys.Control); ApplicationCommands.Open.InputGestures.Add(OpenCmdKeyGesture); //</SnippetCommandingOverviewKeyGestureOnCmd> //<SnippetCommandingOverviewCommandTargetCodeBehind> // Creating the UI objects StackPanel mainStackPanel = new StackPanel(); TextBox pasteTextBox = new TextBox(); Menu stackPanelMenu = new Menu(); MenuItem pasteMenuItem = new MenuItem(); // Adding objects to the panel and the menu stackPanelMenu.Items.Add(pasteMenuItem); mainStackPanel.Children.Add(stackPanelMenu); mainStackPanel.Children.Add(pasteTextBox); // Setting the command to the Paste command pasteMenuItem.Command = ApplicationCommands.Paste; // Setting the command target to the TextBox pasteMenuItem.CommandTarget = pasteTextBox; //</SnippetCommandingOverviewCommandTargetCodeBehind> //<SnippetCommandingOverviewCustomCommandSourceCodeBehind> // create the ui StackPanel CustomCommandStackPanel = new StackPanel(); Button CustomCommandButton = new Button(); CustomCommandStackPanel.Children.Add(CustomCommandButton); CustomCommandButton.Command = CustomRoutedCommand; //</SnippetCommandingOverviewCustomCommandSourceCodeBehind> //<SnippetCommandingOverviewCustomCommandBindingCodeBehind> CommandBinding customCommandBinding = new CommandBinding( CustomRoutedCommand, ExecutedCustomCommand, CanExecuteCustomCommand); // attach CommandBinding to root window this.CommandBindings.Add(customCommandBinding); //</SnippetCommandingOverviewCustomCommandBindingCodeBehind> sp.Children.Add(mainStackPanel); pasteTextBox.Background = Brushes.Bisque; sp.Children.Add(CustomCommandStackPanel); //<SnippetCommandingOverviewCmdSource> StackPanel cmdSourcePanel = new StackPanel(); ContextMenu cmdSourceContextMenu = new ContextMenu(); MenuItem cmdSourceMenuItem = new MenuItem(); // Add ContextMenu to the StackPanel. cmdSourcePanel.ContextMenu = cmdSourceContextMenu; cmdSourcePanel.ContextMenu.Items.Add(cmdSourceMenuItem); // Associate Command with MenuItem. cmdSourceMenuItem.Command = ApplicationCommands.Properties; //</SnippetCommandingOverviewCmdSource> cmdSourcePanel.Background = Brushes.Black; cmdSourcePanel.Height = 100; cmdSourcePanel.Width = 100; mainStackPanel.Children.Add(cmdSourcePanel); }
static public void DOWN(object sender, MouseEventArgs e) { mousePosition = e.Location; if (e.Button == MouseButtons.Right) { movable = null; isDrawSelected = false; if (isWireSelected) { movable = Schemes_Editor.wires[SelectedWireIndex]; ContextMenu menushka = new ContextMenu(new MenuItem[] { new MenuItem("Добавить выноску", handler), new MenuItem("Удалить", handler), new MenuItem("Удалить узел", handler), new MenuItem("Изменить название", handler) }); menushka.Show(father.pictureBox3, e.Location); return; } for (int i = Schemes_Editor.mainWorkList.Count - 1; i > -1; i--) { if (Schemes_Editor.mainWorkList[i].inside(e.Location, localSheet)) { if (Schemes_Editor.mainWorkList[i] is boxes) { movable = Schemes_Editor.mainWorkList[i]; isDrawSelected = true; ContextMenu menushka = new ContextMenu(new MenuItem[] { new MenuItem("Добавить выноску", handler), new MenuItem("Копировать", handler), new MenuItem("Удалить", handler), new MenuItem("Изменить название", handler) }); menushka.Show(father.pictureBox3, e.Location); return; } if (Schemes_Editor.mainWorkList[i] is free) { movable = Schemes_Editor.mainWorkList[i]; isDrawSelected = true; ContextMenu menushka = new ContextMenu(new MenuItem[] { new MenuItem("Добавить выноску", handler), new MenuItem("Копировать", handler), new MenuItem("Удалить", handler), new MenuItem("Изменить название", handler) }); menushka.Show(father.pictureBox3, e.Location); return; } break; } } for (int i = 0; i < Schemes_Editor.rooms.Count; i++) { if (Schemes_Editor.rooms[i].inside(e.Location, localSheet)) { isRoomSelected = true; movable = Schemes_Editor.rooms[i]; ContextMenu menushka = new ContextMenu(new MenuItem[] { new MenuItem("Удалить", handler), new MenuItem("Изменить название", handler) }); menushka.Show(father.pictureBox3, e.Location); return; } } } else { switch (Mode) { case modePlacement.doNothing_NOSCALEMODE: movable = null; isRoomSelected = false; if (isWireSelected) { var t = Schemes_Editor.wires[SelectedWireIndex].inside(localSheet, e.Location); if (t.isExists) { VertexNumber = t.ExistingIndex; if (VertexNumber != -1) { Mode = modePlacement.dragVertex; movable = 1; } } else //создать новую опорную точку { VertexNumber = Schemes_Editor.wires[SelectedWireIndex].insertPoint(t.vertex, localSheet); if (VertexNumber != -1) { Mode = modePlacement.dragVertex; movable = 1; } } } if (movable != null) { break; } for (int i = Schemes_Editor.mainWorkList.Count - 1; i > -1; i--) { if (Schemes_Editor.mainWorkList[i].inside(e.Location, localSheet)) { if (Schemes_Editor.mainWorkList[i] is boxes) { Prev = new Point(e.Location.X - ((boxes)Schemes_Editor.mainWorkList[i]).locations[localSheet].X, e.Location.Y - ((boxes)Schemes_Editor.mainWorkList[i]).locations[localSheet].Y); Mode = modePlacement.dragShkaf; movable = Schemes_Editor.mainWorkList[i]; break; } if (Schemes_Editor.mainWorkList[i] is free) { Prev = new Point(e.Location.X - ((free)Schemes_Editor.mainWorkList[i]).locations[localSheet].X, e.Location.Y - ((free)Schemes_Editor.mainWorkList[i]).locations[localSheet].Y); Mode = modePlacement.dragShkaf; movable = Schemes_Editor.mainWorkList[i]; break; } } } if (movable != null) { break; } else { for (int i = 0; i < Schemes_Editor.rooms.Count; i++) { if (Schemes_Editor.rooms[i].inside(e.Location, localSheet)) { isRoomSelected = true; Prev = new Point(e.Location.X - Schemes_Editor.rooms[i].locations[localSheet].X, e.Location.Y - Schemes_Editor.rooms[i].locations[localSheet].Y); movable = Schemes_Editor.rooms[i]; Mode = modePlacement.moveRoom; } } } break; case modePlacement.doNothing_SCALEMODE: moveTargetIndex = -1; isRoomSelected = false; for (int i = 0; i < Schemes_Editor.mainWorkList.Count; i++) { //if (Schemes_Editor.mainWorkList[i] is wire_s) // continue; if (Schemes_Editor.mainWorkList[i] is inboxes) { continue; } int a = Schemes_Editor.mainWorkList[i].locations[localSheet].X, b = Schemes_Editor.mainWorkList[i].locations[localSheet].Y, c = Schemes_Editor.mainWorkList[i].locations[localSheet].X + Schemes_Editor.mainWorkList[i].scales[localSheet].X, d = Schemes_Editor.mainWorkList[i].locations[localSheet].Y + Schemes_Editor.mainWorkList[i].scales[localSheet].Y; if (Schemes_Editor.distance(new Point(a, b), e.Location) < 20) { scalePoint = new Point(a, b); moveTargetIndex = i; pointNum = 0; Mode = modePlacement.scaleSomething; break; } if (Schemes_Editor.distance(new Point(a, d), e.Location) < 20) { scalePoint = new Point(a, d); moveTargetIndex = i; pointNum = 3; Mode = modePlacement.scaleSomething; break; } if (Schemes_Editor.distance(new Point(c, b), e.Location) < 20) { scalePoint = new Point(c, b); moveTargetIndex = i; pointNum = 1; Mode = modePlacement.scaleSomething; break; } if (Schemes_Editor.distance(new Point(c, d), e.Location) < 20) { scalePoint = new Point(c, d); moveTargetIndex = i; pointNum = 2; Mode = modePlacement.scaleSomething; break; } } if (moveTargetIndex != -1) { break; } else { for (int i = 0; i < Schemes_Editor.rooms.Count; i++) { int a = Schemes_Editor.rooms[i].locations[localSheet].X, b = Schemes_Editor.rooms[i].locations[localSheet].Y, c = Schemes_Editor.rooms[i].locations[localSheet].X + Schemes_Editor.rooms[i].locations[localSheet].Width, d = Schemes_Editor.rooms[i].locations[localSheet].Y + Schemes_Editor.rooms[i].locations[localSheet].Height; if (Schemes_Editor.distance(new Point(a, b), e.Location) < 20) { isRoomSelected = true; scalePoint = new Point(a, b); moveTargetIndex = i; pointNum = 0; Mode = modePlacement.scaleSomething; break; } if (Schemes_Editor.distance(new Point(a, d), e.Location) < 20) { isRoomSelected = true; scalePoint = new Point(a, d); moveTargetIndex = i; pointNum = 3; Mode = modePlacement.scaleSomething; break; } if (Schemes_Editor.distance(new Point(c, b), e.Location) < 20) { isRoomSelected = true; scalePoint = new Point(c, b); moveTargetIndex = i; pointNum = 1; Mode = modePlacement.scaleSomething; break; } if (Schemes_Editor.distance(new Point(c, d), e.Location) < 20) { isRoomSelected = true; scalePoint = new Point(c, d); moveTargetIndex = i; pointNum = 2; Mode = modePlacement.scaleSomething; break; } } } break; } } }
/// <summary> /// Right-click handler /// </summary> /// <param name="e"></param> private void OnContextMenu(MouseEventArgs e) { return; // Change current selection if necessary Point point = new Point(e.X, e.Y); int n = GraphicsList.Count; DrawObject o = null; for (int i = 0; i < n; i++) { if (GraphicsList[i].HitTest(point) == 0) { o = GraphicsList[i]; break; } } if (o != null) { if (!o.Selected) { GraphicsList.UnselectAll(); } // Select clicked object o.Selected = true; } else { GraphicsList.UnselectAll(); } Refresh(); // Show context menu. // Make ugly trick which saves a lot of code. // Get menu items from Edit menu in main form and // make context menu from them. // These menu items are handled in the parent form without // any additional efforts. MainMenu mainMenu = Owner.Menu; // Main menu MenuItem editItem = mainMenu.MenuItems[1]; // Edit submenu // Make array of items for ContextMenu constructor // taking them from the Edit submenu MenuItem[] items = new MenuItem[editItem.MenuItems.Count]; for (int i = 0; i < editItem.MenuItems.Count; i++) { items[i] = editItem.MenuItems[i]; } //Owner.SetStateOfControls(); // enable/disable menu items//设置菜单的选种状态 // Create and show context menu ContextMenu menu = new ContextMenu(items); menu.Show(this, point); // Restore items in the Edit menu (without this line Edit menu // is empty after forst right-click) editItem.MergeMenu(menu); }
private void InitializeComponent() { currTreeView = new TreeView(); splitter1 = new Splitter(); panel1 = new Panel(); CustomPropertyGrid currGrid = new CustomPropertyGrid(); ContextMenu currGridContextMenu = new ContextMenu(); panelContextMenu = new ContextMenu(); panelContextMenu.Popup += new EventHandler(PopupPanelContextMenu); currTreeView.HideSelection = false; currTreeView.Dock = DockStyle.Left; currTreeView.ImageIndex = -1; currTreeView.Location = new Point(0, 0); currTreeView.Name = "currTreeView"; currTreeView.SelectedImageIndex = -1; currTreeView.Size = new Size(256, 266); currTreeView.TabIndex = 6; currTreeView.ImageList = ImageListFactory.GetImageList(); currTreeView.AfterSelect += new TreeViewEventHandler(OnAfterSelect); currTreeViewContextMenu = new ContextMenu(); currTreeViewContextMenu.Popup += new EventHandler(PopupTreeViewContextMenu); currTreeView.MouseDown += new MouseEventHandler(TreeViewMouseDown); currTreeView.KeyDown += new KeyEventHandler(TreeViewKeyDown); splitter1.Dock = DockStyle.Left; splitter1.Location = new Point(140, 0); splitter1.Name = "splitter1"; splitter1.Size = new Size(2, 266); splitter1.TabIndex = 7; splitter1.TabStop = false; currGridContextMenu.Popup += new EventHandler(OnPropertyGridPopupContextMenu); currGrid.Dock = DockStyle.Fill; currGrid.Font = new Font("Tahoma", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((System.Byte)(0))); currGrid.Location = new Point(140, 0); currGrid.Name = "_currGrid"; currGrid.Size = new Size(250, 266); currGrid.TabIndex = 1; currGrid.PropertySort = PropertySort.Alphabetical; currGrid.ToolbarVisible = false; currGrid.PropertyValueChanged += new PropertyValueChangedEventHandler(OnPropertyValueChanged); currGrid.ContextMenu = currGridContextMenu; panel1.Controls.Add(currGrid); panel1.Dock = DockStyle.Fill; panel1.Location = new Point(142, 0); panel1.Name = "panel1"; panel1.Size = new Size(409, 266); panel1.TabIndex = 9; Controls.Add(panel1); Controls.Add(splitter1); Controls.Add(currTreeView); CurrentGrid = currGrid; CurrentGridContextMenu = currGridContextMenu; }
protected virtual void AddCustomTreeViewContextMenuItems(XmlNode node, ContextMenu currTreeViewContextMenu) { }
private void GenerateNotifyIcon() { if (Noti != null) { Noti.Dispose(); } ContextMenu Menu = new ContextMenu(); Noti = new NotifyIcon { Icon = new Icon(@"Resources\icon.ico", new Size(10, 10)), Visible = true, Text = "노티파이아이콘", ContextMenu = Menu }; MenuItem menu1 = new MenuItem { Text = "Menu1" }; menu1.Click += (object o, EventArgs e) => { //event here }; MenuItem menu2 = new MenuItem() { Text = "Menu2" }; MenuItem menu2submenu1 = new MenuItem() { Text = "한국어" }; menu2submenu1.Click += (object o, EventArgs e) => { //event here }; menu2.MenuItems.Add(menu2submenu1); MenuItem menu2submenu2 = new MenuItem() { Text = "English" }; menu2submenu2.Click += (object o, EventArgs e) => { //event here }; menu2.MenuItems.Add(menu2submenu2); MenuItem ExitItem = new MenuItem() { Text = "나가기" }; ExitItem.Click += (object o, EventArgs e) => { }; Menu.MenuItems.Add(menu1); Menu.MenuItems.Add(menu2); Menu.MenuItems.Add(ExitItem); Noti.ContextMenu = Menu; }
private RadioMenuItem FindMenuItem(ContextMenu menu, ElementTheme theme) { return(menu.Items.OfType <RadioMenuItem>().First(x => (ElementTheme)x.Tag == theme)); }
public MainForm(ClickStatus status, CustomizationParameters customParams) { // Initialize Fetcher icon, that pulls main form forward when moused over, and is always TopForm this.fetcher = new Fetcher(this, customParams); fetcher.Show(); // Set starting variables InitializeComponent(); this.clickStatus = status; this.customParams = customParams; // Set Windows Application parameters and add tray icon this.ShowInTaskbar = false; ContextMenu trayMenu = new ContextMenu(); trayMenu.MenuItems.Add("Exit", OnExit); this.trayIcon = new NotifyIcon(); trayIcon.Text = "SmartClicker"; trayIcon.Icon = this.Icon; // Add menu to tray icon and show it. trayIcon.ContextMenu = trayMenu; trayIcon.Visible = true; // This holds every hide-able picturebox for different program modes this.buttons = new PictureBox[] { sleepClick, contextClick, leftClick, rightClick, doubleClick, clickAndDrag }; foreach (PictureBox mode in buttons) { mode.MouseHover += new EventHandler(pictureBox_MouseHover); } // Need to add a mouse hover handler to the config button too CustomForm.MouseHover += new EventHandler(CustomForm_MouseHover); // Create a mapping from picture boxes to default program modes, so we can set them if they are selected ModeMapping = new Dictionary <PictureBox, ProgramMode>() { { leftClick, ProgramMode.leftClick }, { rightClick, ProgramMode.rightClick }, { doubleClick, ProgramMode.doubleClick }, { contextClick, ProgramMode.contextClick }, { clickAndDrag, ProgramMode.clickAndDrag }, { sleepClick, ProgramMode.sleepClick } }; // Create an inverse mapping so the detector can also change how pictureboxes look inverseModeMapping = new Dictionary <ProgramMode, PictureBox>(); foreach (PictureBox box in ModeMapping.Keys) { inverseModeMapping.Add(ModeMapping[box], box); } // Redraw the MainForm to match XML configuration this.redraw(); // Initialize the form to the XML/default parameters this.MaximizeBox = false; this.MinimizeBox = false; this.Text = String.Empty; this.StartPosition = FormStartPosition.Manual; this.Left = Math.Min(this.customParams.layoutValues.startLeft, Screen.PrimaryScreen.Bounds.Width - this.customParams.layoutValues.startWidth); this.Top = Math.Max(this.customParams.layoutValues.startTop, this.customParams.clickValues.clickBoundingBox); this.Width = this.customParams.layoutValues.startWidth; this.Height = this.customParams.layoutValues.startHeight; // Add handler to ask "Are you sure?" dialog this.FormClosing += new FormClosingEventHandler(MainForm_FormClosing); setPictureBoxLock(contextClick); }
private void TreeEntry_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { if (parent == null) { parent = Utils.FindAnchestor <TreeViewItem>(this); } context = (e.NewValue as Node_Common); if (parent != null) { ContextMenu menu = new ContextMenu(); menu.DataContext = context; if (context != null) { MenuItem item = null; item = new MenuItem(); item.Header = context.Name; item.IsEnabled = false; menu.Items.Add(item); menu.Items.Add(new Separator()); item = new MenuItem(); item.Header = "Add to downloads"; item.Click += new RoutedEventHandler(Add_Item); menu.Items.Add(item); item = new MenuItem(); item.Header = "Open containing folder"; item.Click += new RoutedEventHandler(Open_ContainingFolder); menu.Items.Add(item); item = new MenuItem(); item.Header = "Open file/folder"; { Binding bnd = null; try { bnd = new Binding("IsExisting"); bnd.Source = context; } catch (Exception) { bnd = null; } item.SetBinding(MenuItem.IsEnabledProperty, bnd); } item.Click += new RoutedEventHandler(Open_FileOrFolder); menu.Items.Add(item); item = new MenuItem(); item.Header = "Parse file/folder"; item.Click += new RoutedEventHandler(Parse_FileOrFolder); menu.Items.Add(item); item = new MenuItem(); item.Header = "Parse children file/folder"; if (context.NodeType == Node_Common.Type.T_DIR) { Binding bnd = null; try { bnd = new Binding("IsParsed"); bnd.Source = context; } catch (Exception) { bnd = null; } item.SetBinding(MenuItem.IsEnabledProperty, bnd); } else { item.IsEnabled = false; } item.Click += new RoutedEventHandler(ParseChildren_FileOrFolder); menu.Items.Add(item); } parent.ContextMenu = menu; parent.ContextMenu.Opened += new RoutedEventHandler(ContextMenu_Opened); } }
static String polku = "c:\\work\\settings.txt"; //asetusten tallennuspolku #endregion #region Forms public InvisibleForm() { InitializeComponent(); threads = new List <Thread>(); // Ladataan iconit tiedostoista HDDBusyIcon = new Icon("HDD_Busy.ico"); HDDidleIcon = new Icon("HDD_Idle.ico"); // Luo notifyiconin näkyvänä ja asettaa sen idleksi nIcon = new NotifyIcon(); nIcon.Icon = HDDidleIcon; nIcon.Visible = true; // Lukee tiedostosta aloitusThreadin try { System.IO.StreamReader fileR = new System.IO.StreamReader(polku); startThread = fileR.ReadLine(); fileR.Close(); } catch (System.IO.FileNotFoundException ex) { startThread = "hddStart"; } // // Luo menut, sen itemit ja lisää ne iconin valikkoon // MenuItem creatorMenuItem = new MenuItem("Infoilmoitin by Ilari Malinen v. 0.1 ALPHA"); MenuItem quitMenuItem = new MenuItem("Quit"); MenuItem processorSearch = new MenuItem("Ilmoita prosessorin käyttö"); MenuItem hddInfo = new MenuItem("Ilmoita HDD - driven käyttö"); MenuItem settings = new MenuItem("Settings"); ContextMenu contextM = new ContextMenu(); contextM.MenuItems.Add(creatorMenuItem); contextM.MenuItems.Add(hddInfo); contextM.MenuItems.Add(processorSearch); contextM.MenuItems.Add(settings); contextM.MenuItems.Add(quitMenuItem); nIcon.ContextMenu = contextM; // Toiminnallisuus painikkeille quitMenuItem.Click += QuitMenuItem_Click; processorSearch.Click += ProcessorSearch_Click; hddInfo.Click += HddInfo_Click; settings.Click += Settings_Click; // // Piilotetaan ikkuna, sitä ei alkuun haluta // this.WindowState = FormWindowState.Minimized; this.ShowInTaskbar = false; //Luo threadit //aloittaa halutun ensimmäisen threadin HDDInfoThread = new Thread(new ThreadStart(HddActivityThread)); threads.Add(HDDInfoThread); ProcessorInfoThread = new Thread(new ThreadStart(ProcessorActivityThread)); threads.Add(ProcessorInfoThread); if (startThread == "hddStart") { hddRun = true; HDDInfoThread.Start(); } else if (startThread == "cpuStart") { cpuRun = true; ProcessorInfoThread.Start(); } // aloittaessa asettaa nykyinen tekstin label2.Text = "Nykyinen: " + startThread; }
public ContextMenu CreateTreeviewContextMenu() { var ctxMenu = new ContextMenu() { Name = "TopicContextMenu" }; ctxMenu.DataContext = Model.TopicsTree.Model; var mi = new MenuItem { Name = "MenuNewTopic", Header = "_New Topic", InputGestureText = "ctrl-n", Command = Model.Commands.NewTopicCommand }; ctxMenu.Items.Add(mi); mi = new MenuItem { Name = "MenuDeleteTopic", Header = "Delete Topic", InputGestureText = "del", Command = Model.Commands.DeleteTopicCommand }; ctxMenu.Items.Add(mi); ctxMenu.Items.Add(new Separator()); mi = new MenuItem { Name = "MenuOpenExternalTopicFile", Header = "Open Topic File Explicitly", Command = Model.Commands.OpenTopicFileExplicitlyCommand }; ctxMenu.Items.Add(mi); ctxMenu.Items.Add(new Separator()); // *** Template Submenu mi = new MenuItem { Name = "MenuTemplates", Header = "Templates", }; ctxMenu.Items.Add(mi); var sub = new MenuItem { Header = "Edit Topic Template", }; sub.Click += (s, e) => { var path = Path.Combine(Model.ActiveProject.ProjectDirectory, $"_kavadocs\\Themes\\{Model.ActiveTopic?.DisplayType}.cshtml"); ShellUtils.GoUrl(path); }; mi.Items.Add(sub); sub = new MenuItem { Header = "Edit Layout Template (__layout.cshtml)", CommandParameter = "_layout.cshtml" }; sub.Click += On_OpenStaticScriptFile; mi.Items.Add(sub); mi.Items.Add(new Separator()); sub = new MenuItem { Header = "Edit Project CSS (kavadocs.css)", CommandParameter = "kavadocs.css" }; sub.Click += On_OpenStaticScriptFile; mi.Items.Add(sub); sub = new MenuItem { Header = "Edit Project Script (kavadocs.js)", CommandParameter = "scripts\\kavadocs.js" }; sub.Click += On_OpenStaticScriptFile; mi.Items.Add(new Separator()); sub = new MenuItem { Header = "Open Project Template Folder", CommandParameter = "" }; sub.Click += On_OpenStaticScriptFile; mi.Items.Add(sub); mi.Items.Add(new Separator()); sub = new MenuItem { Header = "Re-generate Project with Updated Templates", Command = Model.Commands.BuildHtmlCommand }; mi.Items.Add(sub); sub = new MenuItem { Header = "Update Scripts and Templates", Command = Model.Commands.UpdateScriptsAndTemplatesCommand, ToolTip = "Updates scripts, css, templates, template images, icons from the template into the output folder." }; mi.Items.Add(sub); ctxMenu.Items.Add(new Separator()); // *** Import mi = new MenuItem { Header = "Import", }; ctxMenu.Items.Add(mi); sub = new MenuItem() { Header = "Import .NET Library", Command = Model.Commands.ImportDotnetLibraryCommand }; mi.Items.Add(sub); // *** Misc mi = new MenuItem { Header = "Show File in Explorer", Command = Model.Commands.ShowFileInExplorerCommand, CommandParameter = Path.Combine(Model.ActiveTopic.Project.ProjectDirectory, Model.ActiveTopic.Link) }; ctxMenu.Items.Add(mi); mi = new MenuItem { Name = "MenuRefresh", Header = "Reload Tree", //Command = Model.Commands.ReloadTreeCommand }; ctxMenu.Items.Add(mi); return(ctxMenu); }
public TrayIcon() { this.components = new Container(); this.contextMenu = new ContextMenu(); // Initialize menuItem1 this.menuBlock = new MenuItem() { Text = Translate.fmt("mnu_block") }; ProgramID id = ProgramID.NewID(ProgramID.Types.Global); ProgramSet prog = App.client.GetProgram(id, true); if (prog == null) { this.menuBlock.Enabled = false; } else { this.menuBlock.Checked = (prog.config.CurAccess == ProgramSet.Config.AccessLevels.BlockAccess); } this.menuBlock.Click += new System.EventHandler(this.menuBlock_Click); this.menuPresets = new MenuItem() { Text = Translate.fmt("mnu_presets") }; UpdatePresets(); App.presets.PresetChange += OnPresetChanged; // Initialize menuItem1 this.menuExit = new MenuItem() { Text = Translate.fmt("mnu_exit") }; this.menuExit.Click += new System.EventHandler(this.menuExit_Click); // Initialize contextMenu1 this.contextMenu.MenuItems.AddRange(new MenuItem[] { this.menuBlock, this.menuPresets, new MenuItem("-"), this.menuExit }); // Create the NotifyIcon. this.notifyIcon = new NotifyIcon(this.components); // The Icon property sets the icon that will appear // in the systray for this application. notifyIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(App.exePath); // The ContextMenu property sets the menu that will // appear when the systray icon is right clicked. notifyIcon.ContextMenu = this.contextMenu; // The Text property sets the text that will be displayed, // in a tooltip, when the mouse hovers over the systray icon. notifyIcon.Text = FileVersionInfo.GetVersionInfo(App.exePath).FileDescription; // Handle the DoubleClick event to activate the form. notifyIcon.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick); notifyIcon.Click += new System.EventHandler(this.notifyIcon1_Click); mTimer.Tick += new EventHandler(OnTimerTick); mTimer.Interval = new TimeSpan(0, 0, 0, 0, 500); mTimer.Start(); }
public Ventriloquist() { // Configure logger string path = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "log4net.config"); XmlConfigurator.ConfigureAndWatch(new FileInfo(path)); logger.Info("Ventriliquest Starting up..."); if (!Directory.Exists(appsupportpath)) { Directory.CreateDirectory(appsupportpath); } config = Config.GetInstance(); config.PropertyChanged += async(object sender, System.ComponentModel.PropertyChangedEventArgs e) => { if (e.PropertyName.Equals("localonly")) { server.Stop(); foreach (var socket in allSockets) { try { socket.Close(); } catch (Exception ex) { } } websocketserver.ListenerSocket.Close(); websocketserver.Dispose(); InitHTTPServer(); } }; trayMenu = new ContextMenu(); MenuItem outputDevice = new MenuItem("Output device"); for (int deviceId = 0; deviceId < WaveOut.DeviceCount; deviceId++) { var capabilities = WaveOut.GetCapabilities(deviceId); //Console.WriteLine(String.Format("Device {0} ({1})", deviceId, capabilities.ProductName)); var deviceItem = new MenuItem(capabilities.ProductName, OnDeviceConfig); deviceItem.Tag = deviceId; if (config.OutputDevice.Equals("NOPE")) { config.OutputDevice = capabilities.ProductName; } if (capabilities.ProductName == config.OutputDevice) { deviceItem.Checked = true; OutputDeviceId = deviceId; Console.WriteLine("Output Device: " + OutputDeviceId); } outputDevice.MenuItems.Add(deviceItem); } var networkconfigItem = new MenuItem("Local Connections Only", OnNetworkConfig); Console.WriteLine("network config'd as: " + config.LocalOnly); if (config.LocalOnly) { networkconfigItem.Checked = true; } var voiceconfigItem = new MenuItem("Voice Configuration", OnVoiceConfig); trayMenu.MenuItems.Add(new MenuItem("Version 1.1")); trayMenu.MenuItems.Add(outputDevice); trayMenu.MenuItems.Add(networkconfigItem); trayMenu.MenuItems.Add(voiceconfigItem); trayMenu.MenuItems.Add("Exit", OnExit); trayIcon = new NotifyIcon(); trayIcon.Text = "Ventriloquist TTS Server"; trayIcon.Icon = new Icon(SystemIcons.Application, 40, 40); trayIcon.ContextMenu = trayMenu; trayIcon.Visible = true; }
private void CheckAndStart() { Width = 0; Height = 0; WindowStyle = WindowStyle.None; ShowInTaskbar = false; ShowActivated = false; this.Visibility = Visibility.Hidden; uploadWorker = new BackgroundWorker(); uploadWorker.DoWork += UploadWorker_DoWork; uploadWorker.RunWorkerCompleted += UploadWorker_RunWorkerCompleted; var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).AppSettings.Settings; foreach (var directory in Directory.GetDirectories(config["installDir"].Value)) { if (!File.Exists(Path.Combine(directory, ".flavor.info"))) { continue; } var flavorLines = File.ReadAllLines(Path.Combine(directory, ".flavor.info")); if (flavorLines.Length != 2 || flavorLines[1].Substring(0, 3) != "wow") { Console.WriteLine("Malformed .flavor.info"); continue; } var cacheFolder = Path.Combine(directory, "Cache", "ADB", "enUS"); if (!Directory.Exists(cacheFolder)) { continue; } activeInstalls.Add(flavorLines[1], directory); var watcher = new FileSystemWatcher(); watcher.Renamed += Watcher_Renamed; watcher.Path = cacheFolder; watcher.Filter = "*.bin"; watcher.EnableRaisingEvents = true; watchers.Add(watcher); } showNotifications = bool.Parse(config["showNotifications"].Value); if (config["addonUploads"] != null) { addonUploads = bool.Parse(config["addonUploads"].Value); } else { addonUploads = false; } var menu = new ContextMenu(); foreach (var activeInstall in activeInstalls) { var installItem = new MenuItem(); var installName = activeInstall.Key; installItem.Name = installName; installItem.Header = "Upload " + installName; installItem.Click += Upload_PreviewMouseUp; menu.Items.Add(installItem); } var settingsItem = new MenuItem(); settingsItem.Name = "Settings"; settingsItem.Header = "Settings"; settingsItem.Click += Settings_PreviewMouseUp; menu.Items.Add(settingsItem); var exitItem = new MenuItem(); exitItem.Name = "Exit"; exitItem.Header = "Exit"; exitItem.Click += Exit_PreviewMouseUp; menu.Items.Add(exitItem); this.TBIcon.ContextMenu = menu; CheckForUpdates(); }
public static void AddMenuItem(ContextMenu menu, string Header, RoutedEventHandler RoutedEventHandler, object CommandParameter = null, string icon = "") { MenuItem mnuItem = CreateMenuItem(Header, RoutedEventHandler, CommandParameter, icon); menu.Items.Add(mnuItem); }
/// <summary> /// Metodo que se invoca cuando se presiona un boton del mouse. /// </summary> /// <param name="e"></param> protected override void OnMouseDown(MouseEventArgs e) { lastMousePlace = FromClientToCanvas(e.Location); ChartElement nextSelected = null; foreach (ChartElement c in Charts) { if (c.Display.Contains(FromClientToCanvas(e.Location))) { nextSelected = c; } } if (SelectedItem != null) { SelectedItem.Selected = false; } SelectedItem = nextSelected; if (SelectedItem != null) { SelectedItem.Selected = true; } if (e.Button == System.Windows.Forms.MouseButtons.Right) { isConnecting = false; modifyingConnection = null; if (SelectedItem != null) { ContextMenu cm = GetContextMenuFor(SelectedItem); this.ContextMenu = cm; } else { ContextMenu cm = GetGlobalContextMenu(FromClientToCanvas(e.Location)); this.ContextMenu = cm; } } else { if (isConnecting) { Pin nearestInput = null; if (SelectedItem != null) { foreach (Pin input in SelectedItem.ValidInputs) { if (nearestInput == null || Distance(input.Position, FromClientToCanvas(e.Location)) < Distance(nearestInput.Position, FromClientToCanvas(e.Location))) { nearestInput = input; } } } var before = modifyingConnection.To; modifyingConnection.To = nearestInput; if (nearestInput != null) //le pongo el padre { ((BayesianNodeChartElement)nearestInput.ChartElement).Parents.Add((BayesianNodeChartElement)modifyingConnection.From.ChartElement); ((BayesianNodeChartElement)nearestInput.ChartElement).Condicional_Probabilities = null; } if (before != null) //le quito el antiguo padre { ((BayesianNodeChartElement)before.ChartElement).Parents.Remove( modifyingConnection.From.ChartElement as BayesianNodeChartElement); ((BayesianNodeChartElement)before.ChartElement).Condicional_Probabilities = null; } isConnecting = false; modifyingConnection = null; } } Invalidate(); base.OnMouseDown(e); }
/// <summary> /// Called when content window wants to show the context menu. Allows to add custom functions for the given asset type. /// </summary> /// <param name="menu">The menu.</param> /// <param name="item">The item.</param> public virtual void OnContentWindowContextMenu(ContextMenu menu, ContentItem item) { }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FormMain)); this.menuMain = new System.Windows.Forms.MainMenu(); this.mitemFilePopup = new System.Windows.Forms.MenuItem(); this.mitemFileOpen = new System.Windows.Forms.MenuItem(); this.mitemFileSave = new System.Windows.Forms.MenuItem(); this.mitemFileSaveAs = new System.Windows.Forms.MenuItem(); this.mitemFileFormat = new System.Windows.Forms.MenuItem(); this.mitemFFAscii = new System.Windows.Forms.MenuItem(); this.mitemFFUnicode = new System.Windows.Forms.MenuItem(); this.mitemFFUtf7 = new System.Windows.Forms.MenuItem(); this.mitemFFUtf8 = new System.Windows.Forms.MenuItem(); this.mitemFFDefault = new System.Windows.Forms.MenuItem(); this.mitemEditPopup = new System.Windows.Forms.MenuItem(); this.mitemEditFont = new System.Windows.Forms.MenuItem(); this.mitemToolsPopup = new System.Windows.Forms.MenuItem(); this.mitemToolsOptions = new System.Windows.Forms.MenuItem(); this.mitemSettingsPopup = new System.Windows.Forms.MenuItem(); this.mitemSettingsSave = new System.Windows.Forms.MenuItem(); this.mitemSettingsRestore = new System.Windows.Forms.MenuItem(); this.mitemSettingsInit = new System.Windows.Forms.MenuItem(); this.textInput = new System.Windows.Forms.TextBox(); this.tbarCommands = new System.Windows.Forms.ToolBar(); this.tbbEditFormat = new System.Windows.Forms.ToolBarButton(); this.tbbViewOptions = new System.Windows.Forms.ToolBarButton(); this.ilistCommands = new System.Windows.Forms.ImageList(); this.cmenuMain = new System.Windows.Forms.ContextMenu(); this.mitemProgramMenu = new System.Windows.Forms.MenuItem(); this.mitemToolbar = new System.Windows.Forms.MenuItem(); // // menuMain // this.menuMain.MenuItems.Add(this.mitemFilePopup); this.menuMain.MenuItems.Add(this.mitemEditPopup); this.menuMain.MenuItems.Add(this.mitemToolsPopup); this.menuMain.MenuItems.Add(this.mitemSettingsPopup); // // mitemFilePopup // this.mitemFilePopup.MenuItems.Add(this.mitemFileOpen); this.mitemFilePopup.MenuItems.Add(this.mitemFileSave); this.mitemFilePopup.MenuItems.Add(this.mitemFileSaveAs); this.mitemFilePopup.MenuItems.Add(this.mitemFileFormat); this.mitemFilePopup.Text = "File"; // // mitemFileOpen // this.mitemFileOpen.Text = "Open..."; this.mitemFileOpen.Click += new System.EventHandler(this.mitemFileOpen_Click); // // mitemFileSave // this.mitemFileSave.Text = "Save"; this.mitemFileSave.Click += new System.EventHandler(this.mitemFileSave_Click); // // mitemFileSaveAs // this.mitemFileSaveAs.Text = "SaveAs..."; this.mitemFileSaveAs.Click += new System.EventHandler(this.mitemFileSaveAs_Click); // // mitemFileFormat // this.mitemFileFormat.MenuItems.Add(this.mitemFFAscii); this.mitemFileFormat.MenuItems.Add(this.mitemFFUnicode); this.mitemFileFormat.MenuItems.Add(this.mitemFFUtf7); this.mitemFileFormat.MenuItems.Add(this.mitemFFUtf8); this.mitemFileFormat.MenuItems.Add(this.mitemFFDefault); this.mitemFileFormat.Text = "Format"; // // mitemFFAscii // this.mitemFFAscii.Text = "Ascii"; this.mitemFFAscii.Click += new System.EventHandler(this.mitemFFFormat_Click); // // mitemFFUnicode // this.mitemFFUnicode.Text = "Unicode"; this.mitemFFUnicode.Click += new System.EventHandler(this.mitemFFFormat_Click); // // mitemFFUtf7 // this.mitemFFUtf7.Text = "Utf7"; this.mitemFFUtf7.Click += new System.EventHandler(this.mitemFFFormat_Click); // // mitemFFUtf8 // this.mitemFFUtf8.Text = "Utf8"; this.mitemFFUtf8.Click += new System.EventHandler(this.mitemFFFormat_Click); // // mitemFFDefault // this.mitemFFDefault.Text = "Default"; this.mitemFFDefault.Click += new System.EventHandler(this.mitemFFFormat_Click); // // mitemEditPopup // this.mitemEditPopup.MenuItems.Add(this.mitemEditFont); this.mitemEditPopup.Text = "Edit"; // // mitemEditFont // this.mitemEditFont.Text = "Font..."; this.mitemEditFont.Click += new System.EventHandler(this.mitemEditFont_Click); // // mitemToolsPopup // this.mitemToolsPopup.MenuItems.Add(this.mitemToolsOptions); this.mitemToolsPopup.Text = "Tools"; // // mitemToolsOptions // this.mitemToolsOptions.Text = "Options..."; this.mitemToolsOptions.Click += new System.EventHandler(this.mitemToolsOptions_Click); // // mitemSettingsPopup // this.mitemSettingsPopup.MenuItems.Add(this.mitemSettingsSave); this.mitemSettingsPopup.MenuItems.Add(this.mitemSettingsRestore); this.mitemSettingsPopup.MenuItems.Add(this.mitemSettingsInit); this.mitemSettingsPopup.Text = "Settings"; // // mitemSettingsSave // this.mitemSettingsSave.Text = "Save"; this.mitemSettingsSave.Click += new System.EventHandler(this.mitemSettingsSave_Click); // // mitemSettingsRestore // this.mitemSettingsRestore.Text = "Restore"; this.mitemSettingsRestore.Click += new System.EventHandler(this.mitemSettingsRestore_Click); // // mitemSettingsInit // this.mitemSettingsInit.Text = "Initialize"; this.mitemSettingsInit.Click += new System.EventHandler(this.mitemSettingsInit_Click); // // textInput // this.textInput.Location = new System.Drawing.Point(8, 8); this.textInput.Multiline = true; this.textInput.ScrollBars = System.Windows.Forms.ScrollBars.Both; this.textInput.Size = new System.Drawing.Size(224, 248); this.textInput.Text = "Some text inside a textbox."; // // tbarCommands // this.tbarCommands.Buttons.Add(this.tbbEditFormat); this.tbarCommands.Buttons.Add(this.tbbViewOptions); this.tbarCommands.ImageList = this.ilistCommands; this.tbarCommands.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.tbarCommands_ButtonClick); // // tbbEditFormat // this.tbbEditFormat.ImageIndex = 0; // // tbbViewOptions // this.tbbViewOptions.ImageIndex = 1; // // ilistCommands // this.ilistCommands.Images.Add(((System.Drawing.Image)(resources.GetObject("resource")))); this.ilistCommands.Images.Add(((System.Drawing.Image)(resources.GetObject("resource1")))); this.ilistCommands.ImageSize = new System.Drawing.Size(16, 16); // // cmenuMain // this.cmenuMain.MenuItems.Add(this.mitemProgramMenu); this.cmenuMain.MenuItems.Add(this.mitemToolbar); this.cmenuMain.Popup += new System.EventHandler(this.cmenuMain_Popup); // // mitemProgramMenu // this.mitemProgramMenu.Text = "Program Menu"; this.mitemProgramMenu.Click += new System.EventHandler(this.mitemProgramMenu_Click); // // mitemToolbar // this.mitemToolbar.Text = "Toolbar"; this.mitemToolbar.Click += new System.EventHandler(this.mitemToolbar_Click); // // FormMain // this.ContextMenu = this.cmenuMain; this.Controls.Add(this.textInput); this.Controls.Add(this.tbarCommands); this.Menu = this.menuMain; this.MinimizeBox = false; this.Text = "TextEdit"; this.Load += new System.EventHandler(this.FormMain_Load); }
/// <summary> /// Пересобрать контекстное меню для чарта /// </summary> private void ReloadContext() { try { List <MenuItem> menuRedact = null; List <MenuItem> menuDelete = null; if (_indicatorsCandles != null) { menuRedact = new List <MenuItem>(); menuDelete = new List <MenuItem>(); for (int i = 0; i < _indicatorsCandles.Count; i++) { menuRedact.Add(new MenuItem(_indicatorsCandles[i].GetType().Name)); menuRedact[menuRedact.Count - 1].Click += RedactContextMenu_Click; if (_indicatorsCandles[i].CanDelete) { menuDelete.Add(new MenuItem(_indicatorsCandles[i].GetType().Name)); menuDelete[menuDelete.Count - 1].Click += DeleteContextMenu_Click; } } } if (_chartCandle.GetChartArea("TradeArea") != null) { if (menuRedact == null) { menuRedact = new List <MenuItem>(); menuDelete = new List <MenuItem>(); } menuDelete.Add(new MenuItem("Trades")); menuDelete[menuDelete.Count - 1].Click += DeleteContextMenu_Click; } List <MenuItem> items; items = new List <MenuItem>(); items.Add(new MenuItem("Отрисовка чарта", new MenuItem[] { new MenuItem("Цветовая схема", new MenuItem[] { new MenuItem("Тёмная"), new MenuItem("Светлая") }), new MenuItem("Фигура сделки", new MenuItem[] { new MenuItem("Ромб"), new MenuItem("Кружок"), new MenuItem("Треугольник(тормозит при дебаггинге)") }), new MenuItem("Размер фигуры", new MenuItem[] { new MenuItem("6"), new MenuItem("10"), new MenuItem("14") }) } )); items[items.Count - 1].MenuItems[0].MenuItems[0].Click += ChartBlackColor_Click; items[items.Count - 1].MenuItems[0].MenuItems[1].Click += ChartWhiteColor_Click; items[items.Count - 1].MenuItems[1].MenuItems[0].Click += ChartRombToPosition_Click; items[items.Count - 1].MenuItems[1].MenuItems[1].Click += ChartCircleToPosition_Click; items[items.Count - 1].MenuItems[1].MenuItems[2].Click += ChartTriangleToPosition_Click; items[items.Count - 1].MenuItems[2].MenuItems[0].Click += ChartMinPointSize_Click; items[items.Count - 1].MenuItems[2].MenuItems[1].Click += ChartMiddlePointSize_Click; items[items.Count - 1].MenuItems[2].MenuItems[2].Click += ChartMaxPointSize_Click; items.Add(new MenuItem("Скрыть области")); items[items.Count - 1].Click += ChartHideIndicators_Click; items.Add(new MenuItem("Показать области")); items[items.Count - 1].Click += ChartShowIndicators_Click; if (menuRedact != null) { items.Add(new MenuItem("Редактировать индикаторы", menuRedact.ToArray())); items.Add(new MenuItem("Удалить индикатор", menuDelete.ToArray())); } items.Add(new MenuItem("Добавить индикатор")); items[items.Count - 1].Click += CreateIndicators_Click; ContextMenu menu = new ContextMenu(items.ToArray()); _chartCandle.GetChart().ContextMenu = menu; } catch (Exception error) { SendErrorMessage(error); } }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.myLabel = new Label(); this.myLabelContextMenu = new ContextMenu(); this.myFirstMenuItem = new MenuItem(); this.menuItem1 = new MenuItem(); this.menuItem2 = new MenuItem(); this.menuItem3 = new MenuItem(); this.menuItem5 = new MenuItem(); this.menuItem4 = new MenuItem(); this.menuItem6 = new MenuItem(); this.myCounterLabel = new Label(); this.secondMenu = new ContextMenu(); this.menuItem7 = new MenuItem(); this.menuItem8 = new MenuItem(); this.SuspendLayout(); // // myLabel // this.myLabel.ContextMenu = this.myLabelContextMenu; this.myLabel.Location = new Point(32, 40); this.myLabel.Name = "myLabel"; this.myLabel.Size = new Size(100, 48); this.myLabel.TabIndex = 0; this.myLabel.Text = "Right click me for a context menu"; // // myLabelContextMenu // this.myLabelContextMenu.MenuItems.AddRange( new MenuItem[] { this.myFirstMenuItem, this.menuItem1, this.menuItem2, this.menuItem3, this.menuItem4 }); // // myFirstMenuItem // this.myFirstMenuItem.Index = 0; this.myFirstMenuItem.Text = "Click To Count"; this.myFirstMenuItem.Click += new EventHandler(this.myFirstMenuItem_Click); // // menuItem1 // this.menuItem1.Index = 1; this.menuItem1.Text = "Ambiguous"; // // menuItem2 // this.menuItem2.Index = 2; this.menuItem2.Text = "Ambiguous"; // // menuItem3 // this.menuItem3.Index = 3; this.menuItem3.MenuItems.AddRange(new MenuItem[] { this.menuItem5 }); this.menuItem3.Text = "Test 1"; // // menuItem5 // this.menuItem5.Index = 0; this.menuItem5.Text = "Not Ambiguous"; // // menuItem4 // this.menuItem4.Index = 4; this.menuItem4.MenuItems.AddRange(new MenuItem[] { this.menuItem6 }); this.menuItem4.Text = "Test 2"; // // menuItem6 // this.menuItem6.Index = 0; this.menuItem6.Text = "Not Ambiguous"; // // myCounterLabel // this.myCounterLabel.ContextMenu = this.secondMenu; this.myCounterLabel.Location = new Point(184, 48); this.myCounterLabel.Name = "myCounterLabel"; this.myCounterLabel.TabIndex = 1; this.myCounterLabel.Text = "0"; // // secondMenu // this.secondMenu.MenuItems.AddRange(new MenuItem[] { this.menuItem7 }); // // menuItem7 // this.menuItem7.Index = 0; this.menuItem7.MenuItems.AddRange(new MenuItem[] { this.menuItem8 }); this.menuItem7.Text = "Test 2"; // // menuItem8 // this.menuItem8.Index = 0; this.menuItem8.Text = "Not Ambiguous"; // // ContextMenuTestForm // this.AutoScaleDimensions = new SizeF(5, 13); this.ClientSize = new Size(336, 149); this.Controls.Add(this.myCounterLabel); this.Controls.Add(this.myLabel); this.Name = "ContextMenuTestForm"; this.Text = "ContextMenuTestForm"; this.ResumeLayout(false); }
/// <summary> /// Overloaded Constructor -- 5 -- /// Icon = Programmer must provide, /// Tooltip = Programmer must provide, /// Visibility = Programmer must provide, /// ContextMenu = Programmer must provide. /// </summary> public SystemTrayNotification(System.Windows.Forms.Form form, bool visible, string toolTip, Icon icon, ContextMenu contextMenu) { SystemTrayNotification_base(form, visible, toolTip, icon, contextMenu); }
private void UI_MouseClick(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Right) { return; } ContextMenu cm = new ContextMenu { MenuItems = { new Item("Renderer", self => { foreach (var renderer in availableRenderers) { self.Add(new RadioItem(renderer.RendererName, y => { y.Checked = renderer == _renderer; y.Click += delegate { SetRenderer(renderer); }; })); } }), new Item("Filter", x => { var filters = new Dictionary <string, FilterMode>() { { "None", FilterMode.NearestNeighbor }, { "Linear", FilterMode.Linear }, }; foreach (var filter in filters) { x.Add(new RadioItem(filter.Key, y => { y.Checked = filter.Value == _filterMode; y.Click += delegate { _filterMode = filter.Value; }; })); } }), new SeparatorItem(), new Item("Screenshot (F12)", x => { x.Click += delegate { Screenshot(); }; }), new Item(suspended ? "&Play (F2)" : "&Pause (F3)", x => { x.Click += delegate { suspended ^= true; }; }), new Item("&Speed", x => { foreach (var speed in speeds) { x.Add(new RadioItem($"{speed}x", y => { y.Checked = speed == activeSpeed; y.Click += delegate { activeSpeed = speed; }; })); } }), new Item("Save State", x => { x.Click += delegate { SaveStateToSelectedFile(); }; }), new Item("Load State", x => { x.Click += delegate { LoadStateFromSelectedFile(); }; }), new Item("&Reset..."), } }; cm.Show(this, new Point(e.X, e.Y)); }
private ContextMenu CreateModListContextMenu(ModEntry m, ModTag tag) { var menu = new ContextMenu(); if (m?.ID == null || tag == null) { return(menu); } // change color var changeColorItem = new MenuItem("Change color"); var editColor = new MenuItem("Edit"); editColor.Click += (sender, e) => { var colorPicker = new ColorDialog { AllowFullOpen = true, Color = tag.Color, AnyColor = true, FullOpen = true }; if (colorPicker.ShowDialog() == DialogResult.OK) { tag.Color = colorPicker.Color; } }; changeColorItem.MenuItems.Add(editColor); var makePastelItem = new MenuItem("Make pastel"); makePastelItem.Click += (sender, e) => tag.Color = tag.Color.GetPastelShade(); changeColorItem.MenuItems.Add(makePastelItem); var changeShadeItem = new MenuItem("Random shade"); changeShadeItem.Click += (sender, e) => tag.Color = tag.Color.GetRandomShade(0.33, 1.0); changeColorItem.MenuItems.Add(changeShadeItem); var randomColorItem = new MenuItem("Random color"); randomColorItem.Click += (sender, e) => tag.Color = ModTag.RandomColor(); changeColorItem.MenuItems.Add(randomColorItem); menu.MenuItems.Add(changeColorItem); menu.MenuItems.Add("-"); // renaming tags var renameTagItem = new MenuItem($"Rename '{tag.Label}'"); renameTagItem.Click += (sender, e) => RenameTagPrompt(m, tag, false); menu.MenuItems.Add(renameTagItem); var renameAllTagItem = new MenuItem($"Rename all '{tag.Label}'"); renameAllTagItem.Click += (sender, e) => RenameTagPrompt(m, tag, true); menu.MenuItems.Add(renameAllTagItem); menu.MenuItems.Add("-"); // removing tags var removeTagItem = new MenuItem($"Remove '{tag.Label}'"); removeTagItem.Click += (sender, args) => m.Tags.Remove(tag.Label); menu.MenuItems.Add(removeTagItem); var removeAllTagItem = new MenuItem($"Remove all '{tag.Label}'"); removeAllTagItem.Click += (sender, args) => { if (MessageBox.Show($@"Are you sure you want to remove all instances of tag '{tag.Label}'?", @"Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } foreach (var mod in Mods.All) { for (int i = 0; i < mod.Tags.Count; ++i) { if (mod.Tags[i].ToLower().Equals(tag.Label.ToLower())) { mod.Tags.RemoveAt(i--); } } } }; menu.MenuItems.Add(removeAllTagItem); return(menu); }
/// <summary> /// Sets the context menu for the arrowhead and line. /// </summary> /// <param name="menu">The menu to assign. can be null.</param> public void SetContextMenu(ContextMenu menu) { Line.ContextMenu = menu; Arrowhead.ContextMenu = menu; }
void Row_MouseRightButtonDown(object sender, MouseButtonEventArgs e) { DataGridRow dgr = sender as DataGridRow; if (dgr == null) { return; } if (dgTorrents.Items == null || dgTorrents.Items.Count == 0) { return; } if (dgTorrents.SelectedItems == null || dgTorrents.SelectedItems.Count == 0) { dgTorrents.SelectedItem = dgr.DataContext; } if (dgTorrents.SelectedItems.Count == 1) { dgTorrents.SelectedItem = dgr.DataContext; } ContextMenu m = new ContextMenu(); List <Torrent> selectedTorrents = new List <Torrent>(); foreach (object obj in dgTorrents.SelectedItems) { Torrent tor = obj as Torrent; selectedTorrents.Add(tor); } MenuItem itemStart = new MenuItem(); itemStart.Header = "Start"; itemStart.Click += new RoutedEventHandler(torrentStart); itemStart.CommandParameter = selectedTorrents; MenuItem itemStop = new MenuItem(); itemStop.Header = "Stop"; itemStop.Click += new RoutedEventHandler(torrentStop); itemStop.CommandParameter = selectedTorrents; MenuItem itemPause = new MenuItem(); itemPause.Header = "Pause"; itemPause.Click += new RoutedEventHandler(torrentPause); itemPause.CommandParameter = selectedTorrents; MenuItem itemRemove = new MenuItem(); itemRemove.Header = "Remove Torrent"; itemRemove.Click += new RoutedEventHandler(torrentRemove); itemRemove.CommandParameter = selectedTorrents; MenuItem itemRemoveData = new MenuItem(); itemRemoveData.Header = "Remove Torrent and Files"; itemRemoveData.Click += new RoutedEventHandler(torrentRemoveData); itemRemoveData.CommandParameter = selectedTorrents; if (selectedTorrents.Count == 1) { Torrent tor = selectedTorrents[0]; if (tor.IsNotRunning || tor.IsPaused) { m.Items.Add(itemStart); } if (tor.IsRunning || tor.IsPaused) { m.Items.Add(itemStop); } if (tor.IsRunning) { m.Items.Add(itemPause); } } else { m.Items.Add(itemStart); m.Items.Add(itemStop); m.Items.Add(itemPause); } m.Items.Add(itemRemove); m.Items.Add(itemRemoveData); m.IsOpen = true; }
public void Initialise(ContextMenu parentMenu, string description, StandardDelegate onClickMethod, ContextMenu subMenu) { transform.name = description; this.parentMenu = parentMenu; textLabel.text = description; this.onClickMethod = onClickMethod; this.subMenu = subMenu; if (subMenu == null) { subMenuArrow.gameObject.SetActive(false);//hide the arrow that would show more options } else { subMenu.parentMenu = parentMenu;//show our menu has a parent } }