コード例 #1
0
ファイル: ToolItem.cs プロジェクト: mhusen/Eto
		/// <summary>
		/// Initializes a new instance of the <see cref="Eto.Forms.ToolItem"/> class with the specified <paramref name="command"/>.
		/// </summary>
		/// <param name="command">Command to initialize the tool item with.</param>
		protected ToolItem(Command command)
		{
			ID = command.ID;
			Text = command.ToolBarText;
			ToolTip = command.ToolTip;
			Image = command.Image;
			Command = command;
		}
コード例 #2
0
ファイル: ToolItem.cs プロジェクト: gene-l-thomas/Eto
		/// <summary>
		/// Initializes a new instance of the <see cref="Eto.Forms.ToolItem"/> class with the specified <paramref name="command"/>.
		/// </summary>
		/// <param name="command">Command to initialize the tool item with.</param>
		protected ToolItem(Command command)
		{
			ID = command.ID;
			Text = command.ToolBarText;
			ToolTip = command.ToolTip;
			Image = command.Image;
			Click += (sender, e) => command.Execute();
			Enabled = command.Enabled;
			command.EnabledChanged += (sender, e) => Enabled = command.Enabled;
			Order = -1;
		}
コード例 #3
0
ファイル: MainForm.cs プロジェクト: Neraverin/MyRss
        private void CreateCommands()
        {
            _clickMe = new Command {MenuText = "Click Me!", ToolBarText = "Click Me!"};
            _clickMe.Executed += ClickMeOnExecuted;

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

            _aboutCommand = new Command {MenuText = "About..."};
            _aboutCommand.Executed += (sender, e) => MessageBox.Show(this, "About my app...");
        }
コード例 #4
0
ファイル: ToolItem.cs プロジェクト: gene-l-thomas/Eto
		protected ToolItem(Command command, Generator generator, Type type, bool initialize = true)
			: base(generator, type, initialize)
		{
			ID = command.ID;
			Text = command.ToolBarText;
			ToolTip = command.ToolTip;
			Image = command.Image;
			Click += (sender, e) => command.Execute();
			Enabled = command.Enabled;
			command.EnabledChanged += (sender, e) => Enabled = command.Enabled;
			Order = -1;
		}
コード例 #5
0
ファイル: MainForm.View.cs プロジェクト: MASGAU/2.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 } };
		}
コード例 #6
0
ファイル: TestControlHandler.cs プロジェクト: mhusen/Eto
		public void MapPlatformCommand(string systemCommand, Command command)
		{
			throw new NotImplementedException();
		}
コード例 #7
0
ファイル: Control.cs プロジェクト: mhusen/Eto
		/// <summary>
		/// Specifies a command to execute for a platform-specific command
		/// </summary>
		/// <remarks>
		/// Some platforms have specific system-defined commands that can be associated with a control.
		/// For example, the Mac platform's cut/copy/paste functionality is defined by the system, and if you want to
		/// hook into it, you can use this to map it to your own defined logic.
		/// The valid values of the <paramref name="systemCommand"/> parameter are defined by each platform, and a list can be
		/// retrieved using <see cref="Control.SupportedPlatformCommands"/>
		/// </remarks>
		/// <example>
		/// This example shows how to extend a control with cut/copy/paste for the mac platform:
		/// <code>
		/// var drawable = new Drawable();
		/// if (drawable.Generator.IsMac)
		/// {
		/// 	drawable.MapPlatformCommand("cut", new MyCutCommand());
		/// 	drawable.MapPlatformCommand("copy", new MyCopyCommand());
		/// 	drawable.MapPlatformCommand("paste", new MyPasteCommand());
		/// }
		/// </code>
		/// </example>
		/// <param name="systemCommand">System command</param>
		/// <param name="command">Command to execute, or null to restore to the default behavior</param>
		/// <seealso cref="SupportedPlatformCommands"/>
		public void MapPlatformCommand(string systemCommand, Command command)
		{
			Handler.MapPlatformCommand(systemCommand, command);
		}
コード例 #8
0
        private MenuBar BuildMenu()
        {
            if (!Platform.Supports <MenuBar>())
            {
                return(null);
            }

            var menuBar = new MenuBar
            {
                AboutItem = _menuItemAbout = new AboutCommand()
                {
                    DelegatedCommand = new RelayCommand <object>((_) =>
                    {
                        new AboutForm().ShowModal(this);
                    }),
                },
                QuitItem = _menuItemExit = new QuitCommand(),
            };

            var file = menuBar.Items.GetSubmenu("&File");

            file.Items.Add((_menuItemNew = new NewCommand()));
            file.Items.Add((_menuItemOpen = new OpenCommand()));
            file.Items.Add((_menuItemSave = new SaveCommand()));
            file.Items.Add((_menuItemSaveAs = new SaveAsCommand()));
            //file.Items.Add(new SeparatorMenuItem());

            var view = menuBar.Items.GetSubmenu("&View");

            view.Items.Add(new Eto.Forms.Command
            {
                MenuText         = "Device Bot",
                DelegatedCommand = new RelayCommand <object>((_) =>
                {
                    ShowDeviceBot();
                }),
            });
            view.Items.Add((_menuItemAlwaysOnTop = new CheckCommand
            {
                MenuText = "Always on top",
            }));

            //var help = menuBar.Items.GetSubmenu("He&lp");
            menuBar.HelpItems.Add((_menuItemHelp = new HelpCommand()));

            if (Platform.IsMac || Platform.IsWpf || Platform.IsWinForms)
            {
                menuBar.ApplicationItems.Add(new UpdateCommand
                {
                    DelegatedCommand = new RelayCommand <object>((_) =>
                    {
                        new PreferencesForm().ShowModal(this);
                    }),
                });
            }

            menuBar.ApplicationItems.Add((_menuItemPreferences = new PreferencesCommand
            {
                DelegatedCommand = new RelayCommand <object>((_) =>
                {
                    new PreferencesForm().ShowModal(this);
                }),
            }), 900);


            return(menuBar);
        }
コード例 #9
0
        public DeviceBotForm()
        {
            _mainVm  = ServiceLocator.Current.Get <MainViewModel>();
            _botVM   = ServiceLocator.Current.Get <DeviceBotViewModel>();
            _botView = ServiceLocator.Current.Get <DeviceBotView>();

            Style       = EtoStyles.DeviceBotDialog;
            Resizable   = true;
            Minimizable = true;
            Maximizable = true;
            Content     = _botView;
            ToolBar     = new ToolBar
            {
                Style = EtoStyles.Toolbar,
                Items =
                {
                    (_newCommand     = new NewCommand       {
                    }),
                    (_openCommand    = new OpenCommand      {
                    }),
                    (_saveCommand    = new SaveCommand      {
                    }),
                    (_saveAsCommand  = new SaveAsCommand    {
                    }),
                    new SeparatorToolItem {
                        Type         = SeparatorToolItemType.FlexibleSpace,
                    },
                    (_enableCommand  = new BotActiveCommand {
                    }),
                    (_compileCommand = new CompileCommand   {
                    }),
                },
            };

            for (var i = 0; i < 4; i++)
            {
                ToolBar.Items[i].Style = EtoStyles.ButtonToolItem;
            }

            this.Closing += (_, e) =>
            {
                if (this.DataContext is DeviceBotViewModel vm)
                {
                    if (vm.IsBotEnabled == true)
                    {
                        var err = vm.Compile();
                        if (string.IsNullOrEmpty(err))
                        {
                            _mainVm.DeviceBotEngine = vm.DeviceBotEngine;
                        }
                        else
                        {
                            MessageBox.Show(this, $"{err}", "Compile Error!", MessageBoxType.Error);
                            e.Cancel = true;
                            return;
                        }
                    }
                }
            };

            _botVM.PropertyChanged += (_, e) =>
            {
                if (e.PropertyName == nameof(DeviceBotViewModel.IsBotEnabled))
                {
                    //_compileCommand.Enabled = _botVM.IsBotEnabled;
                }
            };

            if (!Platform.IsWpf)
            {
                this.BindDataContext(x => x.Title, Binding.Property((DeviceBotViewModel vm) => vm.Title).Convert(x => x ?? " ", x => x ?? " "), DualBindingMode.OneWay);
            }
            this.BindDataContext(x => x.Width, Binding.Property((DeviceBotViewModel vm) => vm.Width));
            this.BindDataContext(x => x.Height, Binding.Property((DeviceBotViewModel vm) => vm.Height));

            _enableCommand.BindDataContext(x => x.Checked, Binding.Property((DeviceBotViewModel vm) => vm.IsBotEnabled));
            //_compileCommand.BindDataContext(x => x.Enabled, Binding.Property((DeviceBotViewModel vm) => vm.IsBotEnabled));

            _compileCommand.BindDataContext(x => x.DelegatedCommand, Binding.Property((DeviceBotViewModel vm) => vm.CompileCommand));
            _newCommand.BindDataContext(x => x.DelegatedCommand, Binding.Property((DeviceBotViewModel vm) => vm.NewCommand));
            _openCommand.BindDataContext(x => x.DelegatedCommand, Binding.Property((DeviceBotViewModel vm) => vm.OpenCommand));
            _saveCommand.BindDataContext(x => x.DelegatedCommand, Binding.Property((DeviceBotViewModel vm) => vm.SaveCommand));
            _saveAsCommand.BindDataContext(x => x.DelegatedCommand, Binding.Property((DeviceBotViewModel vm) => vm.SaveAsCommand));

            this.DataContext            = _botVM;
            _compileCommand.DataContext = _botVM;
            _enableCommand.DataContext  = _botVM;
            _newCommand.DataContext     = _botVM;
            _openCommand.DataContext    = _botVM;
            _saveCommand.DataContext    = _botVM;
            _saveAsCommand.DataContext  = _botVM;
        }
コード例 #10
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 });
				};
			}

		}
コード例 #11
0
ファイル: ButtonToolItem.cs プロジェクト: gene-l-thomas/Eto
		/// <summary>
		/// Initializes a new instance of the <see cref="Eto.Forms.ButtonToolItem"/> class with the specified <paramref name="command"/>.
		/// </summary>
		/// <param name="command">Command for the tool item.</param>
		public ButtonToolItem(Command command)
			: base(command)
		{
			Handler.CreateFromCommand(command);
		}
コード例 #12
0
ファイル: ButtonMenuItem.cs プロジェクト: gene-l-thomas/Eto
		public ButtonMenuItem(Command command, Generator generator = null)
			: base(command, generator, typeof(IHandler))
		{
			Image = command.Image;
		}
コード例 #13
0
ファイル: MenuItem.cs プロジェクト: gene-l-thomas/Eto
		/// <summary>
		/// Initializes a new instance of the <see cref="Eto.Forms.MenuItem"/> class with the specified command.
		/// </summary>
		/// <remarks>
		/// This links the menu item with the specified command, and will trigger <see cref="Command.Execute"/>
		/// when the user clicks the item, and enable/disable the menu item based on <see cref="Command.Enabled"/>.
		/// 
		/// This is not a weak link, so you should not re-use the Command instance for other menu items if you are disposing
		/// this menu item.
		/// </remarks>
		/// <param name="command">Command to initialize the menu item with.</param>
		protected MenuItem(Command command)
		{
			ID = command.ID;
			Text = command.MenuText;
			ToolTip = command.ToolTip;
			Shortcut = command.Shortcut;
			Click += (sender, e) => command.Execute();
			Validate += (sender, e) => Enabled = command.Enabled;
			Enabled = command.Enabled;
			command.EnabledChanged += (sender, e) => Enabled = command.Enabled;
		}
コード例 #14
-1
ファイル: MenuItem.cs プロジェクト: alexandrebaker/Eto
		protected MenuItem(Command command, Generator generator, Type type, bool initialize = true)
			: base(generator, type, initialize)
		{
			ID = command.ID;
			Text = command.MenuText;
			ToolTip = command.ToolTip;
			Shortcut = command.Shortcut;
			Click += (sender, e) => command.OnExecuted(e);
			Validate += (sender, e) => Enabled = command.Enabled;
			Enabled = command.Enabled;
			command.EnabledChanged += (sender, e) => Enabled = command.Enabled;
			if (initialize)
				Handler.CreateFromCommand(command);
		}
コード例 #15
-1
		void Init()
		{
			//_textBoxUrl
			_textBoxUrl = new TextBox();

			//_buttonReadFile
			_buttonReadFile = new Button { Text = StrRes.GetString("StrLoad", "Load") };
			_buttonReadFile.Click += _buttonReadFile_Click;

			//_buttonSaveFile
			_buttonSaveFile = new Button {Text = StrRes.GetString("StrSave","Save")};
			_buttonSaveFile.Click += _buttonSaveFile_Click;

			//_textAreaBody
			_textAreaBody = new TextArea();
            //rightMenu_Body
            var rightMenuBody = new ContextMenu();
		    var findCommand = new Command
		    {
		        MenuText = StrRes.GetString("StrFind", "Find"),
		        Shortcut = Keys.F | Application.Instance.CommonModifier
		    };
            findCommand.Executed += findCommand_Executed;
            rightMenuBody.Items.Add(findCommand);

			var layout = new DynamicLayout { Padding = new Padding(5, 5), Spacing = new Size(5, 5) };
			layout.BeginVertical();
			layout.BeginHorizontal();
			layout.AddCentered(_textBoxUrl, xscale: true, horizontalCenter: false);
			layout.AddCentered(_buttonReadFile, horizontalCenter: false);
			layout.AddCentered(_buttonSaveFile, horizontalCenter: false);
			layout.EndBeginHorizontal();
			layout.EndVertical();

            layout.AddRow(_textAreaBody);

            // bug in gtk2
            layout.ContextMenu = rightMenuBody;
            layout.MouseUp += (sender, e) =>
            {
                if (e.Buttons == MouseButtons.Alternate)
                {
                    layout.ContextMenu.Show(_textAreaBody);
                }
            };

			Content = layout;
		}
コード例 #16
-1
ファイル: MainForm.eto.cs プロジェクト: mhusen/Eto
        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 } };
        }
コード例 #17
-1
ファイル: ToolItemCollectionTests.cs プロジェクト: mhusen/Eto
		public void MixedCommandsAndToolItemsShouldBeInCorrectOrder()
		{
			TestUtils.Invoke(() =>
			{
				var toolbar = new ToolBar();
				for (int i = 0; i < 15; i++)
				{
					switch (i % 5)
					{
						case 0:
							toolbar.Items.Add(new ButtonToolItem { Text = i.ToString() });
							break;
						case 1:
							toolbar.Items.Add(new ButtonToolItem { Text = i.ToString() });
							break;
						case 2:
							toolbar.Items.Add(new Command { ToolBarText = i.ToString() });
							break;
						case 3:
							toolbar.Items.AddSeparator();
							break;
						case 4:
							// convert to toolitem first
							ToolItem toolItem = new Command { ToolBarText = i.ToString() };
							toolbar.Items.Add(toolItem);
							break;
					}
				}
				for (int i = 0; i < toolbar.Items.Count; i++)
				{
					if (toolbar.Items[i] is SeparatorToolItem)
						continue;
					Assert.AreEqual(i.ToString(), toolbar.Items[i].Text, "Items are out of order");
				}
			});
		}
コード例 #18
-1
ファイル: MainForm.cs プロジェクト: kripod/MoneroGui.Net
        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
            );
        }
コード例 #19
-1
ファイル: FormMain.cs プロジェクト: kevins1022/Altman
		private ButtonMenuItem LoadPluginsInUi(IPlugin plugin, bool isRoot)
		{
			var item = new ButtonMenuItem();

			var title = plugin.PluginInfo.Name;
			item.ID = title;
			item.Text = title;
			item.Order = plugin.PluginSetting.IndexInList;

			// 如果是插件,添加Run按钮
			if (isRoot)
			{
				var pluginRun = new Command()
				{
					ID = "Show",
					MenuText = "Show " + title,
					Tag = plugin,
				};
				pluginRun.Executed += pluginRun_Click;
				item.Items.Add(pluginRun);
			}

			// 添加子插件按钮
			var childs = PluginProvider.GetChildPlugins(plugin);
			if (childs.Any())
			{
				item.Items.AddSeparator(80000 - 1);
				var pluginChild = new ButtonMenuItem()
				{
					ID = "Childs",
					Text = "Child Plugins",
					Order = 80000
				};
				foreach (var c in childs)
				{
					pluginChild.Items.Add(LoadPluginsInUi(c, false));
				}
				item.Items.Add(pluginChild);
			}
			// 添加分隔符
			item.Items.AddSeparator(90000 - 1);
			// 添加About按钮
			var pluginAbout = new Command()
			{
				ID = "About",
				MenuText = "About",
				Tag = plugin
			};
			pluginAbout.Executed += pluginAbout_Click;
			pluginAbout.Tag = plugin;
			item.Items.Add(pluginAbout, 90000);
		
			return item;
		}
コード例 #20
-1
ファイル: MenuItem.cs プロジェクト: mhusen/Eto
		/// <summary>
		/// Initializes a new instance of the <see cref="Eto.Forms.MenuItem"/> class with the specified command.
		/// </summary>
		/// <remarks>
		/// This links the menu item with the specified command, and will trigger <see cref="Eto.Forms.Command.Execute"/>
		/// when the user clicks the item, and enable/disable the menu item based on <see cref="Eto.Forms.Command.Enabled"/>.
		/// 
		/// This is not a weak link, so you should not re-use the Command instance for other menu items if you are disposing
		/// this menu item.
		/// </remarks>
		/// <param name="command">Command to initialize the menu item with.</param>
		protected MenuItem(Command command)
		{
			ID = command.ID;
			Text = command.MenuText;
			ToolTip = command.ToolTip;
			Shortcut = command.Shortcut;
			Validate += (sender, e) => Enabled = command.Enabled;
			Command = command;
		}
コード例 #21
-1
ファイル: ButtonMenuItem.cs プロジェクト: alexandrebaker/Eto
		public ButtonMenuItem(Command command, Generator generator = null)
			: base(command, generator, typeof(IButtonMenuItem))
		{
			Items = new MenuItemCollection(Handler);
			Image = command.Image;
		}
コード例 #22
-1
ファイル: ButtonMenuItem.cs プロジェクト: picoe/Eto
		/// <summary>
		/// Initializes a new instance of the <see cref="Eto.Forms.ButtonMenuItem"/> class with the specified command.
		/// </summary>
		/// <param name="command">Command to initialize the menu item with.</param>
		public ButtonMenuItem(Command command)
			: base(command)
		{
			Image = command.Image;
			Handler.CreateFromCommand(command);
		}
コード例 #23
-1
ファイル: ButtonToolItem.cs プロジェクト: gene-l-thomas/Eto
		public ButtonToolItem(Command command, Generator generator = null)
			: base(command, generator, typeof(IHandler))
		{
			Handler.CreateFromCommand(command);
		}
コード例 #24
-1
ファイル: MainForm.cs プロジェクト: monocraft/Test2d
        /// <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
        }