public void ShowTextDialog(string title, string text, Action <string> onOk) { if (textDialogVisible) { return; } var display = this.Frontend.CurrentDisplay; var textDialog = new TextOkCancelBox { Text = text, Title = title }; var textDialogBackend = textDialog.Backend as TextOkCancelBoxBackend; textDialogBackend.Widget.HorizontalPlacement = WidgetPlacement.Fill; textDialogBackend.Widget.VerticalPlacement = WidgetPlacement.Start; var panel = PanelOf(this.Frontend.CurrentDisplay); var c = panel.Content; var box = new VBox { HorizontalPlacement = WidgetPlacement.Fill, VerticalPlacement = WidgetPlacement.Fill, Spacing = 2 }; panel.Content = box; box.PackStart(textDialogBackend.Widget); box.PackEnd(c, true); box.SetFocus(); textDialogBackend.SetFocus(); textDialogVisible = true; textDialogBackend.Finish = (e) => { if (e == DialogResult.Ok) { onOk(textDialog.Text); } box.Remove(c); box.Remove(textDialogBackend.Widget); panel.Content = c; box.Dispose(); textDialog.Dispose(); textDialogVisible = false; // hide is changing the CurrentDisplay (whyever) // Frontend.DisplayGotFocus (display); }; }
public void ShowTextDialog(string title, string text, Action <string> onOk) { if (textDialogVisible) { return; } var display = this.Frontend.CurrentDisplay; var textDialog = new TextOkCancelBox { Text = text, Title = title }; var textDialogBackend = textDialog.Backend as TextOkCancelBoxBackend; textDialogBackend.Control.Dock = DockStyle.Top; var displayBackend = display.Backend as Control; if (SplitContainer.Panel1.Contains(displayBackend)) { SplitContainer.Panel1.Controls.Add(textDialogBackend.Control); } else if (SplitContainer.Panel2.Contains(displayBackend)) { SplitContainer.Panel2.Controls.Add(textDialogBackend.Control); } Control.ActiveControl = textDialogBackend.TextBox; textDialogBackend.Finish += (e) => { if (e == DialogResult.Ok) { onOk(textDialog.Text); } textDialog.Dispose(); textDialogVisible = false; SplitContainer.ResumeLayout(true); display.Backend.QueueDraw(); // hide is changing the CurrentDisplay (whyever) // TODO: Frontend.DisplayGotFocus (display); }; }