Dialog CreateDialog() { var dialog = new Dialog(); dialog.DisplayMode = DisplayMode; var layout = new DynamicLayout(); layout.AddCentered(new Label { Text = "Content" }, yscale: true); dialog.DefaultButton = new Button { Text = "Default Button" }; dialog.AbortButton = new Button { Text = "Abort Button" }; dialog.DefaultButton.Click += delegate { MessageBox.Show("Default button clicked"); }; dialog.AbortButton.Click += delegate { MessageBox.Show("Abort button clicked"); dialog.Close(); }; layout.BeginVertical(); layout.AddRow(null, dialog.DefaultButton, dialog.AbortButton); layout.EndVertical(); dialog.Content = layout; return dialog; }
Control KitchenSink () { var control = new Button { Text = "Kitchen Sink && Maximized" }; control.Click += delegate { var dialog = new Dialog (); #if DESKTOP dialog.State = WindowState.Maximized; dialog.Resizable = true; #endif dialog.Title = "Kitchen Sink Dialog"; dialog.AddDockedControl(new Controls.KitchenSinkSection()); dialog.ShowDialog (this); }; return control; }
public static Dialog CreateDialog(Control content, String title, int width = 0, int height = 0) { var alert = new Eto.Forms.Dialog(); alert.Content = content; if (height != 0) { alert.Height = height; } if (width != 0) { alert.Width = width; } alert.Title = title; alert.Icon = Eto.Drawing.Icon.FromResource(imgprefix + "DWSIM_ico.ico"); return(alert); }
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()); }
Control LoadUrl () { var control = new Button{ Text = "Load Url" }; control.Click += delegate { var dialog = new Dialog(); #if DESKTOP dialog.MinimumSize = new Size(300, 0); #endif var layout = new DynamicLayout(dialog); var textBox = new TextBox { Text = "http://google.com" }; var goButton = new Button { Text = "Go" }; dialog.DefaultButton = goButton; goButton.Click += (sender, e) => { dialog.DialogResult = DialogResult.Ok; dialog.Close (); }; var cancelButton = new Button { Text = "Cancel" }; dialog.AbortButton = cancelButton; cancelButton.Click += (sender, e) => { dialog.Close (); }; layout.BeginVertical (); layout.AddRow (new Label { Text = "Url" }, textBox); layout.EndBeginVertical (); layout.AddRow (null, cancelButton, goButton); layout.EndVertical (); if (dialog.ShowDialog (this) == DialogResult.Ok) { Uri uri; if (Uri.TryCreate(textBox.Text, UriKind.Absolute, out uri)) webView.Url = uri; } }; return control; }
Control LoadUrl() { var control = new Button { Text = "Load Url" }; control.Click += delegate { if (Platform.Supports<Dialog>()) { var dialog = new Dialog<bool>(); if (Platform.IsDesktop) dialog.MinimumSize = new Size(300, 0); var layout = new DynamicLayout(); var textBox = new TextBox { Text = "http://google.com" }; var goButton = new Button { Text = "Go" }; dialog.DefaultButton = goButton; goButton.Click += (sender, e) => dialog.Close(true); var cancelButton = new Button { Text = "Cancel" }; dialog.AbortButton = cancelButton; cancelButton.Click += (sender, e) => dialog.Close(); layout.BeginVertical(); layout.AddRow(new Label { Text = "Url" }, textBox); layout.EndBeginVertical(); layout.AddRow(null, cancelButton, goButton); layout.EndVertical(); dialog.Content = layout; if (dialog.ShowModal(this)) { Uri uri; if (Uri.TryCreate(textBox.Text, UriKind.Absolute, out uri)) webView.Url = uri; } } else webView.Url = new Uri("http://google.com"); }; return control; }
/// <summary> /// Runs the application with the specified <paramref name="dialog"/> and begins the main loop. /// </summary> /// <remarks> /// When the dialog is closed, the application will exit. /// </remarks> /// <param name="dialog">Dialog to show for the application.</param> public virtual void Run(Dialog dialog) { Initialized += (sender, e) => { dialog.ShowModal(); Quit(); }; Handler.Run(); }
public async void Show(Dialog dialog, Control parent) { if (UseAsync) { Log.Write(null, "Showing dialog async..."); var dialogTask = dialog.ShowModalAsync(parent); Log.Write(null, "Waiting for dialog to close..."); await dialogTask; Log.Write(null, "Dialog closed"); } else { Log.Write(null, "Showing dialog (blocking)..."); dialog.ShowModal(parent); Log.Write(null, "Dialog closed"); } }
Control KitchenSink() { var control = new Button { Text = "Kitchen Sink && Maximized" }; control.Click += delegate { var dialog = new Dialog(); dialog.DisplayMode = DisplayMode; if (Platform.IsDesktop) { dialog.Minimizable = true; dialog.Resizable = true; dialog.Maximizable = true; dialog.WindowState = WindowState.Maximized; } dialog.Title = "Kitchen Sink Dialog"; dialog.Content = new Controls.KitchenSinkSection(); Show(dialog, this); }; return control; }