Exemplo n.º 1
0
    private void UpdateRecentDocuments()
    {
        // remove all old MenuItems
        MenuItemMruEntries.ForEach(delegate(MruEntry o){ MenuItemLevel_menu.Remove(o.MenuItem); });
        MenuItemMruEntries.Clear();

        // find out where to insert the MenuItems
        int insertAt = 0;

        foreach (Gtk.Widget w in MenuItemLevel_menu.Children)
        {
            insertAt++;
            if (w == MenuItemMruBegin)
            {
                break;
            }
        }

        // add all new MenuItems
        Settings.Instance.RecentDocuments.ForEach(delegate(string fileName){
            string shortLabel = System.IO.Path.GetFileName(fileName);

            MruEntry e            = new MruEntry();
            e.MenuItem            = new Gtk.MenuItem(shortLabel);
            e.MenuItem.Activated += OnMruEntry;
            e.FileName            = fileName;
            MenuItemMruEntries.Add(e);
            MenuItemLevel_menu.Insert(e.MenuItem, insertAt);
            e.MenuItem.Show();                                  //everything is hidden when created...
        });
    }
        private void OnTomboyTrayMenuHidden(object sender, EventArgs args)
        {
            // Remove the tasks
            foreach (Gtk.Widget item in top_tasks)
            {
                tomboy_tray_menu.Remove(item);
            }

            top_tasks.Clear();
        }
Exemplo n.º 3
0
        public void CreateMainMenu(Gtk.Menu menu)
        {
            MenuItem show_pad = (MenuItem)menu.Children[0];

            menu.Remove(show_pad);

            menu.Append(ToolBar.CreateMenuItem());
            menu.Append(PixelGrid.CreateMenuItem());
            menu.Append(Rulers.CreateMenuItem());
            menu.Append(ImageTabs.CreateMenuItem());
            menu.AppendSeparator();

            ImageMenuItem zoomin = ZoomIn.CreateAcceleratedMenuItem(Gdk.Key.plus, Gdk.ModifierType.ControlMask);

            zoomin.AddAccelerator("activate", PintaCore.Actions.AccelGroup, new AccelKey(Gdk.Key.equal, Gdk.ModifierType.ControlMask, AccelFlags.Visible));
            zoomin.AddAccelerator("activate", PintaCore.Actions.AccelGroup, new AccelKey(Gdk.Key.equal, 0, AccelFlags.Visible));
            zoomin.AddAccelerator("activate", PintaCore.Actions.AccelGroup, new AccelKey(Gdk.Key.KP_Add, Gdk.ModifierType.ControlMask, AccelFlags.Visible));
            zoomin.AddAccelerator("activate", PintaCore.Actions.AccelGroup, new AccelKey(Gdk.Key.KP_Add, 0, AccelFlags.Visible));
            menu.Append(zoomin);

            ImageMenuItem zoomout = ZoomOut.CreateAcceleratedMenuItem(Gdk.Key.minus, Gdk.ModifierType.ControlMask);

            zoomout.AddAccelerator("activate", PintaCore.Actions.AccelGroup, new AccelKey(Gdk.Key.minus, Gdk.ModifierType.ControlMask, AccelFlags.Visible));
            zoomout.AddAccelerator("activate", PintaCore.Actions.AccelGroup, new AccelKey(Gdk.Key.minus, 0, AccelFlags.Visible));
            zoomout.AddAccelerator("activate", PintaCore.Actions.AccelGroup, new AccelKey(Gdk.Key.KP_Subtract, Gdk.ModifierType.ControlMask, AccelFlags.Visible));
            zoomout.AddAccelerator("activate", PintaCore.Actions.AccelGroup, new AccelKey(Gdk.Key.KP_Subtract, 0, AccelFlags.Visible));
            menu.Append(zoomout);

            ImageMenuItem actualsize = ActualSize.CreateAcceleratedMenuItem(Gdk.Key.Key_0, Gdk.ModifierType.ControlMask);

            actualsize.AddAccelerator("activate", PintaCore.Actions.AccelGroup, new AccelKey(Gdk.Key.A, Gdk.ModifierType.ControlMask | Gdk.ModifierType.ShiftMask, AccelFlags.Visible));
            menu.Append(actualsize);
            menu.Append(ZoomToWindow.CreateAcceleratedMenuItem(Gdk.Key.B, Gdk.ModifierType.ControlMask));
            //menu.Append (ZoomToSelection.CreateAcceleratedMenuItem (Gdk.Key.B, Gdk.ModifierType.ControlMask | Gdk.ModifierType.ShiftMask));
            menu.Append(Fullscreen.CreateAcceleratedMenuItem(Gdk.Key.F11, Gdk.ModifierType.None));

            menu.AppendSeparator();

            Gtk.Action unit_action = new Gtk.Action("RulerUnits", Mono.Unix.Catalog.GetString("Ruler Units"), null, null);
            Menu       unit_menu   = (Menu)menu.AppendItem(unit_action.CreateSubMenuItem()).Submenu;

            unit_menu.Append(Pixels.CreateMenuItem());
            unit_menu.Append(Inches.CreateMenuItem());
            unit_menu.Append(Centimeters.CreateMenuItem());

            menu.AppendSeparator();
            menu.Append(show_pad);
        }
Exemplo n.º 4
0
		/// <summary>
		/// Builds the menu.
		/// </summary>
		private void BuildMenu ()
		{
			MenuBar mbar = (this.UIManager.GetWidget ("/menubarMain") as MenuBar);

			#region FileMenu
			Menu filemenu = new Menu ();
			MenuItem file = new MenuItem ("File");
			file.Submenu = filemenu;
			MenuItem newoption = new MenuItem ("New");
			MenuItem openoption = openAction.CreateMenuItem () as MenuItem;
			MenuItem saveoption = saveAction.CreateMenuItem () as MenuItem; 
			MenuItem saveasoption = saveAsAction.CreateMenuItem () as MenuItem;
			MenuItem recentconfigs = new ImageMenuItem ("Recent Configurations");
			MenuItem exit = quitAction.CreateMenuItem () as MenuItem;

			Menu LastConfigurations = new Menu ();
			recentconfigs.Activated += (object sender, EventArgs e) =>
			{
				foreach (MenuItem mi in LastConfigurations.AllChildren)
				{
					LastConfigurations.Remove (mi);
				}

				foreach (string s in con.LastConfigurationLocations)
				{
					if (!string.IsNullOrEmpty (s))
					{
						MenuItem entry = new MenuItem (s);
						entry.ButtonPressEvent += (object o, ButtonPressEventArgs args) => RunOpenConfig (s);
						LastConfigurations.Append (entry);
					}
				}
				LastConfigurations.ShowAll ();
			};
			exit.Activated += (sender, e) => OnDeleteEvent (null, null);

			filemenu.Append (newoption);
			filemenu.Append (openoption);
			filemenu.Append (saveoption);
			filemenu.Append (saveasoption);
			filemenu.Append (new SeparatorMenuItem ());
			filemenu.Append (recentconfigs);
			recentconfigs.Submenu = LastConfigurations;
			filemenu.Append (new SeparatorMenuItem ());
			filemenu.Append (exit);
			mbar.Append (file);
			#endregion

			#region Edit
			Menu editmenu = new Menu ();
			MenuItem edit = new MenuItem ("Edit");
			edit.Submenu = editmenu;
			MenuItem preferences = preferencesAction.CreateMenuItem () as MenuItem;
			editmenu.Append (preferences);

			mbar.Append (edit);
			#endregion

			#region ConnectionMenu
			Menu connectionmenu = new Menu ();
			MenuItem connection = new MenuItem ("Connection");
			connection.Submenu = connectionmenu;
			var autoConnect = refreshAction.CreateMenuItem () as MenuItem;
			Menu portmenu = new Menu ();
			MenuItem port = new MenuItem ("Port");
			connectionmenu.Append (autoConnect);
			connectionmenu.Append (port);
			port.Submenu = portmenu;

			port.Activated += (object sender, EventArgs e) =>
			{
				foreach (MenuItem mi in portmenu.AllChildren)
				{
					portmenu.Remove (mi);
				}
				foreach (String s in System.IO.Ports.SerialPort.GetPortNames())
				{
					CheckMenuItem portname = new CheckMenuItem (s);
					if (ArduinoController.SerialPortName != null)
					{
						if (ArduinoController.SerialPortName.Equals (s) && ArduinoController.IsConnected)
						{
							portname.Toggle ();
						}
					}

					portname.Toggled += (object senderer, EventArgs ee) =>
					{
						if ((senderer as CheckMenuItem).Active)
						{
							ArduinoController.SerialPortName = ((senderer as CheckMenuItem).Child as Label).Text;
							ArduinoController.Setup ();
						} else
						{
							ArduinoController.Disconnect ();
						}
					};
					portmenu.Append (portname);
				}
				portmenu.ShowAll ();
			};
				
			mbar.Append (connection);
			#endregion

			#region Help
			Menu helpmenu = new Menu ();
			MenuItem help = new MenuItem ("Help");
			help.Submenu = helpmenu;
			MenuItem about = aboutAction.CreateMenuItem () as MenuItem;

			helpmenu.Append (about);

			mbar.Append (help);
			#endregion

			mbar.ShowAll ();

		}