Inheritance: Window
Exemple #1
7
			protected override void OnInitialized(EventArgs e)
			{
				base.OnInitialized(e);
				/**
				var layout = new DynamicLayout();
				layout.Add(new Label { Text = "Hello world", VerticalAlign = VerticalAlign.Middle, HorizontalAlign = HorizontalAlign.Center });
				layout.Add(new Label { Text = "Hello world2", VerticalAlign = VerticalAlign.Middle, HorizontalAlign = HorizontalAlign.Center });
				layout.Add(new Eto.Forms.Button { Text = "Hello world3" });
				layout.Add(new Eto.Forms.Spinner { Enabled = true });
				layout.Add(null);

				var layout2 = new Eto.Forms.TableLayout(
					new Eto.Forms.TableRow(null, new Label { Text = "Hello world", VerticalAlign = VerticalAlign.Middle, HorizontalAlign = HorizontalAlign.Center }, null),
					new Eto.Forms.TableRow(null, new Label { Text = "Hello world2", VerticalAlign = VerticalAlign.Middle, HorizontalAlign = HorizontalAlign.Center }, null),
					new Eto.Forms.TableRow(null, new Eto.Forms.Button { Text = "Hello world3" }, null),
					new Eto.Forms.TableRow(null, new Eto.Forms.Spinner { Enabled = true }, null)
				);

				MainForm = new Form { Content = new Panel { Content = layout2 } };
				MainForm.Show();
				/**
				var gv = new Eto.Forms.GridView();
				gv.Columns.Add(new GridColumn { DataCell = new TextBoxCell { Binding = new DelegateBinding<string, string>(r => r) }, HeaderText = "Col 1" });
				gv.DataStore = new ObservableCollection<string>(Enumerable.Range(0, 1000).Select(r => "Woo" + r));

				MainForm = new Form { Content = gv };//new Eto.Test.Sections.Controls.ButtonSection() };
				MainForm.Show();
				/**/
				MainForm = new Form { Content = new Eto.Test.Sections.UnitTestSection() };
				MainForm.Show();
				/**/
			}
		protected override Forms.Window GetWindow()
		{
			// Add splitters like this:
			// |---------------------------
			// |        |      |          |
			// |  P0    |  P2  |   P4     |
			// | -------|      |          |  <== These are on MainPanel
			// |  P1    |------|          |
			// |        |  P3  |          |
			// |---------------------------
			// |         status0..4,      |  <== These are on StatusPanel
			// ----------------------------

			Label[] status = new Label[] { new Label(), new Label(), new Label(), new Label(), new Label() };

			// Status bar
			var statusPanel = new Panel { };
			var statusLayout = new DynamicLayout(Padding.Empty, Size.Empty);
			statusLayout.BeginHorizontal();
			for (var i = 0; i < status.Length; ++i)
				statusLayout.Add(status[i], xscale: true);
			statusLayout.EndHorizontal();
			statusPanel.Content = statusLayout;

			// Splitter windows
			Panel[] p = new Panel[] { new Panel(), new Panel(), new Panel(), new Panel(), new Panel() };
			var colors = new Color[] { Colors.PaleTurquoise, Colors.Olive, Colors.NavajoWhite, Colors.Purple, Colors.Orange };
			var count = 0;
			for (var i = 0; i < p.Length; ++i)
			{
				var temp = i;
				//p[i].BackgroundColor = colors[i];
				var button = new Button { Text = "Click to update status " + i.ToString(), BackgroundColor = colors[i] };
				button.Click += (s, e) => status[temp].Text = "New count: " + (count++).ToString();
				p[i].Content = button;
			}

			var p0_1 = new Splitter { Panel1 = p[0], Panel2 = p[1], Orientation = SplitterOrientation.Vertical, Position = 200 };
			var p2_3 = new Splitter { Panel1 = p[2], Panel2 = p[3], Orientation = SplitterOrientation.Vertical, Position = 200 };
			var p01_23 = new Splitter { Panel1 = p0_1, Panel2 = p2_3, Orientation = SplitterOrientation.Horizontal, Position = 200};
			var p0123_4 = new Splitter { Panel1 = p01_23, Panel2 = p[4], Orientation = SplitterOrientation.Horizontal, Position = 400 };

			// Main panel
			var mainPanel = new Panel();
			mainPanel.Content = p0123_4;

			// Form's content
			var layout = new DynamicLayout();
			layout.Add(mainPanel, yscale: true);
			layout.Add(statusPanel);
			layout.Generate();
			var form = new Form 
			{ 
				Size = new Size(800, 600),
				Content = layout
			};
			return form;
		}
Exemple #3
0
			public override void OnInitialized(EventArgs e)
			{
				base.OnInitialized(e);
				var layout = new DynamicLayout();
				layout.Add(new Label { Text = "Hello world", VerticalAlign = VerticalAlign.Middle, HorizontalAlign = HorizontalAlign.Center });
				layout.Add(new Label { Text = "Hello world2", VerticalAlign = VerticalAlign.Middle, HorizontalAlign = HorizontalAlign.Center });
				layout.Add(new Eto.Forms.Spinner { Enabled = true });
				layout.Add(null);

				MainForm = new Form { Content = layout };
				MainForm.Show();
			}
Exemple #4
0
		/// <summary>
		/// Test operations on a form
		/// </summary>
		/// <param name="test">Delegate to execute on the form</param>
		/// <param name="timeout">Timeout to wait for the operation to complete</param>
		public static void Form(Action<Form> test, int timeout = DefaultTimeout)
		{
			Form form;
			Run((app, finished) =>
			{
				form = new Form();

				test(form);

				form.Closed += (sender, e) => finished();
				form.Show();

			}, timeout);
		}
Exemple #5
0
        /// <summary>
        /// Show a general settings dialog.
        /// </summary>
        private static void ShowSettings(object sender, object e)
        {
            // Options dialog.
            Eto.Forms.Form dialog = new Eto.Forms.Form();
            dialog.Size = new Eto.Drawing.Size(300, 300);

            StackLayout buttonStack = new StackLayout();

            Eto.Forms.Button b0 = new Eto.Forms.Button();
            buttonStack.Items.Add(b0);

            // Set the main content and options.
            dialog.Content = buttonStack;

            dialog.BackgroundColor = Colors.SlateGray;
            dialog.Maximizable     = false;
            dialog.Minimizable     = false;
            dialog.Topmost         = true;

            dialog.Show();
        }
		static Form Test1(bool setSize, Action<Label[], Panel> layoutContent)
		{
			// Status bar
			Label[] status = { new Label(), new Label(), new Label(), new Label(), new Label() };
			var statusLayout = new DynamicLayout(Padding.Empty, Size.Empty);
			statusLayout.BeginHorizontal();
			for (var i = 0; i < status.Length; ++i)
				statusLayout.Add(status[i], xscale: true);
			statusLayout.EndHorizontal();

			// Main panel
			var mainPanel = new Panel();
			layoutContent(status, mainPanel);

			// Form's content
			var layout = new DynamicLayout();
			layout.Add(mainPanel, yscale: true);
			layout.Add(statusLayout);
			layout.Generate();
			var form = new Form { Content = layout };
			if (setSize)
				form.ClientSize = new Size(800, 600);
			return form;
		}
Exemple #7
0
		/// <summary>
		/// Runs the application with the specified <paramref name="mainForm"/> and begins the main loop.
		/// </summary>
		/// <seealso cref="MainForm"/>
		/// <param name="mainForm">Main form for the application.</param>
		public virtual void Run(Form mainForm)
		{
			Initialized += (sender, e) =>
			{
				MainForm = mainForm;
				MainForm.Show();
			};
			Handler.Run();
		}
Exemple #8
0
 public void SetFlowsheetForm(Eto.Forms.Form form)
 {
     FlowsheetForm = form;
 }
Exemple #9
0
		void CreateChild()
		{
			if (child != null)
				child.Close();
			Action show;

			var layout = new DynamicLayout();
			layout.Add(null);
			layout.AddCentered(TestChangeSizeButton());
			layout.AddCentered(TestChangeClientSizeButton());
			layout.AddCentered(SendToBackButton());
			layout.AddCentered(CreateCancelClose());
			layout.AddCentered(CloseButton());

			if (typeRadio.SelectedKey == "form")
			{
				var form = new Form();
				child = form;
				show = form.Show;
			}
			else
			{
				var dialog = new Dialog();

				dialog.DefaultButton = new Button { Text = "Default" };
				dialog.DefaultButton.Click += (sender, e) => Log.Write(dialog, "Default button clicked");

				dialog.AbortButton = new Button { Text = "Abort" };
				dialog.AbortButton.Click += (sender, e) => Log.Write(dialog, "Abort button clicked");

				layout.AddSeparateRow(null, dialog.DefaultButton, dialog.AbortButton, null);

				child = dialog;
				show = dialog.ShowModal;
			}

			layout.Add(null);
			child.Content = layout;

			child.OwnerChanged += child_OwnerChanged;
			child.WindowStateChanged += child_WindowStateChanged;
			child.Closed += child_Closed;
			child.Closing += child_Closing;
			child.Shown += child_Shown;
			child.GotFocus += child_GotFocus;
			child.LostFocus += child_LostFocus;
			child.LocationChanged += child_LocationChanged;
			child.SizeChanged += child_SizeChanged;

			child.Title = "Child Window";
			child.WindowStyle = styleCombo.SelectedValue;
			child.WindowState = stateCombo.SelectedValue;
			child.Topmost = topMostCheckBox.Checked ?? false;
			child.Resizable = resizableCheckBox.Checked ?? false;
			child.Maximizable = maximizableCheckBox.Checked ?? false;
			child.Minimizable = minimizableCheckBox.Checked ?? false;
			child.ShowInTaskbar = showInTaskBarCheckBox.Checked ?? false;
			if (setInitialLocation)
				child.Location = initialLocation;
			if (setInitialClientSize)
				child.ClientSize = initialClientSize;
			if (setInitialMinimumSize)
				child.MinimumSize = initialMinimumSize;
			if (setOwnerCheckBox.Checked ?? false)
				child.Owner = ParentWindow;
			bringToFrontButton.Enabled = true;
			show();
			// show that the child is now referenced
			Log.Write(null, "Open Windows: {0}", Application.Instance.Windows.Count());
		}
Exemple #10
0
		static Form Test2(bool setSize)
		{
			var leftPane = new DynamicLayout { Padding = Padding.Empty, DefaultPadding = Padding.Empty };
			leftPane.AddColumn(new TreeGridView());

			var rightTop = new DynamicLayout();
			rightTop.AddColumn(ComboWithItems(), new Panel());

			var rightBottom = new DynamicLayout();
			rightBottom.AddRow(new ComboBox(), ComboWithItems(), new Button(), new CheckBox(), null);

			var rightPane = new Splitter
			{
				Orientation = SplitterOrientation.Vertical,
				FixedPanel = SplitterFixedPanel.Panel2,
				Panel1 = rightTop,
				Panel2 = rightBottom,
				Position = 200,
			};

			var form = new Form
			{ 
				Padding = new Padding(5),
				Content = new Splitter
				{
					Orientation = SplitterOrientation.Horizontal,
					FixedPanel = SplitterFixedPanel.Panel1,
					BackgroundColor = Colors.Gray,
					Position = 200,
					Panel1 = leftPane,
					Panel2 = rightPane
				}
			};
			if (setSize)
				form.Size = new Size(600, 400);
			return form;
		}
Exemple #11
0
		static Control TestDynamic()
		{
			var control = new Button { Text = "Dynamic splitter creation" };
			control.Click += (sender, e) =>
			{
				var tabcontrol = new TabControl();
				tabcontrol.Pages.Add(new TabPage { Text = "Index" });

				var addTabButton = new Button { Text = "Add Tab With Splitter" };
				addTabButton.Click += (ss, ee) =>
				{
					using (Context)
					{
						var newTabpage = new TabPage
						{
							Text = "test",
							Content = new Splitter
							{
								Panel1 = new TreeView { Size = new Size(100, 100) },
								Panel2 = new GridView(),
								Orientation = Orientation.Horizontal,
								FixedPanel = SplitterFixedPanel.Panel1,
								Position = 100,
							}
						};
						tabcontrol.Pages.Add(newTabpage);
						tabcontrol.SelectedPage = newTabpage;
					}
				};

				var form = new Form
				{
					Padding = new Padding(5),
					Content = new TableLayout(
						TableLayout.AutoSized(addTabButton, centered: true),
						tabcontrol
					)
				};
				form.Size = new Size(600, 400);
				form.Show();
			};
			return control;
		}
Exemple #12
0
		public static void UpdateLanguage(Form mainForm)
		{
			try
			{
				var id = mainForm.ID ?? "";
				//Menu
				if (mainForm.Menu != null)
				{
					UpdateMenu(mainForm.Menu.Items, Table);
				}
				//Title
				if (Table.Contains(id.ToLower()))
					mainForm.Title = (string)Table[id.ToLower()];
			}
			catch (Exception ex)
			{
				Console.WriteLine(ex.ToString());
			}
		}
Exemple #13
0
		void child_Closed(object sender, EventArgs e)
		{
			Log.Write(child, "Closed");
			child.WindowStateChanged -= child_WindowStateChanged;
			child.Closed -= child_Closed;
			child.Closing -= child_Closing;
			child.Shown -= child_Shown;
			child.GotFocus -= child_GotFocus;
			child.LostFocus -= child_LostFocus;
			child.LocationChanged -= child_LocationChanged;
			child.SizeChanged -= child_SizeChanged;
			bringToFrontButton.Enabled = false;
			child = null;
			// write out number of open windows after the closed event is called
			Application.Instance.AsyncInvoke(() => Log.Write(null, "Open Windows: {0}", Application.Instance.Windows.Count()));
		}
Exemple #14
0
		void child_Closed(object sender, EventArgs e)
		{
			Log.Write(child, "Closed");
			child.WindowStateChanged -= child_WindowStateChanged;
			child.Closed -= child_Closed;
			child.Shown -= child_Shown;
			child.GotFocus -= child_GotFocus;
			child.LostFocus -= child_LostFocus;
			child.LocationChanged -= child_LocationChanged;
			child.SizeChanged -= child_SizeChanged;
			bringToFrontButton.Enabled = false;
			child = null;
		}
Exemple #15
0
		void CreateChild()
		{
			if (child != null)
				child.Close();
			child = new Form
			{ 
				Title = "Child Window",
				ClientSize = new Size (300, 200),
				WindowStyle = styleCombo.SelectedValue,
				WindowState = stateCombo.SelectedValue,
				Topmost = topMostCheckBox.Checked ?? false,
				Resizable = resizableCheckBox.Checked ?? false,
				Maximizable = maximizableCheckBox.Checked ?? false,
				Minimizable = minimizableCheckBox.Checked ?? false,
				ShowInTaskbar = showInTaskBarCheckBox.Checked ?? false
			};
			var layout = new DynamicLayout();
			layout.Add(null);
			layout.AddCentered(SendToBackButton());
			layout.AddCentered(CloseButton());
			layout.Add(null);
			child.Content = layout;

			child.WindowStateChanged += child_WindowStateChanged;
			child.Closed += child_Closed;
			child.Shown += child_Shown;
			child.GotFocus += child_GotFocus;
			child.LostFocus += child_LostFocus;
			child.LocationChanged += child_LocationChanged;
			child.SizeChanged += child_SizeChanged;
			bringToFrontButton.Enabled = true;
			child.Show();
		}
Exemple #16
0
		Button TestHiding()
		{
			var control = new Button { Text = "Test Hiding" };
			control.Click += (sender, e) =>
			{
				var form = new Form();
				using (Context)
				{
					var splitter = new Splitter
					{
						Orientation = Orientation.Horizontal,
						FixedPanel = SplitterFixedPanel.None,
						RelativePosition = 0.5,
						Panel1 = new Panel { Padding = 20, BackgroundColor = Colors.Red, Content = new Panel { BackgroundColor = Colors.White, Size = new Size(200, 400) } },
						Panel2 = new Panel { Padding = 20, BackgroundColor = Colors.Blue, Content = new Panel { BackgroundColor = Colors.White, Size = new Size(200, 400) } }
					};

					var showPanel1 = new CheckBox { Text = "Panel1.Visible" };
					showPanel1.CheckedBinding.Bind(splitter.Panel1, r => r.Visible);

					var showPanel2 = new CheckBox { Text = "Panel2.Visible" };
					showPanel2.CheckedBinding.Bind(splitter.Panel2, r => r.Visible);

					var fixedPanel = new EnumDropDown<SplitterFixedPanel>();
					fixedPanel.SelectedValueBinding.Bind(splitter, r => r.FixedPanel);

					var orientation = new EnumDropDown<Orientation>();
					orientation.SelectedValueBinding.Bind(splitter, r => r.Orientation);

					var splitPanel = new Panel { Content = splitter };

					var showSplitter = new CheckBox { Text = "Show Splitter", Checked = true };
					showSplitter.CheckedChanged += (sender2, e2) => {
						if (showSplitter.Checked == true)
							splitPanel.Content = splitter;
						else
							splitPanel.Content = null;
					};

					var buttons = new StackLayout
					{
						Orientation = Orientation.Horizontal,
						Items = { showSplitter, showPanel1, showPanel2, fixedPanel, orientation }
					};
				
					form.Content = new StackLayout
					{
						HorizontalContentAlignment = HorizontalAlignment.Stretch,
						Items =
						{
							buttons,
							new StackLayoutItem(splitPanel, true)
						}
					};
				}
				form.Show();
			};

			return control;
		}
Exemple #17
0
		static Control TestInitResize()
		{
			var app = Application.Instance;
			var control = new Button
			{
				Text = "Show splitter test of initial resize"
			};
			Func<Splitter, Control> makebox = split =>
			{
				var area = new TextArea();
				area.SizeChanged += (s, e) =>
				{
					var size = area.VisualParent.Size;
					if (split.Orientation == Orientation.Horizontal)
						size.Width -= split.SplitterWidth;
					else
						size.Height -= split.SplitterWidth;
					if (size.Width <= 0 || size.Height <= 0)
						return;
					app.AsyncInvoke(() => {
					area.Text = string.Format(
						"W:{0} ({1}%)\r\nH:{2} ({3}%)",
						area.Width, (area.Width * 200 + size.Width) / (size.Width + size.Width),
						area.Height, (area.Height * 200 + size.Height) / (size.Height + size.Height));
					});
				};
				return area;
			};
			Func<int, Form> makeform = i =>
			{
				var wa = new Rectangle(Screen.PrimaryScreen.WorkingArea);
				var form = new Form
				{
					Title = "Test Form #" + (i + 1),
					Bounds = i == 0
					? new Rectangle(wa.X + 20, wa.Y + 20, wa.Width / 3, wa.Height / 3)
					: i == 1
					? new Rectangle(wa.X + 20, wa.Y + 40 + wa.Height / 3, wa.Width / 3, wa.Height * 2 / 3 - 60)
					: new Rectangle(wa.X + wa.Width / 3 + 40, wa.Y + 20, wa.Width * 2 / 3 - 60, wa.Height - 40)
				};
				using (Context)
				{
					var main = new Splitter
					{
						Position = 80
					};
					var middle = new Splitter
					{
						FixedPanel = SplitterFixedPanel.Panel2,
						Width = 200,
						Position = 120 - main.SplitterWidth
					};
					var ltop = new Splitter
					{
						Orientation = Orientation.Vertical,
						Position = 80
					};
					var lbottom = new Splitter
					{
						Orientation = Orientation.Vertical,
						FixedPanel = SplitterFixedPanel.Panel2,
						RelativePosition = 80
					};
					var right = new Splitter
					{
						Orientation = Orientation.Vertical,
						FixedPanel = SplitterFixedPanel.None,
						Height = 300 + main.SplitterWidth,
						Position = 100 // ~33%
					};
					var center = new Splitter
					{
						FixedPanel = SplitterFixedPanel.None,
						RelativePosition = .4
					};
					main.Panel1 = ltop;
					main.Panel2 = middle;
					ltop.Panel1 = makebox(ltop);
					ltop.Panel2 = lbottom;
					lbottom.Panel1 = makebox(lbottom);
					lbottom.Panel2 = makebox(lbottom);
					middle.Panel1 = center;
					middle.Panel2 = right;
					right.Panel1 = makebox(right);
					right.Panel2 = makebox(right);
					center.Panel1 = makebox(center);
					center.Panel2 = makebox(center);
					form.Content = main;
				}
				form.Show();
				return form;
			};
			control.Click += (sender, e) =>
			{
				var forms = new Form[3];
				for (int i = 0; i < 3; i++)
				{
					forms[i] = makeform(i);
					forms[i].Closed += (fs, fe) =>
					{
						var all = forms;
						forms = null;
						if (all != null)
							for (int j = 0; j < 3; j++)
								if (all[j] != fs)
									all[j].Close();
					};
				}
			};
			return control;
		}