public RadioMenuItem(RadioMenuItem[] group, string label) : base(IntPtr.Zero) { if (GetType () != typeof (RadioMenuItem)) { CreateNativeObject (new string [0], new GLib.Value [0]); AccelLabel al = new AccelLabel (""); al.TextWithMnemonic = label; al.SetAlignment (0.0f, 0.5f); Add (al); al.AccelWidget = this; Group = group; return; } IntPtr native_label = GLib.Marshaller.StringToPtrGStrdup (label); IntPtr native_group = IntPtr.Zero; if (group != null) { GLib.List list = new GLib.List(IntPtr.Zero); foreach (RadioMenuItem item in group) { list.Append (item.Handle); } native_group = list.Handle; } Raw = gtk_radio_menu_item_new_with_mnemonic(native_group, native_label); GLib.Marshaller.Free (native_label); }
public ImageMenuItem (string label) : base (IntPtr.Zero) { if (GetType() != typeof (ImageMenuItem)) { CreateNativeObject (new string [0], new GLib.Value [0]); AccelLabel al = new AccelLabel (""); al.TextWithMnemonic = label; al.SetAlignment (0.0f, 0.5f); Add (al); al.AccelWidget = this; return; } IntPtr native = GLib.Marshaller.StringToPtrGStrdup (label); Raw = gtk_image_menu_item_new_with_mnemonic (native); GLib.Marshaller.Free (native); }
public RadioMenuItem(GLib.SList group, string label) : base(IntPtr.Zero) { if (GetType () != typeof (RadioMenuItem)) { CreateNativeObject (new string [0], new GLib.Value [0]); AccelLabel al = new AccelLabel (""); al.TextWithMnemonic = label; al.SetAlignment (0.0f, 0.5f); Add (al); al.AccelWidget = this; Group = group; return; } IntPtr native_label = GLib.Marshaller.StringToPtrGStrdup (label); Raw = gtk_radio_menu_item_new_with_mnemonic(group == null ? IntPtr.Zero : group.Handle, native_label); GLib.Marshaller.Free (native_label); }
/// <summary> /// Add an action (on context menu) on the series grid. /// </summary> /// <param name="menuItemText">The text of the menu item</param> /// <param name="onClick">The event handler to call when menu is selected</param> public void AddContextOption(string menuItemText, System.EventHandler onClick, bool active) { CheckMenuItem item = null; foreach (Widget w in Popup) { CheckMenuItem oldItem = w as CheckMenuItem; if (oldItem != null) { AccelLabel itemText = oldItem.Child as AccelLabel; if (itemText.Text == menuItemText) { item = oldItem; // Deactivate the "Activate" handler PropertyInfo pi = item.GetType().GetProperty("AfterSignals", BindingFlags.NonPublic | BindingFlags.Instance); if (pi != null) { System.Collections.Hashtable handlers = (System.Collections.Hashtable)pi.GetValue(w); if (handlers != null && handlers.ContainsKey("activate")) { EventHandler handler = (EventHandler)handlers["activate"]; item.Activated -= handler; } } break; } } } if (item == null) { item = new CheckMenuItem(menuItemText); item.DrawAsRadio = false; Popup.Append(item); Popup.ShowAll(); } // Be sure to set the Active property before attaching the Activated event, since // the event handler will call this function again when Active is changed. // This can lead to infinite recursion. This is also why we deactivate the handler // (done above) when the item is already found in the menu item.Active = active; item.Activated += onClick; }
public void Load() { Console.WriteLine("testplugin starting"); bool pluginsmenufound = false; Menu pluginsmenu = null; foreach (Widget widget in MainUI.GetInstance().uiwindow.menubar1.Children) { Console.WriteLine(widget.Name + " " + widget.GetType().ToString()); MenuItem menuitem = widget as MenuItem; foreach (Widget subwidget in menuitem.Children) { Console.WriteLine(subwidget.Name + " " + subwidget.GetType().ToString()); AccelLabel accellabel = subwidget as AccelLabel; Console.WriteLine(accellabel.Text); if (accellabel.Text.ToLower() == "plugins") { pluginsmenufound = true; pluginsmenu = menuitem.Submenu as Menu; } } } if (!pluginsmenufound) { MenuItem pluginsmenuitem = new MenuItem("Plugins"); MainUI.GetInstance().uiwindow.menubar1.Add(pluginsmenuitem); pluginsmenu = new Menu(); pluginsmenuitem.Submenu = pluginsmenu; pluginsmenuitem.ShowAll(); } MenuItem Testpluginmenuitem = new MenuItem("About TestPlugin..."); Testpluginmenuitem.Activated += new EventHandler(Testpluginmenuitem_Activated); pluginsmenu.Add(Testpluginmenuitem); Testpluginmenuitem.Show(); pluginsmenu.ShowAll(); }
// // Constructor // public InfoManager(MainWindow main, string profilePath) { this.main = main; if (profilePath == null) { string corlibdir = System.IO.Path.GetDirectoryName(typeof(int).Assembly.Location); monodir = System.IO.Path.GetFullPath(System.IO.Path.Combine(corlibdir, "..")); } else { monodir = profilePath; } moondir = System.IO.Path.Combine(monodir, @"../moonlight/plugin"); // Work around limitation in Stetic, there is no way // of getting a handle on the menu (!!!) // Populate File/Recent Comparisons, this would be so much // easier if Stetic had any support for this. recentmenu = new Menu(); MenuItem filemenuitem = (main.MenuBar.Children [0]) as MenuItem; Menu filesub = (Menu)filemenuitem.Submenu; MenuItem recentmenuitem = new MenuItem("Recent Comparisons"); recentmenuitem.Submenu = recentmenu; recentmenuitem.ShowAll(); filesub.Insert(recentmenuitem, 0); MenuItem sep = new MenuItem(); sep.ShowAll(); filesub.Insert(sep, 1); PopulateRecent(); // Populate the list of profile comparisons Menu sub = null; foreach (MenuItem mi in main.MenuBar.AllChildren) { AccelLabel a = mi.Child as AccelLabel; if (a == null || a.LabelProp != "_Compare") { continue; } if (a.LabelProp == "Recent Comparisons") { } sub = (Menu)mi.Submenu; break; } if (sub == null) { Console.WriteLine("Unable to found Compare submenu"); return; } MenuItem separator = new SeparatorMenuItem(); separator.ShowAll(); sub.Add(separator); Populate(sub, "API 1.1", GetVersionPath("1.0", "net_1_1"), "1.0", api_1_1); Populate(sub, "API 2.0 sp2", GetVersionPath("2.0", "net_2_0"), "2.0", api_2_0); Populate(sub, "API 3.0 sp1", GetVersionPath("2.0", "net_2_0"), "3.0", api_3_0); Populate(sub, "API 3.5 sp1", GetVersionPath("2.0", "net_2_0"), "3.5", api_3_5); Populate(sub, "API 4.0", GetVersionPath("4.0", "net_4_0"), "4.0", api_4_0); Populate(sub, "API 4.5", GetVersionPath("4.5", "net_4_5"), "4.5", api_4_5); // Populate (sub, "Silverlight 2.0", GetVersionPath ("2.1", "net_2_1"), "SL2", api_sl2); // Populate (sub, "Silverlight 3.0", GetVersionPath ("2.1", "net_2_1"), "SL3", api_sl2); Populate(sub, "Silverlight 4.0", GetVersionPath("2.1", "net_2_1"), "SL4", api_sl4); }