Exemplo n.º 1
0
        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);
            };
        }