Inheritance: Eto.Forms.MenuItem
Esempio n. 1
0
		protected RadioMenuItem (Generator generator, Type type, RadioMenuItem controller, bool initialize = true)
			: base (generator, type, false)
		{
			Handler.Create (controller);
			if (initialize)
				Initialize ();
		}
Esempio n. 2
0
			public MenuConnector(RadioAction action, RadioMenuItem menuItem)
			{
				this.action = action;
				this.menuItem = menuItem;
				this.menuItem.Click += menuItem_Click;
				this.action.EnabledChanged += new EventHandler<EventArgs>(action_EnabledChanged).MakeWeak(e => this.action.EnabledChanged -= e);
				this.action.CheckedChanged += new EventHandler<EventArgs>(action_CheckedChanged).MakeWeak(e => this.action.CheckedChanged -= e);
			}
Esempio n. 3
0
 public MenuConnector(RadioAction action, RadioMenuItem menuItem)
 {
     this.action                 = action;
     this.menuItem               = menuItem;
     this.menuItem.Click        += menuItem_Click;
     this.action.EnabledChanged += new EventHandler <EventArgs>(action_EnabledChanged).MakeWeak(e => this.action.EnabledChanged -= e);
     this.action.CheckedChanged += new EventHandler <EventArgs>(action_CheckedChanged).MakeWeak(e => this.action.CheckedChanged -= e);
 }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Eto.Forms.RadioMenuItem"/> class with the specified command and controller.
 /// </summary>
 /// <param name="command">Command to initialize the menu item with.</param>
 /// <param name="controller">Controller radio menu item to link to, or null if no controller.</param>
 public RadioMenuItem(RadioCommand command, RadioMenuItem controller = null)
     : base(command)
 {
     Handler.Create(controller);
     Initialize();
     Handler.CreateFromCommand(command);
     HandleEvent(CheckedChangedEvent);
 }
Esempio n. 5
0
 protected RadioMenuItem(Generator generator, Type type, RadioMenuItem controller, bool initialize = true)
     : base(generator, type, false)
 {
     Handler.Create(controller);
     if (initialize)
     {
         Initialize();
     }
 }
Esempio n. 6
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Eto.Forms.RadioMenuItem"/> class with the specified command and controller.
		/// </summary>
		/// <param name="command">Command to initialize the menu item with.</param>
		/// <param name="controller">Controller radio menu item to link to, or null if no controller.</param>
		public RadioMenuItem(RadioCommand command, RadioMenuItem controller = null)
			: base(command)
		{
			Checked = command.Checked;
			Handler.Create(controller);
			CheckedChanged += (sender, e) => command.Checked = Checked;
			command.CheckedChanged += (sender, e) => Checked = command.Checked;
			Initialize();
			Handler.CreateFromCommand(command);
		}
Esempio n. 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Eto.Forms.RadioMenuItem"/> class with the specified command and controller.
 /// </summary>
 /// <param name="command">Command to initialize the menu item with.</param>
 /// <param name="controller">Controller radio menu item to link to, or null if no controller.</param>
 public RadioMenuItem(RadioCommand command, RadioMenuItem controller = null)
     : base(command)
 {
     Checked                 = command.Checked;
     CheckedChanged         += (sender, e) => command.Checked = Checked;
     command.CheckedChanged += (sender, e) => Checked = command.Checked;
     Handler.Create(controller);
     Initialize();
     Handler.CreateFromCommand(command);
 }
Esempio n. 8
0
 public RadioMenuItem(RadioCommand command, RadioMenuItem controller, Generator generator = null)
     : base(command, generator, typeof(IRadioMenuItem), false)
 {
     Checked = command.Checked;
     Click  += (sender, e) => command.Checked = Checked;
     command.CheckedChanged += (sender, e) => Checked = command.Checked;
     Handler.Create(controller);
     Initialize();
     Handler.CreateFromCommand(command);
 }
Esempio n. 9
0
		public RadioMenuItem(RadioCommand command, RadioMenuItem controller, Generator generator = null)
			: base(command, generator, typeof(RadioMenuItem.IHandler), false)
		{
			Checked = command.Checked;
			Click += (sender, e) => command.Checked = Checked;
			command.CheckedChanged += (sender, e) => Checked = command.Checked;
			Handler.Create(controller);
			Initialize();
			Handler.CreateFromCommand(command);
		}
Esempio n. 10
0
        public override MenuItem Generate(ActionItem actionItem, ISubMenuWidget menu)
        {
            RadioMenuItem mi = new RadioMenuItem(menu.Generator, (Controller != null) ? Controller.menuItem : null);
            mi.Text = MenuText;
            mi.Shortcut = Accelerator;
            mi.Enabled = this.Enabled;
            mi.Checked = Checked;

            new MenuConnector(this, mi);
            menuItem = mi;
            return mi;
        }
Esempio n. 11
0
		public override MenuItem GenerateMenuItem(Generator generator)
		{
			var mi = new RadioMenuItem((Controller != null) ? Controller.menuItem : null, generator);
			mi.Text = MenuText;
			mi.Shortcut = Accelerator;
			mi.Enabled = Enabled;
			mi.Checked = Checked;
			if (!string.IsNullOrEmpty(MenuItemStyle))
				mi.Style = MenuItemStyle;

			new MenuConnector(this, mi);
			menuItem = mi;
			return mi;
		}
Esempio n. 12
0
        public override MenuItem GenerateMenuItem(Generator generator)
        {
            RadioMenuItem mi = new RadioMenuItem(generator, (Controller != null) ? Controller.menuItem : null);

            mi.Text     = MenuText;
            mi.Shortcut = Accelerator;
            mi.Enabled  = this.Enabled;
            mi.Checked  = Checked;
            if (!string.IsNullOrEmpty(MenuItemStyle))
            {
                mi.Style = MenuItemStyle;
            }

            new MenuConnector(this, mi);
            menuItem = mi;
            return(mi);
        }
Esempio n. 13
0
		ContextMenu CreateMenu()
		{
			if (menu != null)
				return menu;
			
			menu = new ContextMenu();

			menu.Opening += (sender, e) => Log.Write(sender, "Opening");
			menu.Closed += (sender, e) => Log.Write(sender, "Closed");

			menu.Items.Add(new ButtonMenuItem { Text = "Item 1" });
			menu.Items.Add(new ButtonMenuItem { Text = "Item 2", Shortcut = Keys.Control | Keys.I });
			menu.Items.Add(new ButtonMenuItem { Text = "Item 3", Shortcut = Keys.Shift | Keys.I });
			menu.Items.Add(new ButtonMenuItem { Text = "Item 4", Shortcut = Keys.Alt | Keys.I });

			var subMenu = menu.Items.GetSubmenu("Sub Menu");
			subMenu.Items.Add(new ButtonMenuItem { Text = "Item 5", Shortcut = Keys.Application | Keys.I });
			subMenu.Items.Add(new ButtonMenuItem { Text = "Item 6", Shortcut = Keys.I });

			menu.Items.AddSeparator();
			RadioMenuItem radioController;
			menu.Items.Add(radioController = new RadioMenuItem { Text = "Radio 1" });
			menu.Items.Add(new RadioMenuItem(radioController) { Text = "Radio 2", Checked = true });
			menu.Items.Add(new RadioMenuItem(radioController) { Text = "Radio 3", Shortcut = Keys.R });
			menu.Items.Add(new RadioMenuItem(radioController) { Text = "Radio 4" });

			menu.Items.AddSeparator();
			menu.Items.Add(new CheckMenuItem { Text = "Check 1" });
			menu.Items.Add(new CheckMenuItem { Text = "Check 2", Shortcut = Keys.Control | Keys.Alt | Keys.G, Checked = true });
			menu.Items.Add(new CheckMenuItem { Text = "Check 3", Shortcut = Keys.Control | Keys.Shift | Keys.G });
			menu.Items.Add(new CheckMenuItem { Text = "Check 4", Shortcut = Keys.Control | Keys.Application | Keys.G });
			menu.Items.Add(new CheckMenuItem { Text = "Check 5", Shortcut = Keys.Shift | Keys.Alt | Keys.G });
			menu.Items.Add(new CheckMenuItem { Text = "Check 6", Shortcut = Keys.Shift | Keys.Application | Keys.G });
			menu.Items.Add(new CheckMenuItem { Text = "Check 7", Shortcut = Keys.Alt | Keys.Application | Keys.G });

			LogEvents(menu);
			return menu;
		}
Esempio n. 14
0
		void LogEvents(RadioMenuItem item)
		{
			if (item == null)
				return;
			item.CheckedChanged += delegate
			{
				Log.Write(item, "CheckedChanged, Item: {0}, Checked: {1}", item.Text, item.Checked);
			};
		}
Esempio n. 15
0
 public RadioMenuItem(RadioMenuItem controller, Generator generator = null)
     : this(generator, typeof(IRadioMenuItem), controller)
 {
 }
Esempio n. 16
0
 /// <summary>
 /// Creates a new menu item attached to this command.
 /// </summary>
 /// <returns>The menu item for the command.</returns>
 public override MenuItem CreateMenuItem()
 {
     return(menuItem = new RadioMenuItem(this, Controller != null ? Controller.menuItem : null));
 }
Esempio n. 17
0
 public override MenuItem CreateMenuItem(Generator generator = null)
 {
     return(menuItem = new RadioMenuItem(this, Controller != null ? Controller.menuItem : null, generator));
 }
Esempio n. 18
0
		public RadioMenuItem (Generator g, RadioMenuItem controller = null)
			: this (g, typeof(IRadioMenuItem), controller)
		{
		}
Esempio n. 19
0
 public RadioMenuItem(Generator g, RadioMenuItem controller = null)
     : this(g, typeof(IRadioMenuItem), controller)
 {
 }
Esempio n. 20
0
		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 });
				};
			}

		}
Esempio n. 21
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Eto.Forms.RadioMenuItem"/> class.
		/// </summary>
		/// <param name="controller">Controller radio menu item to link to, or null if no controller.</param>
		public RadioMenuItem(RadioMenuItem controller)
		{
			Handler.Create(controller);
			Initialize();
		}
Esempio n. 22
0
 public RadioMenuItem(RadioMenuItem controller = null) : this(Generator.Current, controller)
 {
 }
Esempio n. 23
0
 public RadioMenuItem(Generator g, RadioMenuItem controller)
     : base(g, typeof(IRadioMenuItem))
 {
     inner = (IRadioMenuItem)base.Handler;
     inner.Create(controller);
 }
Esempio n. 24
0
		public RadioMenuItem(RadioMenuItem controller, Generator generator = null)
			: this(generator, typeof(RadioMenuItem.IHandler), controller)
		{
		}
Esempio n. 25
0
 /// <summary>
 /// Raises the checked changed event.
 /// </summary>
 public void OnCheckedChanged(RadioMenuItem widget, EventArgs e)
 {
     using (widget.Platform.Context)
         widget.OnCheckedChanged(e);
 }
Esempio n. 26
0
 /// <summary>
 /// Raises the checked changed event.
 /// </summary>
 public void OnCheckedChanged(RadioMenuItem widget, EventArgs e)
 {
     widget.Platform.Invoke(() => widget.OnCheckedChanged(e));
 }
Esempio n. 27
0
		#pragma warning disable 672,612,618

		/// <summary>
		/// Creates a new menu item attached to this command.
		/// </summary>
		/// <returns>The menu item for the command.</returns>
		/// <param name="generator">Generator.</param>
		public override MenuItem CreateMenuItem(Generator generator)
		{
			return menuItem = new RadioMenuItem(this, Controller != null ? Controller.menuItem : null);
		}
Esempio n. 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Eto.Forms.RadioMenuItem"/> class.
 /// </summary>
 /// <param name="controller">Controller radio menu item to link to, or null if no controller.</param>
 public RadioMenuItem(RadioMenuItem controller)
 {
     Handler.Create(controller);
     Initialize();
 }
Esempio n. 29
0
			/// <summary>
			/// Raises the checked changed event.
			/// </summary>
			public void OnCheckedChanged(RadioMenuItem widget, EventArgs e)
			{
				widget.Platform.Invoke(() => widget.OnCheckedChanged(e));
			}
Esempio n. 30
0
		public RadioMenuItem (RadioMenuItem controller = null) : this (Generator.Current, controller)
		{
		}