Inheritance: Eto.Forms.Menu, ISubMenuWidget
示例#1
0
        public CSyclesForm(string path)
        {
            ClientSize = new Eto.Drawing.Size(500, 500);
            Title      = "CSycles Tester";
            Path       = path;

            Image = new ef.ImageView();
            var layout = new ef.TableLayout();

            layout.Rows.Add(
                new ef.TableRow(
                    Image
                    )
                );

            var scenes = Directory.EnumerateFiles(path, "scene*.xml");

            Menu = new ef.MenuBar();
            var scenesmenu = Menu.Items.GetSubmenu("scenes");

            foreach (var sf in scenes)
            {
                scenesmenu.Items.Add(new RenderModalCommand(this, sf));
            }

            Content = layout;

            var m = new RendererModel();

            DataContext = m;
        }
示例#2
0
文件: Main.cs 项目: mhusen/Eto
		public MyForm()
		{
			ClientSize = new Size(600, 400);
			Title = "Table Layout";


			Content = new TableLayout(
				new TableRow(new Label { Text = "DataContext Binding" }, DataContextBinding()),
				new TableRow(new Label { Text = "Object Binding" }, ObjectBinding()),
				new TableRow(new Label { Text = "Direct Binding" }, DirectBinding()),
				null // same as creating a row with ScaleHeight = true
			) { Spacing = new Size(5, 5), Padding = new Padding(10) };

			// Set data context so it propegates to all child controls
			DataContext = new MyObject { TextProperty = "Initial value 1" };

			Menu = new MenuBar
			{
				QuitItem = new Command((sender, e) => Application.Instance.Quit())
				{ 
					MenuText = "Quit",
					Shortcut = Application.Instance.CommonModifier | Keys.Q
				}
			};
		}
示例#3
0
        public CSyclesForm(string path)
        {
            ClientSize = new Eto.Drawing.Size(500, 500);
            Title = "CSycles Tester";
            Path = path;

            Image = new ef.ImageView();
            var layout = new ef.TableLayout();
            layout.Rows.Add(
                new ef.TableRow(
                    Image
                    )
                );

            var scenes = Directory.EnumerateFiles(path, "scene*.xml");
            Menu = new ef.MenuBar();
            var scenesmenu = Menu.Items.GetSubmenu("scenes");
            foreach(var sf in scenes)
            {
                scenesmenu.Items.Add(new RenderModalCommand(this, sf));
            }

            Content = layout;

            var m = new RendererModel();
            DataContext = m;
        }
示例#4
0
        public MainForm()
        {
            Title = "MachoMap";
            Size = new Size(1280, 800);

            Menu = new MenuBar();
            ButtonMenuItem fileMenu = Menu.Items.GetSubmenu("&File");
            fileMenu.Items.AddRange(new Command[] { new NewWindowCommand(), new OpenFileCommand(this) });
        }
示例#5
0
文件: Main.cs 项目: mhusen/Eto
		public MyForm()
		{
			ClientSize = new Size(600, 400);
			Title = "Table Layout";

			// The main layout mechanism for Eto.Forms is a TableLayout.
			// This is recommended to allow controls to keep their natural platform-specific size.
			// You can layout your controls declaratively using rows and columns as below, or add to the TableLayout.Rows and TableRow.Cell directly.

			Content = new TableLayout
			{
				Spacing = new Size(5, 5), // space between each cell
				Padding = new Padding(10, 10, 10, 10), // space around the table's sides
				Rows =
				{
					new TableRow(
						new TableCell(new Label { Text = "First Column" }, true), 
						new TableCell(new Label { Text = "Second Column" }, true),
						new Label { Text = "Third Column" }
					),
					new TableRow(
						new TextBox { Text = "Some text" },
						new DropDown { Items = { "Item 1", "Item 2", "Item 3" } },
						new CheckBox { Text = "A checkbox" }
					),
					// by default, the last row & column will get scaled. This adds a row at the end to take the extra space of the form.
					// otherwise, the above row will get scaled and stretch the TextBox/ComboBox/CheckBox to fill the remaining height.
					new TableRow { ScaleHeight = true }
				}
			};

			// This creates the following layout:
			//  --------------------------------
			// |First     |Second    |Third     |
			//  --------------------------------
			// |<TextBox> |<ComboBox>|<CheckBox>|
			//  --------------------------------
			// |          |          |          |
			// |          |          |          |
			//  --------------------------------
			//
			// Some notes:
			//  1. When scaling the width of a cell, it applies to all cells in the same column.
			//  2. When scaling the height of a row, it applies to the entire row.
			//  3. Scaling a row/column makes it share all remaining space with other scaled rows/columns.
			//  4. If a row/column is not scaled, it will be the size of the largest control in that row/column.
			//  5. A Control can be implicitly converted to a TableCell or TableRow to make the layout more concise.

			Menu = new MenuBar
			{
				QuitItem = new Command((sender, e) => Application.Instance.Quit())
				{
					MenuText = "Quit",
					Shortcut = Application.Instance.CommonModifier | Keys.Q
				}
			};
		}
示例#6
0
文件: Main.cs 项目: Exe0/Eto
		MenuBar CreateMenu()
		{
			var menu = new MenuBar();
			// add standard menu items (e.g. for OS X)
			Application.Instance.CreateStandardMenu(menu.Items);

			// add command to file sub-menu
			var file = menu.Items.GetSubmenu("&File");
			file.Items.Add(new MyCommand());

			return menu;
		}
示例#7
0
		private void Construct()
		{
			Title = "My Eto Form";
			ClientSize = new Size(400, 350);

            lblContent = new Label { Text = "Hello World!" };
            prgBar = new ProgressBar();

			// scrollable region as the main content
			Content = new Scrollable
			{
				// table with three rows
				Content = new TableLayout(
					null,
					// row with three columns
					new TableRow(null, lblContent, null),
                    new TableRow(null, prgBar, null)
				)
			};

			// create a few commands that can be used for the menu and toolbar
            cmdButton = new Command { MenuText = "Click Me!", ToolBarText = "Click Me!" };

			var quitCommand = new Command { MenuText = "Quit", Shortcut = Application.Instance.CommonModifier | Keys.Q };
			quitCommand.Executed += (sender, e) => Application.Instance.Quit();

			var aboutCommand = new Command { MenuText = "About..." };
			aboutCommand.Executed += (sender, e) => MessageBox.Show(this, "About my app...");

			// create menu
			Menu = new MenuBar
			{
				Items =
				{
					// File submenu
					new ButtonMenuItem { Text = "&File", Items = { cmdButton } },
					// new ButtonMenuItem { Text = "&Edit", Items = { /* commands/items */ } },
					// new ButtonMenuItem { Text = "&View", Items = { /* commands/items */ } },
				},
				ApplicationItems =
				{
					// application (OS X) or file menu (others)
					new ButtonMenuItem { Text = "&Preferences..." },
				},
				QuitItem = quitCommand,
				AboutItem = aboutCommand
			};

			// create toolbar			
            ToolBar = new ToolBar { Items = { cmdButton } };
		}
示例#8
0
		MenuBar GenerateMenuBar()
		{
			var docs = new Actions.Docs();
            var checkUpdate = new Actions.CheckUpdate();
			var about = new Actions.About();
			var quit = new Actions.Quit();
			var setting = new Actions.Setting();

			//var file = new ButtonMenuItem {Text = AltStrRes.File, ID = "File"};
			var service = _servicesMenuItem = new ButtonMenuItem { Text = AltStrRes.Services, ID = "Services" };
			var plugin = _pluginsMenuItem = new ButtonMenuItem { Text = AltStrRes.Plugins, ID = "Plugins" };
			//var help = new ButtonMenuItem { Text = AltStrRes.Help, ID = "Help" };

			var menuBar = new MenuBar
			{
				Trim = false,
				Items =
				{
					service,
					plugin
				},
				ApplicationItems =
				{
					setting
				},
				HelpItems =
				{
					docs,
                    checkUpdate
				},
				QuitItem = quit,
				AboutItem = about,
				IncludeSystemItems = MenuBarSystemItems.None
			};
			var file = menuBar.ApplicationMenu;
			file.ID = "File";
			if (!Platform.IsMac)
			{
				file.Text = AltStrRes.File;
			}

			var help = menuBar.HelpMenu;
			help.ID = "Help";
			help.Text = AltStrRes.Help;

			return menuBar;
		}
示例#9
0
文件: Main.cs 项目: mhusen/Eto
		public MyForm()
		{
			ClientSize = new Size(600, 400);
			Title = "Menus and Toolbars";

			// create menu
			Menu = new MenuBar
			{
				Items =
				{
					new ButtonMenuItem
					{ 
						Text = "&File",
						Items =
						{ 
							// you can add commands or menu items
							new MyCommand(),
							new ButtonMenuItem { Text = "Click Me, MenuItem" }
						}
					} 
				},
				// quit item (goes in Application menu on OS X, File menu for others)
				QuitItem = new Command((sender, e) => Application.Instance.Quit())
				{ 
					MenuText = "Quit", 
					Shortcut = Application.Instance.CommonModifier | Keys.Q
				},
				// about command (goes in Application menu on OS X, Help menu for others)
				AboutItem = new Command((sender, e) => new Dialog { Content = new Label { Text = "About my app..." }, ClientSize = new Size(200, 200) }.ShowModal(this))
				{ 
					MenuText = "About my app"
				}
			};

			// create toolbar
			ToolBar = new ToolBar
			{
				Items =
				{ 
					new MyCommand(),
					new SeparatorToolItem(),
					new ButtonToolItem { Text = "Click Me, ToolItem" }
				}
			};
		}
示例#10
0
文件: MainForm.cs 项目: mhusen/Eto
		public MainForm()
		{
			Menu = new MenuBar();

			// create a new native MonoMac view and wrap it in an eto control
			var nativeControl = new MyNativeWidget().ToEto();

			Content = new TableLayout
			{
				Padding = new Padding(10),
				Spacing = new Size(5, 5),
				Rows =
				{
					nativeControl,
					null,
					new TableLayout(new TableRow(null, new Button { Text = "An Eto.Forms button" })),
				}
			};
		}
示例#11
0
        void CreateActions()
        {
            var menu = new MenuBar();
            Application.Instance.CreateStandardMenu(menu.Items);

            var file = menu.Items.GetSubmenu("&File", 100);
            var help = menu.Items.GetSubmenu("&Help", 900);
            var server = menu.Items.GetSubmenu("&Server", 500);
            var view = menu.Items.GetSubmenu("&View", 500);
            

            server.Items.Add(new Actions.ServerConnect(top.Channels), 500);
            server.Items.Add(new Actions.ServerDisconnect(top.Channels), 500);
            server.Items.AddSeparator(500);
            server.Items.Add(new Actions.AddServer { AutoConnect = true }, 500);
            server.Items.Add(new Actions.EditServer(top.Channels), 500);
            server.Items.Add(new Actions.RemoveServer(top.Channels, config), 500);
            server.Items.AddSeparator(500);
            server.Items.Add(new Actions.ChannelList(top.Channels), 500);
            
            if (Generator.IsMac)
            {
                var application = menu.Items.GetSubmenu(Application.Instance.Name, 100);
                application.Items.Add(new Actions.About(), 100);
#if DEBUG
                // TODO: not yet implemented!
				application.Items.Add(new Actions.ShowPreferences(config), 500);
#endif
                application.Items.Add(new Actions.Quit(), 900);
            }
            else
            {
                file.Items.Add(new Actions.Quit(), 900);
                view.Items.Add(new Actions.ShowPreferences(config), 500);
                help.Items.Add(new Actions.About(), 100);
            }
            
            top.CreateActions(menu.Items);

			menu.Items.Trim();
            Menu = menu;
        }
示例#12
0
        void GenerateMenu()
        {
            var menu = new MenuBar
            {
                AboutItem = new Commands.About(),
                QuitItem = new Commands.Quit(),
            };

            var file = menu.Items.GetSubmenu("&File");
            file.Items.Add(new Commands.Save());
            file.Items.Add(new Commands.New());
            file.Items.Add(new Commands.Delete());
            file.Items.Add(new Commands.Rename());
            file.Items.Add(new SeparatorMenuItem());

            menu.ApplicationItems.Add(new Commands.Preferences(), 900);

            Notes.GenerateMenu(menu);

            Menu = menu;
        }
示例#13
0
 private void CreateMenu()
 {
     Menu = new MenuBar
     {
         Items =
         {
             new ButtonMenuItem {Text = "&File", Items = {_clickMe}},
             //new ButtonMenuItem { Text = "&Edit", Items = { /* commands/items */ } },
             //new ButtonMenuItem { Text = "&View", Items = { /* commands/items */ } },
         },
         ApplicationItems =
         {
             new ButtonMenuItem {Text = "&Preferences..."},
         },
         QuitItem = _quitCommand,
         AboutItem = _aboutCommand
     };
 }
示例#14
0
		void CreateMenuToolBar()
		{
			var about = new Commands.About();
			var quit = new Commands.Quit();

			if (Platform.Supports<MenuBar>())
			{
				Menu = new MenuBar
				{
					Items =
					{
						// custom top-level menu items
						new ButtonMenuItem { Text = "&File", Items = { new Command { MenuText = "File Command" } } },
						new ButtonMenuItem { Text = "&Edit", Items = { new Command { MenuText = "Edit Command" } } },
						new ButtonMenuItem { Text = "&View", Items = { new Command { MenuText = "View Command" } } },
						new ButtonMenuItem { Text = "&Window", Order = 1000, Items = { new Command { MenuText = "Window Command" } } },
					},
					ApplicationItems =
					{
						// custom menu items for the application menu (Application on OS X, File on others)
						new Command { MenuText = "Application command" },
						new ButtonMenuItem { Text = "Application menu item" }
					},
					HelpItems =
					{
						new Command { MenuText = "Help Command" }
					},
					QuitItem = quit,
					AboutItem = about
				};
			}

			if (Platform.Supports<ToolBar>())
			{
				// create and set the toolbar
				ToolBar = new ToolBar();

				ToolBar.Items.Add(about);
				if (Platform.Supports<CheckToolItem>())
				{
					ToolBar.Items.Add(new SeparatorToolItem { Type = SeparatorToolItemType.Divider });
					ToolBar.Items.Add(new CheckToolItem { Text = "Check", Image = TestIcons.TestImage });
				}
				if (Platform.Supports<RadioToolItem>())
				{
					ToolBar.Items.Add(new SeparatorToolItem { Type = SeparatorToolItemType.FlexibleSpace });
					ToolBar.Items.Add(new RadioToolItem { Text = "Radio1", Image = TestIcons.TestIcon, Checked = true });
					ToolBar.Items.Add(new RadioToolItem { Text = "Radio2", Image = TestIcons.TestImage });
				};
			}

		}
示例#15
0
		Control MainContent()
		{
			contentContainer = new Panel();

			// set focus when the form is shown
			Shown += delegate
			{
				SectionList.Focus();
			};
			SectionList.SelectedItemChanged += (sender, e) =>
			{
				try
				{
					var item = SectionList.SelectedItem;
					Control content = item != null ? item.CreateContent() : null;

					if (navigation != null)
					{
						if (content != null)
							navigation.Push(content, item != null ? item.Text : null);
					}
					else
					{
						contentContainer.Content = content;
					}
				}
				catch (Exception ex)
				{
					Log.Write(this, "Error loading section: {0}", ex.GetBaseException());
					contentContainer.Content = null;
				}

				#if DEBUG
				GC.Collect();
				GC.WaitForPendingFinalizers();
				#endif
			};

			if (Splitter.IsSupported())
			{
				var splitter = new Splitter
				{
					Position = 200,
					FixedPanel = SplitterFixedPanel.Panel1,
					Panel1 = SectionList.Control,
#if MOBILE
					// for now, don't show log in mobile
					Panel2 = contentContainer
#else
					Panel2 = RightPane()
#endif
				};
				return splitter;
			}
			if (Navigation.IsSupported())
			{
				navigation = new Navigation(SectionList.Control, "Eto.Test");
				return navigation;
			}
			throw new EtoException("Platform must support splitter or navigation");

		}

		Control RightPane()
		{
			return new Splitter
			{
				Orientation = SplitterOrientation.Vertical,
				FixedPanel = SplitterFixedPanel.Panel2,
				Panel1 = contentContainer,
				Panel2 = EventLogSection()
			};
		}

		Control EventLogSection()
		{
			var layout = new DynamicLayout { Size = new Size(100, 120) };
			
			layout.BeginHorizontal();
			layout.Add(EventLog, true);
			
			layout.BeginVertical();
			layout.Add(ClearButton());
			layout.Add(null);
			layout.EndVertical();
			layout.EndHorizontal();
			return layout;
		}

		Control ClearButton()
		{
			var control = new Button
			{
				Text = "Clear"
			};
			control.Click += (sender, e) => EventLog.Text = string.Empty;
			return control;
		}

		void GenerateMenuToolBar()
		{
			var about = new Actions.About();
			var quit = new Actions.Quit();

#if DESKTOP
			var menu = new MenuBar();
			// create standard system menu (e.g. for OS X)
			Application.Instance.CreateStandardMenu(menu.Items);

			// add our own items to the menu

			var file = menu.Items.GetSubmenu("&File", 100);
			menu.Items.GetSubmenu("&Edit", 200);
			menu.Items.GetSubmenu("&Window", 900);
			var help = menu.Items.GetSubmenu("&Help", 1000);

			if (Generator.IsMac)
			{
				// have a nice OS X style menu
				var main = menu.Items.GetSubmenu(Application.Instance.Name, 0);
				main.Items.Add(about, 0);
				main.Items.Add(quit, 1000);
			}
			else
			{
				// windows/gtk style window
				file.Items.Add(quit);
				help.Items.Add(about);
			}

			// optional, removes empty submenus and duplicate separators
			menu.Items.Trim();

			Menu = menu;
#endif

			// generate and set the toolbar
			var toolBar = new ToolBar();
			toolBar.Items.Add(quit);
			toolBar.Items.Add(new ButtonToolItem(about));

			ToolBar = toolBar;
		}
		public MenuBar GenerateMenuBar()
		{
			var menu = new MenuBar(Generator);
			Generate (menu);
			return menu;
		}
示例#17
0
		public static MenuBar CreateStandardMenu(IEnumerable<Command> commands = null)
		{
			var menu = new MenuBar();
			menu.CreateLegacySystemMenu();
			return menu;
		}
示例#18
0
文件: MainForm.cs 项目: mhusen/Eto
		void CreateMenuToolBar()
		{
			var about = new Commands.About();
			var quit = new Commands.Quit();

			if (Platform.Supports<MenuBar>())
			{
				var fileCommand = new Command { MenuText = "File Command", Shortcut = Application.Instance.CommonModifier | Keys.F };
				fileCommand.Executed += (sender, e) => Log.Write(sender, "Executed");
				var editCommand = new Command { MenuText = "Edit Command", Shortcut = Keys.Shift | Keys.E };
				editCommand.Executed += (sender, e) => Log.Write(sender, "Executed");
				var viewCommand = new Command { MenuText = "View Command", Shortcut = Keys.Control | Keys.V };
				viewCommand.Executed += (sender, e) => Log.Write(sender, "Executed");
				var windowCommand = new Command { MenuText = "Window Command" };
				windowCommand.Executed += (sender, e) => Log.Write(sender, "Executed");

				var file = new ButtonMenuItem { Text = "&File", Items = { fileCommand } };
				var edit = new ButtonMenuItem { Text = "&Edit", Items = { editCommand } };
                var view = new ButtonMenuItem { Text = "&View", Items = { viewCommand } };
				var window = new ButtonMenuItem { Text = "&Window", Order = 1000, Items = { windowCommand } };

				if (Platform.Supports<CheckMenuItem>())
				{
					edit.Items.AddSeparator();

					var checkMenuItem1 = new CheckMenuItem { Text = "Check Menu Item", Shortcut = Keys.Shift | Keys.K };
					checkMenuItem1.Click += (sender, e) => Log.Write(checkMenuItem1, "Click, {0}, Checked: {1}", checkMenuItem1.Text, checkMenuItem1.Checked);
					checkMenuItem1.CheckedChanged += (sender, e) => Log.Write(checkMenuItem1, "CheckedChanged, {0}: {1}", checkMenuItem1.Text, checkMenuItem1.Checked);
					edit.Items.Add(checkMenuItem1);

					var checkMenuItem2 = new CheckMenuItem { Text = "Initially Checked Menu Item", Checked = true };
					checkMenuItem2.Click += (sender, e) => Log.Write(checkMenuItem2, "Click, {0}, Checked: {1}", checkMenuItem2.Text, checkMenuItem2.Checked);
					checkMenuItem2.CheckedChanged += (sender, e) => Log.Write(checkMenuItem2, "CheckedChanged, {0}: {1}", checkMenuItem2.Text, checkMenuItem2.Checked);
					edit.Items.Add(checkMenuItem2);
				}

				if (Platform.Supports<RadioMenuItem>())
				{
					edit.Items.AddSeparator();

					RadioMenuItem controller = null;
					for (int i = 0; i < 5; i++)
					{
						var radio = new RadioMenuItem(controller) { Text = "Radio Menu Item " + (i + 1) };
						radio.Click += (sender, e) => Log.Write(radio, "Click, {0}, Checked: {1}", radio.Text, radio.Checked);
						radio.CheckedChanged += (sender, e) => Log.Write(radio, "CheckedChanged, {0}: {1}", radio.Text, radio.Checked);
						edit.Items.Add(radio);

						if (controller == null)
						{
							radio.Checked = true; // check the first item initially
							controller = radio;
						}
					}

				}

				Menu = new MenuBar
				{
					Items =
					{
						// custom top-level menu items
						file, edit, view, window
					},
					ApplicationItems =
					{
						// custom menu items for the application menu (Application on OS X, File on others)
						new Command { MenuText = "Application command" },
						new ButtonMenuItem { Text = "Application menu item" }
					},
					HelpItems =
					{
						new Command { MenuText = "Help Command" }
					},
					QuitItem = quit,
					AboutItem = about
				};
			}

			if (Platform.Supports<ToolBar>())
			{
				// create and set the toolbar
				ToolBar = new ToolBar();

				ToolBar.Items.Add(about);
				if (Platform.Supports<CheckToolItem>())
				{
					ToolBar.Items.Add(new SeparatorToolItem { Type = SeparatorToolItemType.Divider });
					ToolBar.Items.Add(new CheckToolItem { Text = "Check", Image = TestIcons.TestImage });
				}
				if (Platform.Supports<RadioToolItem>())
				{
					ToolBar.Items.Add(new SeparatorToolItem { Type = SeparatorToolItemType.FlexibleSpace });
					ToolBar.Items.Add(new RadioToolItem { Text = "Radio1", Image = TestIcons.TestIcon, Checked = true });
					ToolBar.Items.Add(new RadioToolItem { Text = "Radio2", Image = TestIcons.TestImage });
				};
			}

		}
示例#19
0
文件: Application.cs 项目: Exe0/Eto
		public void GetSystemActions(GenerateActionArgs args, bool addStandardItems = false)
		{
			// map new commands/menus back to actions for backwards compatibility
			var commands = GetSystemCommands().ToArray();
			foreach (var command in commands)
			{
				var currentCommand = command;
				var action = new ButtonAction
				{
					ID = currentCommand.ID,
					MenuText = currentCommand.MenuText,
					ToolBarText = currentCommand.ToolBarText,
					TooltipText = currentCommand.ToolTip,
					Accelerator = currentCommand.Shortcut,
					command = currentCommand
				};
				currentCommand.Executed += (sender, e) => action.Activate();
				action.EnabledChanged += (sender, e) => currentCommand.Enabled = action.Enabled;
				args.Actions.Add(action);
			}
			#if DESKTOP
			if (addStandardItems)
			{
				var menu = new MenuBar(Generator);
				CreateStandardMenu(menu.Items, commands);
				args.Menu.ExtractMenu(menu);
			}
			#endif
		}
示例#20
-1
        void InitializeComponent()
        {
            Title = "My Eto Form";
            ClientSize = new Size(400, 350);

            Content = new StackLayout
            {
                Padding = 10,
                Items =
                {
                    "Hello World!",
                    // add more controls here
                }
            };

            // create a few commands that can be used for the menu and toolbar
            var clickMe = new Command { MenuText = "Click Me!", ToolBarText = "Click Me!" };
            clickMe.Executed += (sender, e) => MessageBox.Show(this, "I was clicked!");

            var quitCommand = new Command { MenuText = "Quit", Shortcut = Application.Instance.CommonModifier | Keys.Q };
            quitCommand.Executed += (sender, e) => Application.Instance.Quit();

            var aboutCommand = new Command { MenuText = "About..." };
            aboutCommand.Executed += (sender, e) => MessageBox.Show(this, "About my app...");

            // create menu
            Menu = new MenuBar
            {
                Items =
                    {
					    // File submenu
					    new ButtonMenuItem { Text = "&File", Items = { clickMe } },
					    // new ButtonMenuItem { Text = "&Edit", Items = { /* commands/items */ } },
					    // new ButtonMenuItem { Text = "&View", Items = { /* commands/items */ } },
				    },
                ApplicationItems =
                    {
					    // application (OS X) or file menu (others)
					    new ButtonMenuItem { Text = "&Preferences..." },
                    },
                QuitItem = quitCommand,
                AboutItem = aboutCommand
            };

            // create toolbar			
            ToolBar = new ToolBar { Items = { clickMe } };
        }
示例#21
-1
        void RenderMenu()
        {
            CommandExport = new Command(OnCommandExport) {
                MenuText = Desktop.Properties.Resources.MenuExport,
                Image = Utilities.LoadImage("Export"),
                Shortcut = Application.Instance.CommonModifier | Keys.E,
                Enabled = false
            };

            CommandAccountUnlock = new Command(OnCommandAccountUnlock) {
                MenuText = Desktop.Properties.Resources.MenuUnlockAccount,
                Image = Utilities.LoadImage("Key")
            };

            CommandAccountChangePassphrase = new Command(OnCommandAccountChangePassphrase) {
                MenuText = Desktop.Properties.Resources.MenuChangeAccountPassphrase,
                Image = Utilities.LoadImage("Key"),
                Enabled = false
            };

            var commandAccountBackupManager = new Command(OnCommandAccountBackupManager) {
                MenuText = Desktop.Properties.Resources.MenuBackupManager,
                Image = Utilities.LoadImage("Save"),
                Enabled = false
            };

            var commandExit = new Command(OnCommandExit) {
                MenuText = Desktop.Properties.Resources.MenuExit,
                Image = Utilities.LoadImage("Exit"),
                Shortcut = Application.Instance.CommonModifier | Keys.Q
            };

            var commandShowWindowOptions = new Command(OnCommandShowWindowOptions) {
                MenuText = Desktop.Properties.Resources.MenuOptions,
                Image = Utilities.LoadImage("Options"),
                Shortcut = Application.Instance.CommonModifier | Keys.O
            };

            var commandShowWindowAbout = new Command(OnCommandShowWindowAbout) {
                MenuText = Desktop.Properties.Resources.MenuAbout,
                Image = Utilities.LoadImage("Information"),
            };

            var menuFile = new ButtonMenuItem {
                Text = Desktop.Properties.Resources.MenuFile,
                Items = {
                    commandAccountBackupManager,
                    CommandExport,
                    new SeparatorMenuItem(),
                    commandExit
                }
            };

            MenuSettings = new ButtonMenuItem {
                Text = Desktop.Properties.Resources.MenuSettings,
                Items = {
                    CommandAccountUnlock,
                    new SeparatorMenuItem(),
                    commandShowWindowOptions
                }
            };

            var menuHelp = new ButtonMenuItem {
                Text = Desktop.Properties.Resources.MenuHelp,
                Items = {
                    commandShowWindowAbout
                }
            };

            Menu = new MenuBar(
                menuFile,
                MenuSettings,
                menuHelp
            );
        }
示例#22
-1
        /// <summary>
        /// 
        /// </summary>
        private void InitializeMenu()
        {
            #region File

            var newCommand = new Command()
            {
                MenuText = "&New",
                Shortcut = Application.Instance.CommonModifier | Keys.N
            };

            newCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.NewCommand.Execute(null);
                if (_context.Invalidate != null)
                {
                    _context.Invalidate();
                }
            };

            var openCommand = new Command()
            {
                MenuText = "&Open...",
                Shortcut = Application.Instance.CommonModifier | Keys.O
            };

            openCommand.Executed +=
            (s, e) =>
            {
                var dlg = new OpenFileDialog();
                dlg.Filters.Add(new FileDialogFilter("Project", ".project"));
                dlg.Filters.Add(new FileDialogFilter("All", ".*"));

                var result = dlg.ShowDialog(this);
                if (result == DialogResult.Ok)
                {
                    _context.Open(dlg.FileName);
                    if (_context.Invalidate != null)
                    {
                        _context.Invalidate();
                    }
                }
            };

            var saveAsCommand = new Command()
            {
                MenuText = "Save &As...",
                Shortcut = Application.Instance.CommonModifier | Keys.S
            };

            saveAsCommand.Executed +=
            (s, e) =>
            {
                var dlg = new SaveFileDialog();
                dlg.Filters.Add(new FileDialogFilter("Project", ".project"));
                dlg.Filters.Add(new FileDialogFilter("All", ".*"));
                dlg.FileName = _context.Editor.Project.Name;
                var result = dlg.ShowDialog(this);
                if (result == DialogResult.Ok)
                {
                    _context.Save(dlg.FileName);
                }
            };

            var exportCommand = new Command()
            {
                MenuText = "&Export...",
                Shortcut = Application.Instance.CommonModifier | Keys.E
            };

            exportCommand.Executed +=
            (s, e) =>
            {
                var dlg = new SaveFileDialog();
                dlg.Filters.Add(new FileDialogFilter("Pdf", ".pdf"));
                dlg.Filters.Add(new FileDialogFilter("Dxf", ".dxf"));
                dlg.Filters.Add(new FileDialogFilter("All", ".*"));

                dlg.FileName = _context.Editor.Project.Name;
                var result = dlg.ShowDialog(this);
                if (result == DialogResult.Ok)
                {
                    string path = dlg.FileName;
                    int filterIndex = dlg.CurrentFilterIndex;
                    switch (filterIndex)
                    {
                        case 0:
                            _context.ExportAsPdf(path, _context.Editor.Project);
                            Process.Start(path);
                            break;
                        case 1:
                            _context.ExportAsDxf(path);
                            Process.Start(path);
                            break;
                        default:
                            break;
                    }
                }
            };

            var exitCommand = new Command()
            {
                MenuText = "E&xit",
                Shortcut = Application.Instance.AlternateModifier | Keys.F4
            };

            exitCommand.Executed +=
            (s, e) =>
            {
                Application.Instance.Quit();
            };

            #endregion

            #region Tool

            var noneTool = new Command()
            {
                MenuText = "&None",
                Shortcut = Keys.N
            };

            noneTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolNoneCommand.Execute(null);
            };

            var selectionTool = new Command()
            {
                MenuText = "&Selection",
                Shortcut = Keys.S
            };

            selectionTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolSelectionCommand.Execute(null);
            };

            var pointTool = new Command()
            {
                MenuText = "&Point",
                Shortcut = Keys.P
            };

            pointTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolPointCommand.Execute(null);
            };

            var lineTool = new Command()
            {
                MenuText = "&Line",
                Shortcut = Keys.L
            };

            lineTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolLineCommand.Execute(null);
            };

            var arcTool = new Command()
            {
                MenuText = "&Arc",
                Shortcut = Keys.A
            };

            arcTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolArcCommand.Execute(null);
            };

            var bezierTool = new Command()
            {
                MenuText = "&Bezier",
                Shortcut = Keys.B
            };

            bezierTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolBezierCommand.Execute(null);
            };

            var qbezierTool = new Command()
            {
                MenuText = "&QBezier",
                Shortcut = Keys.Q
            };

            qbezierTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolQBezierCommand.Execute(null);
            };

            var pathTool = new Command()
            {
                MenuText = "Pat&h",
                Shortcut = Keys.H
            };

            pathTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolPathCommand.Execute(null);
            };

            var rectangleTool = new Command()
            {
                MenuText = "&Rectangle",
                Shortcut = Keys.R
            };

            rectangleTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolRectangleCommand.Execute(null);
            };

            var ellipseTool = new Command()
            {
                MenuText = "&Ellipse",
                Shortcut = Keys.E
            };

            ellipseTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolEllipseCommand.Execute(null);
            };

            var textTool = new Command()
            {
                MenuText = "&Text",
                Shortcut = Keys.T
            };

            textTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolTextCommand.Execute(null);
            };

            var imageTool = new Command()
            {
                MenuText = "&Image",
                Shortcut = Keys.I
            };

            imageTool.Executed +=
            (s, e) =>
            {
                _context.Commands.ToolImageCommand.Execute(null);
            };

            #endregion

            #region Edit

            var undoCommand = new Command()
            {
                MenuText = "&Undo",
                Shortcut = Application.Instance.CommonModifier | Keys.Z
            };

            undoCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.UndoCommand.Execute(null);
            };

            var redoCommand = new Command()
            {
                MenuText = "&Redo",
                Shortcut = Application.Instance.CommonModifier | Keys.Y
            };

            redoCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.RedoCommand.Execute(null);
            };

            var cutCommand = new Command()
            {
                MenuText = "Cu&t",
                Shortcut = Application.Instance.CommonModifier | Keys.X
            };

            cutCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.CutCommand.Execute(null);
            };

            var copyCommand = new Command()
            {
                MenuText = "&Copy",
                Shortcut = Application.Instance.CommonModifier | Keys.C
            };

            copyCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.CopyCommand.Execute(null);
            };

            var pasteCommand = new Command()
            {
                MenuText = "&Paste",
                Shortcut = Application.Instance.CommonModifier | Keys.V
            };

            pasteCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.PasteCommand.Execute(null);
            };

            var deleteCommand = new Command()
            {
                MenuText = "&Delete",
                Shortcut = Keys.Delete
            };

            deleteCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.DeleteCommand.Execute(null);
            };

            var selectAllCommand = new Command()
            {
                MenuText = "Select &All",
                Shortcut = Application.Instance.CommonModifier | Keys.A
            };

            selectAllCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.SelectAllCommand.Execute(null);
            };

            var deSelectAllCommand = new Command()
            {
                MenuText = "De&select All",
                Shortcut = Keys.Escape
            };

            deSelectAllCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.DeselectAllCommand.Execute(null);
            };

            var clearAllCommand = new Command()
            {
                MenuText = "Cl&ear All"
            };

            clearAllCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.ClearAllCommand.Execute(null);
            };

            var groupCommand = new Command()
            {
                MenuText = "&Group",
                Shortcut = Application.Instance.CommonModifier | Keys.G
            };

            groupCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.GroupCommand.Execute(null);
            };

            var ungroupCommand = new Command()
            {
                MenuText = "U&ngroup",
                Shortcut = Application.Instance.CommonModifier | Keys.U
            };

            ungroupCommand.Executed +=
            (s, e) =>
            {
                _context.Commands.UngroupCommand.Execute(null);
            };

            #endregion

            #region Menu

            var fileMenu = new ButtonMenuItem()
            {
                Text = "&File",
                Items =
                {
                    newCommand,
                    new SeparatorMenuItem(),
                    openCommand,
                    new SeparatorMenuItem(),
                    saveAsCommand,
                    new SeparatorMenuItem(),
                    exportCommand
                }
            };

            var editMenu = new ButtonMenuItem()
            {
                Text = "&Edit",
                Items =
                {
                    undoCommand,
                    redoCommand,
                    new SeparatorMenuItem(),
                    cutCommand,
                    copyCommand,
                    pasteCommand,
                    deleteCommand,
                    new SeparatorMenuItem(),
                    selectAllCommand,
                    deSelectAllCommand,
                    new SeparatorMenuItem(),
                    clearAllCommand,
                    new SeparatorMenuItem(),
                    groupCommand,
                    ungroupCommand
                }
            };

            var toolMenu = new ButtonMenuItem()
            {
                Text = "&Tool",
                Items =
                {
                    noneTool,
                    new SeparatorMenuItem(),
                    selectionTool,
                    new SeparatorMenuItem(),
                    pointTool,
                    new SeparatorMenuItem(),
                    lineTool,
                    arcTool,
                    bezierTool,
                    qbezierTool,
                    new SeparatorMenuItem(),
                    pathTool,
                    new SeparatorMenuItem(),
                    rectangleTool,
                    ellipseTool,
                    new SeparatorMenuItem(),
                    textTool,
                    new SeparatorMenuItem(),
                    imageTool
                }
            };

            var aboutCommand = new Command()
            {
                MenuText = "&About..."
            };
            aboutCommand.Executed +=
            (s, e) =>
            {
                MessageBox.Show(this, Platform.ID);
            };

            Menu = new MenuBar
            {
                Items =
                {
                    fileMenu,
                    editMenu,
                    toolMenu
                },
                QuitItem = exitCommand,
                AboutItem = aboutCommand
            };

            #endregion
        }