Пример #1
0
        public HiColorPicker() : base("HiColor Color Picker", "=========[HiColor Color Picker]=========".Length, 10)
        {
            Rainbow RainbowGraphic = new Rainbow();


            Label MegaLabel = new Label(this, "Color 1:                   Shade: ░▒▓\n\n\n" +
                                        "Color 2:", ConsoleColor.Gray, ConsoleColor.Black, 1, 2);
            Image Rainbow1 = new Image(this, RainbowGraphic, 10, 2);
            Image Rainbow2 = new Image(this, RainbowGraphic, 10, 5);

            Slider1  = new Slider(this, RainbowGraphic.GetWidth(), 10, 3, ConsoleColor.DarkGray, ConsoleColor.DarkBlue, ConsoleColor.Red);
            Slider2  = new Slider(this, RainbowGraphic.GetWidth(), 10, 6, ConsoleColor.DarkGray, ConsoleColor.DarkBlue, ConsoleColor.Red);
            Slider3  = new Slider(this, 3, 35, 3, ConsoleColor.DarkGray, ConsoleColor.DarkBlue, ConsoleColor.Red);
            OKButton = new FlaggedCloseButton(this, "[     OK     ]", ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, 3, 8);
            CloseButton Cancelbutton = new CloseButton(this, "[   CANCEL   ]", ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, 24, 8);

            WindowElement[] AddIt = { MegaLabel, Rainbow1, Rainbow2, Slider1, Slider2, Slider3, OKButton, Cancelbutton };
            AllElements.AddRange(AddIt);

            //Link elements
            Slider1.NextElement          = Slider2;
            Slider2.PreviousElement      = Slider1;
            Slider2.NextElement          = Slider3;
            Slider3.PreviousElement      = Slider2;
            Slider3.NextElement          = OKButton;
            OKButton.PreviousElement     = Slider3;
            OKButton.NextElement         = Cancelbutton;
            Cancelbutton.PreviousElement = OKButton;
            Cancelbutton.NextElement     = Slider1;
            Slider1.PreviousElement      = Cancelbutton;

            //Highlight elements
            HighlightedElement  = Slider1;
            Slider1.Highlighted = true;
        }
Пример #2
0
        public NewFileWindow() : base("New File", "==================[New File]================".Length, 10)
        {
            //haha I still will not count it.

            //Megalabel
            AllElements.Add(new Label(this, "Name of File:\n\nMode of File\n\nSize of File:     x", ConsoleColor.Gray, ConsoleColor.Black, 1, 2));

            //FielName box
            Namebox = new Textbox(this, 28, 15, 2, ConsoleColor.DarkGray, ConsoleColor.DarkBlue, ConsoleColor.White);
            AllElements.Add(Namebox);

            String[] Items = { "DF Editor", "HC Editor" };

            //ModeBox
            ModeBox = new LeftRightSelect(this, new List <string>(Items), 28, 15, 4, ConsoleColor.DarkGray, ConsoleColor.DarkBlue, ConsoleColor.White);
            AllElements.Add(ModeBox);

            //XBox and YBox
            XBox = new NumericalTextBox(this, 150, 3, 15, 6, ConsoleColor.DarkGray, ConsoleColor.DarkBlue, ConsoleColor.White);
            YBox = new NumericalTextBox(this, 40, 3, 21, 6, ConsoleColor.DarkGray, ConsoleColor.DarkBlue, ConsoleColor.White);
            AllElements.Add(XBox);
            AllElements.Add(YBox);

            //OKButton
            OKButton = new FlaggedCloseButton(this, "[     OK     ]", ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, 5, 8);
            AllElements.Add(OKButton);

            //CancelButton
            CloseButton Cancelbutton = new CloseButton(this, "[   CANCEL   ]", ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, 26, 8);

            AllElements.Add(Cancelbutton);

            //Link elements
            Namebox.NextElement          = ModeBox;
            ModeBox.PreviousElement      = Namebox;
            ModeBox.NextElement          = XBox;
            XBox.PreviousElement         = ModeBox;
            XBox.NextElement             = YBox;
            YBox.PreviousElement         = XBox;
            YBox.NextElement             = OKButton;
            OKButton.PreviousElement     = YBox;
            OKButton.NextElement         = Cancelbutton;
            Cancelbutton.PreviousElement = OKButton;
            Cancelbutton.NextElement     = Namebox;
            Namebox.PreviousElement      = Cancelbutton;

            //Highlight Element.
            HighlightedElement  = Namebox;
            Namebox.Highlighted = true;
        }
Пример #3
0
        /// <summary>Creates a dialog box</summary>
        /// <param name="Type"></param>
        /// <param name="Text"></param>
        /// <param name="Buttons"></param>
        public DialogBox(Icon.IconType Type, DialogBoxButtons Buttons, String Text)
        {
            //time to set up a window

            //MaxWidth-6 because 3 for the icon, 1 for spacing between icon and left, icon and text, and text and right
            //MaxHeight-5 because 1 for header, 1 for space between header and text, 1 for space between text and button, 1 for button, and 1 for footer
            FormattedText TextButFormatted = new FormattedText(Text, MaxWidth - 6, MaxHeight - 5);

            //find the minimum width of the window given the buttons:
            //5 is the base because that's the width of the icon;
            int MinWidth = 5;

            switch (Buttons)
            {
            case DialogBoxButtons.OK:
                //Single button (length of button, plus spacing with the left side of the window
                MinWidth += 12 + 1;
                break;

            case DialogBoxButtons.OKCancel:
            case DialogBoxButtons.YesNo:
                //two buttons
                //two single buttons
                MinWidth += 13 + 13;
                break;

            case DialogBoxButtons.YesNoCancel:
            case DialogBoxButtons.AbortRetryIgnore:
                //Three buttons
                //Three single buttons
                MinWidth += 13 * 3;
                break;

            default:
                break;
            }

            //Get the actual width of the window.
            //Max in case the text's width or height is smaller than the minimum required to display other elements.
            int WindowWidth  = Math.Max(MinWidth, TextButFormatted.ActualWidth + 6);
            int WindowHeight = Math.Max(6, TextButFormatted.ActualHeight + 5);

            //OK now lets figure out which title/icon this will have.
            String       Title;
            ConsoleColor HeaderBG = ConsoleColor.DarkBlue;

            switch (Type)
            {
            case Icon.IconType.ERROR:
                Title    = "Error";
                HeaderBG = ConsoleColor.DarkRed;
                break;

            case Icon.IconType.EXCLAMATION:
                Title = "Warning";
                break;

            case Icon.IconType.INFORMATION:
                Title = "Information";
                break;

            case Icon.IconType.QUESTION:
                Title = "Question";
                break;

            default:
                Title = "Uh...";
                break;
            }

            //Now we're ready to create the window
            MainWindow = new Window(false, true, ConsoleColor.Gray, HeaderBG, ConsoleColor.White, Title, WindowWidth, WindowHeight);

            //Now let's go ahead and populate the window
            MainWindow.AddElement(new Icon(MainWindow, Type, 1, 2));
            MainWindow.AddElement(new Label(MainWindow, TextButFormatted, ConsoleColor.Gray, ConsoleColor.Black, 5, 2));

            switch (Buttons)
            {
            case DialogBoxButtons.OK:
                OKButton = new FlaggedCloseButton(MainWindow, OKButtonText, ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, MainWindow.Length - 13, MainWindow.Height - 2);

                MainWindow.AddElement(OKButton);

                MainWindow.HighlightedElement = OKButton;
                OKButton.Highlighted          = true;
                break;

            case DialogBoxButtons.OKCancel:
                OKButton     = new FlaggedCloseButton(MainWindow, OKButtonText, ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, MainWindow.Length - 26, MainWindow.Height - 2);
                CancelButton = new FlaggedCloseButton(MainWindow, CancelButtonText, ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, MainWindow.Length - 13, MainWindow.Height - 2);

                MainWindow.AddElement(OKButton);
                MainWindow.AddElement(CancelButton);

                OKButton.NextElement         = CancelButton;
                CancelButton.PreviousElement = OKButton;

                MainWindow.HighlightedElement = OKButton;
                OKButton.Highlighted          = true;
                break;

            case DialogBoxButtons.YesNo:
                YesButton = new FlaggedCloseButton(MainWindow, YesButtonText, ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, MainWindow.Length - 26, MainWindow.Height - 2);
                NoButton  = new FlaggedCloseButton(MainWindow, NoButtonText, ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, MainWindow.Length - 13, MainWindow.Height - 2);

                MainWindow.AddElement(YesButton);
                MainWindow.AddElement(NoButton);

                YesButton.NextElement    = NoButton;
                NoButton.PreviousElement = YesButton;

                MainWindow.HighlightedElement = YesButton;
                YesButton.Highlighted         = true;

                break;

            case DialogBoxButtons.YesNoCancel:
                YesButton    = new FlaggedCloseButton(MainWindow, YesButtonText, ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, MainWindow.Length - 39, MainWindow.Height - 2);
                NoButton     = new FlaggedCloseButton(MainWindow, NoButtonText, ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, MainWindow.Length - 26, MainWindow.Height - 2);
                CancelButton = new FlaggedCloseButton(MainWindow, CancelButtonText, ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, MainWindow.Length - 13, MainWindow.Height - 2);

                MainWindow.AddElement(YesButton);
                MainWindow.AddElement(NoButton);
                MainWindow.AddElement(CancelButton);

                YesButton.NextElement        = NoButton;
                NoButton.PreviousElement     = YesButton;
                NoButton.NextElement         = CancelButton;
                CancelButton.PreviousElement = NoButton;

                MainWindow.HighlightedElement = YesButton;
                YesButton.Highlighted         = true;

                break;

            case DialogBoxButtons.AbortRetryIgnore:
                AbortButton  = new FlaggedCloseButton(MainWindow, AbortButtonText, ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, MainWindow.Length - 39, MainWindow.Height - 2);
                RetryButton  = new FlaggedCloseButton(MainWindow, RetryButtonText, ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, MainWindow.Length - 26, MainWindow.Height - 2);
                IgnoreButton = new FlaggedCloseButton(MainWindow, IgnoreButtonText, ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, MainWindow.Length - 13, MainWindow.Height - 2);

                MainWindow.AddElement(AbortButton);
                MainWindow.AddElement(RetryButton);
                MainWindow.AddElement(IgnoreButton);

                AbortButton.NextElement      = RetryButton;
                RetryButton.PreviousElement  = AbortButton;
                RetryButton.NextElement      = IgnoreButton;
                IgnoreButton.PreviousElement = RetryButton;

                MainWindow.HighlightedElement = AbortButton;
                AbortButton.Highlighted       = true;

                break;

            default:
                break;
            }
        }