Пример #1
0
        public YesNoDialog(string message)
        {
            // Dialog windows set their own region.
            this.Region = new ConsoleGui.Drawing.Rect(
                (int)((double)Console.BufferWidth * .1),
                (int)((double)Console.BufferHeight * .1),
                (int)((double)Console.BufferWidth * .9),
                (int)((double)Console.BufferHeight * .9));

            // Layout engine for children controls.
            this.LayoutEngine = new ConsoleGui.Drawing.TableLayoutEngine(this.Region.Interior);

            this.LayoutEngine.LayoutRows = 5;
            this.LayoutEngine.LayoutCols = 2;


            MessageLabel = new ConsoleGui.Drawing.ReadOnlyTextbox()
            {
                Region           = LayoutEngine.GetRegion(0, 0, 4, 2),
                Text             = message,
                ScrollbarVisible = true
            };

            YesButton = new ConsoleGui.Drawing.Button()
            {
                Text    = "Yes",
                Region  = LayoutEngine.GetRegion(4, 0, 1, 1),
                OnClick = new Action(() => {
                    Result = YesNoDialogResult.Yes;
                    Close();
                })
            };

            NoButton = new ConsoleGui.Drawing.Button()
            {
                Text    = "No",
                Region  = LayoutEngine.GetRegion(4, 1, 1, 1),
                OnClick = new Action(() => {
                    Result = YesNoDialogResult.No;
                    Close();
                })
            };

            this.Controls.Add(MessageLabel);
            this.Controls.Add(YesButton);
            this.Controls.Add(NoButton);
        }