Inheritance: InstanceWidget
コード例 #1
1
ファイル: MacButtonAction.cs プロジェクト: hultqvist/Eto
		public override ToolBarItem Generate (ActionItem actionItem, ToolBar toolBar)
		{
			var item = base.Generate (actionItem, toolBar);
			var tb = (NSToolbarItem)item.ControlObject;
			tb.Target = null;
			tb.Action = Selector;
			return item;
		}
コード例 #2
0
ファイル: ActionItem.cs プロジェクト: hultqvist/Eto
		public override void Generate(ToolBar toolBar)
		{
			var tbb = new SeparatorToolBarItem(toolBar.Generator) { Type = this.ToolBarType };
			if (!string.IsNullOrEmpty (ToolBarItemStyle))
				tbb.Style = ToolBarItemStyle;
			toolBar.Items.Add(tbb);
		}
コード例 #3
0
ファイル: Main.cs プロジェクト: Exe0/Eto
		ToolBar CreateToolBar()
		{
			var toolbar = new ToolBar();

			toolbar.Items.Add(new MyCommand());

			return toolbar;
		}
コード例 #4
0
ファイル: FormMain.UI.cs プロジェクト: kevins1022/Altman
		ToolBar GenerateToolBar()
		{
			var toolBar = new ToolBar();
			toolBar.Dock = ToolBarDock.Top;
			//toolBar.Items.Add(quit);
			//toolBar.Items.Add(new ButtonToolItem(about));

			return toolBar;
		}
コード例 #5
0
ファイル: ActionItem.cs プロジェクト: hultqvist/Eto
		public override void Generate(ToolBar toolBar)
		{
			var item = Action.Generate(this, toolBar);
			if (item != null) {
				if (!string.IsNullOrEmpty (ToolBarItemStyle))
					item.Style = ToolBarItemStyle;
				toolBar.Items.Add (item);
			}
		}
コード例 #6
0
ファイル: CheckAction.cs プロジェクト: M1C/Eto
 public override ToolBarItem Generate(ActionItem actionItem, ToolBar toolBar)
 {
     CheckToolBarButton tbb = new CheckToolBarButton(toolBar.Generator);
     tbb.ID = this.ID;
     tbb.Checked = Checked;
     tbb.Enabled = this.Enabled;
     if (ShowLabel || actionItem.ShowLabel || toolBar.TextAlign != ToolBarTextAlign.Right) tbb.Text = ToolBarText;
     if (Icon != null) tbb.Icon = Icon;
     new ToolBarConnector(this, tbb);
     return tbb;
 }
コード例 #7
0
ファイル: ButtonAction.cs プロジェクト: M1C/Eto
 public override ToolBarItem Generate(ActionItem actionItem, ToolBar toolBar)
 {
     ToolBarButton tbb = new ToolBarButton(toolBar.Generator);
     tbb.ID = this.ID;
     tbb.Enabled = this.Enabled;
     if (ShowLabel || actionItem.ShowLabel || toolBar.TextAlign != ToolBarTextAlign.Right) tbb.Text = ToolBarText;
     //Console.WriteLine("Adding toolbar {0}", ToolBarText);
     if (Icon != null) tbb.Icon = Icon;
     new ToolBarConnector(this, tbb);
     return tbb;
 }
コード例 #8
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 } };
		}
コード例 #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
 /// <summary>
 /// Raises the <see cref="BindableWidget.DataContextChanged"/> event
 /// </summary>
 /// <remarks>
 /// Implementors may override this to fire this event on child widgets in a heirarchy.
 /// This allows a control to be bound to its own <see cref="BindableWidget.DataContext"/>, which would be set
 /// on one of the parent control(s).
 /// </remarks>
 /// <param name="e">Event arguments</param>
 protected override void OnDataContextChanged(EventArgs e)
 {
     base.OnDataContextChanged(e);
     ToolBar?.TriggerDataContextChanged();
     Menu?.TriggerDataContextChanged();
 }
コード例 #11
0
ファイル: ActionItem.cs プロジェクト: M1C/Eto
 public override void Generate(ToolBar toolBar)
 {
     toolBar.Items.Add(new SeparatorToolBarItem(toolBar.Generator) { Type = this.ToolBarType });
 }
コード例 #12
0
ファイル: BaseAction.cs プロジェクト: hultqvist/Eto
		public abstract ToolBarItem Generate(ActionItem actionItem, ToolBar toolBar);
コード例 #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Eto.Forms.ToolItemCollection"/> class.
 /// </summary>
 /// <param name="parent">Parent of the tool item.</param>
 protected internal ToolItemCollection(ToolBar parent)
 {
     this.parent = parent;
 }
コード例 #14
0
ファイル: MainForm.cs プロジェクト: andererandre/Notedown
        void GenerateToolBar()
        {
            var toolbar = new ToolBar { Style = "ToolBar" };
            toolbar.Items.Add(new Commands.New());
            toolbar.Items.Add(new Commands.Delete());
            toolbar.Items.Add(new Commands.Rename());
            //toolbar.Items.AddFlexibleSpace();
            //toolbar.Items.Add(new Commands.Preferences());
            //toolbar.Items.Add(new Commands.About());

            ToolBar = toolbar;
        }
コード例 #15
0
 public void AddToolbar(Eto.Forms.ToolBar toolBar)
 {
     Control.Controls.Add((swf.Control)toolBar.ControlObject);
 }
コード例 #16
0
ファイル: ActionItem.cs プロジェクト: M1C/Eto
 public override void Generate(ToolBar toolBar)
 {
     var item = Action.Generate(this, toolBar);
     if (item != null)
         toolBar.Items.Add (item);
 }
コード例 #17
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 });
				};
			}

		}
コード例 #18
0
ファイル: MainForm.cs プロジェクト: Neraverin/MyRss
 private void CreateToolbar()
 {
     ToolBar = new ToolBar {Items = {_clickMe}};
 }
コード例 #19
0
ファイル: MainForm.cs プロジェクト: gene-l-thomas/Eto
		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 });
				};
			}

		}
コード例 #20
0
 protected internal ToolbarItemCollection(ToolBar toolBar)
 {
     this.toolBar = toolBar;
 }
コード例 #21
0
ファイル: ActionItem.cs プロジェクト: hultqvist/Eto
		public override void Generate(ToolBar toolBar)
		{
		}
コード例 #22
0
ファイル: RadioAction.cs プロジェクト: hultqvist/Eto
		public override ToolBarItem Generate(ActionItem actionItem, ToolBar toolBar)
		{
			throw new NotImplementedException("cannot put radio buttons on the toolbar just yet");
		}
コード例 #23
0
ファイル: ActionItem.cs プロジェクト: hultqvist/Eto
		public abstract void Generate(ToolBar toolBar);
コード例 #24
0
ファイル: MainForm.cs プロジェクト: alexandrebaker/Eto
		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;
		}
コード例 #25
0
 public void RemoveToolbar(Eto.Forms.ToolBar toolBar)
 {
     Control.Controls.Remove((swf.Control)toolBar.ControlObject);
 }
コード例 #26
0
ファイル: BaseAction.cs プロジェクト: modulexcite/Eto-1
 public abstract ToolBarItem Generate(ActionItem actionItem, ToolBar toolBar);
コード例 #27
-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 } };
        }
コード例 #28
-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");
				}
			});
		}