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(); /**/ }
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(); }
/// <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); }
/// <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(); }
/// <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(); }
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(); }
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; }
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; }
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; }