示例#1
0
 /// <summary>
 /// Creates a new instance of <see cref="UIFelliSquare"/>.
 /// </summary>
 /// <param name="name">The name given to the element.
 /// This is basically an ID.</param>
 /// <param name="position">The anchor position of this element.</param>
 /// <param name="square">The game's square.</param>
 /// <param name="colorBg">The background color of the element.</param>
 /// <param name="colorFg">The foreground color of the element.</param>
 /// <param name="colorHoverBg">The background color of the element
 /// when hovered.</param>
 public UIFelliSquare(string name, UIPosition position, BoardSquare square,
                      ConsoleColor colorBg      = UISettings.ColorBoardSquareBg,
                      ConsoleColor colorFg      = UISettings.ColorBoardSquareFg,
                      ConsoleColor colorHoverBg = UISettings.ColorBoardSquareHoverBg)
     : base(name, position, colorBg, colorFg, colorHoverBg)
 {
     this.Square = square;
 }
示例#2
0
        /// <summary>
        /// Creates a new instance of <see cref="UIInfoPanel"/>.
        /// </summary>
        /// <param name="name">The name given to the element.
        /// This is basically an ID.</param>
        /// <param name="position">The anchor position of this element.</param>
        /// <param name="padding">The padding to be applied to the entire
        /// info panel.</param>
        /// <param name="colorBg">The background color of the element.</param>
        /// <param name="colorFg">The foreground color of the element.</param>
        public UIInfoPanel(string name, UIPosition position, int padding,
                           ConsoleColor colorBg = UISettings.ColorInfoPanelBg,
                           ConsoleColor colorFg = UISettings.ColorInfoPanelFg)
            : base(name, position, colorBg, colorFg)
        {
            this.padding = padding;

            this.content = new List <UIText>();
        }
示例#3
0
        /// <summary>
        /// Created a new instance of <see cref="UIText"/>.
        /// </summary>
        /// <param name="name">The name given to the element.
        /// This is basically an ID.</param>
        /// <param name="position">The anchor position of this element.</param>
        /// <param name="content">The content to be displayed.</param>
        /// <param name="topPadding">The padding to be applied above the
        /// content.</param>
        /// <param name="bottomPadding">The padding to be applied below the
        /// content.</param>
        /// <param name="colorBg">The background color of the element.</param>
        /// <param name="colorFg">The foreground color of the element.</param>
        /// <param name="colorContentBg">The content's background color.</param>
        public UIText(string name, UIPosition position, string content,
                      int topPadding, int bottomPadding, ConsoleColor colorBg,
                      ConsoleColor colorFg, ConsoleColor colorContentBg)
            : base(name, position, colorBg, colorFg)
        {
            this.Content = content;

            this.topPadding     = topPadding;
            this.bottomPadding  = bottomPadding;
            this.contentColorBg = colorContentBg;
        }
示例#4
0
 /// <summary>
 /// Creates a new instance of <see cref="UIButton"/>.
 /// </summary>
 /// <param name="name">The name given to the element.
 /// This is basically an ID.</param>
 /// <param name="position">The anchor position of this element.</param>
 /// <param name="text">The text to be displayed.</param>
 /// <param name="leftRightPadding">The ammount of padding
 /// to the left and right.</param>
 /// <param name="topBottomPadding">The ammount of padding
 /// to the top and bottom.</param>
 /// <param name="colorBg">The background color of the button.</param>
 /// <param name="colorFg">The foreground color of the button.</param>
 /// <param name="colorHoverBg">The background color of the button
 /// when hovered.</param>
 /// <param name="colorHoverFg">The foreground color of the button
 /// when hovered.</param>
 public UIButton(string name, UIPosition position, string text,
                 int leftRightPadding      = 1, int topBottomPadding = 1,
                 ConsoleColor colorBg      = UISettings.ColorButtonBg,
                 ConsoleColor colorFg      = UISettings.ColorButtonFg,
                 ConsoleColor colorHoverBg = UISettings.ColorButtonHoverBg,
                 ConsoleColor colorHoverFg = UISettings.ColorButtonHoverFg)
     : base(name, position, colorBg, colorFg, colorHoverBg, colorHoverFg)
 {
     this.text             = text;
     this.leftRightPadding = leftRightPadding;
     this.topBottomPadding = topBottomPadding;
 }
示例#5
0
 /// <summary>
 /// Creates a new instance of <see cref="UITitle"/>.
 /// </summary>
 /// <param name="name">The name given to the element.
 /// This is basically an ID.</param>
 /// <param name="position">The anchor position of this element.</param>
 /// <param name="text">The text to be displayed.</param>
 /// <param name="leftRightPadding">The left/right padding.</param>
 /// <param name="topBottomPadding">The top/bottom padding.</param>
 /// <param name="leftBorderWith">The width of the left border.</param>
 /// <param name="colorBg">The background color of the element.</param>
 /// <param name="colorFg">The foreground color of the element.</param>
 /// <param name="colorBorder">The color of the border.</param>
 public UITitle(string name, UIPosition position, string text,
                int leftRightPadding, int topBottomPadding, int leftBorderWith = 1,
                ConsoleColor colorBg     = UISettings.ColorTitleBg,
                ConsoleColor colorFg     = UISettings.ColorTitleFg,
                ConsoleColor colorBorder = UISettings.ColorTitleBorder)
     : base(name, position, colorBg, colorFg)
 {
     this.leftBorderWidth  = leftBorderWith;
     this.leftRightPadding = leftRightPadding;
     this.topBottomPadding = topBottomPadding;
     this.text             = text;
     this.borderColor      = colorBorder;
 }
示例#6
0
        /// <summary>
        /// Creates a new instance of <see cref="UIFelliRow"/>.
        /// </summary>
        /// <param name="name">The name given to the element. This is basically an ID.</param>
        /// <param name="position">The anchor position of this element.</param>
        /// <param name="row">The game board's row.</param>
        /// <param name="squareSpacing">The spacing between squares.</param>
        /// <param name="colorBg">The background color of the element.</param>
        /// <param name="colorFg">The foreground color of the element.</param>
        public UIFelliRow(string name, UIPosition position, BoardRow row,
                          int squareSpacing, ConsoleColor colorBg = UISettings.ColorBoardRowBg,
                          ConsoleColor colorFg = UISettings.ColorConsoleFg)
            : base(name, position, colorBg, colorFg)
        {
            this.row = row;

            this.squares = new UIFelliSquare[row.Squares.Length];

            this.squareSpacing = squareSpacing;

            for (int i = 0; i < row.Squares.Length; i++)
            {
                this.squares[i] = new UIFelliSquare($"felliSquare{i}",
                                                    this.TopLeft, row.Squares[i]);
            }
        }
示例#7
0
        /// <summary>
        /// Shows this row's squares.
        /// </summary>
        private void ShowSquares()
        {
            UIPosition deltaPosition;

            // First square ignores spacing
            for (int i = 0, spaceMult = 0; i < squares.Length; i++, spaceMult = 1)
            {
                int spacing = squares[i].Width * squareSpacing * spaceMult * i;

                squares[i].SetPosition(this.TopLeft);

                deltaPosition = new UIPosition(squares[i].Width * i + spacing, 0);

                squares[i].Move(deltaPosition);

                squares[i].Display();
            }
        }
示例#8
0
        /// <summary>
        /// Base constructor.
        /// </summary>
        /// <param name="name">The name given to the element.
        /// This is basically an ID.</param>
        /// <param name="position">The anchor position of this element.</param>
        /// <param name="colorBg">The background color of the element.</param>
        /// <param name="colorFg">The foreground color of the element.</param>
        /// <param name="colorHoverBg">The background color of the element when
        /// hovered.</param>
        /// <param name="colorHoverFg">The foreground color of the element when
        /// hovered.</param>
        public UIElement(string name, UIPosition position,
                         ConsoleColor colorBg,
                         ConsoleColor colorFg,
                         ConsoleColor colorHoverBg = UISettings.ColorConsoleBg,
                         ConsoleColor colorHoverFg = UISettings.ColorConsoleFg)
        {
            this.Name = name;

            this.TopLeft = position;

            this.colorBackground = colorBg;

            this.colorForeground = colorFg;

            this.colorBackgroundHover = colorHoverBg;

            this.colorForegroundHover = colorHoverFg;
        }
示例#9
0
        /// <summary>
        /// Creates a new instance of <see cref="UIFelliBoard"/>.
        /// </summary>
        /// <param name="name">The name given to the element.
        /// This is basically an ID.</param>
        /// <param name="position">The anchor position of this element.</param>
        /// <param name="board">The game's board.</param>
        /// <param name="colorBg">The background color of the element.</param>
        /// <param name="colorFg">The foreground color of the element.</param>
        public UIFelliBoard(string name, UIPosition position, Board board,
                            ConsoleColor colorBg = UISettings.ColorConsoleBg,
                            ConsoleColor colorFg = UISettings.ColorConsoleFg)
            : base(name, position, colorBg, colorFg)
        {
            this.board = board;

            this.rows = new UIFelliRow[board.Rows.Length];

            for (int i = 0; i < board.Rows.Length; i++)
            {
                // If i is even spacing is 1, else is 0
                int spacing = (i % 2) == 0 ? 1 : 0;

                this.rows[i] = new UIFelliRow($"felliRow{i}",
                                              this.TopLeft, board.Rows[i], spacing);
            }
        }
示例#10
0
        /// <summary>
        /// Shows all rows.
        /// </summary>
        private void ShowRows()
        {
            UIPosition delta;

            for (int i = 0; i < rows.Length; i++)
            {
                // Center the row
                int x = (this.Width - rows[i].Width) / 2;

                rows[i].SetPosition(this.TopLeft);

                delta = new UIPosition(x, i * rows[i].Height);

                rows[i].Move(delta);

                rows[i].Display();
            }
        }
示例#11
0
        /// <summary>
        /// Created a new instance of <see cref="UIDialog"/>.
        /// </summary>
        /// <param name="name">The name given to the dialog.
        /// This is basically an ID.</param>
        /// <param name="position">The anchor position of this element.</param>
        /// <param name="title">The title of the dialog.</param>
        /// <param name="text">The text for the body of the dialog.</param>
        /// <param name="button1Text">The text for the first button.</param>
        /// <param name="button2Text">The text for the second button.</param>
        /// <param name="padding">The padding to add to the entire dialog.</param>
        /// <param name="titleTextMargin">The margin between the title and the
        /// text.</param>
        /// <param name="textButtonsMargin">The margin between the text and the
        /// buttons.</param>
        /// <param name="buttonsMargin">The margin between the buttons.</param>
        /// <param name="colorTitleFg">The title's foreground color.</param>
        /// <param name="colorBg">The background color for the dialog.</param>
        /// <param name="colorFg">The foreground color for the dialog.</param>
        public UIDialog(string name, UIPosition position, string title,
                        string text, string button1Text, string button2Text,
                        int padding               = 1, int titleTextMargin = 1, int textButtonsMargin = 2,
                        int buttonsMargin         = 1,
                        ConsoleColor colorTitleFg = UISettings.ColorDialogTitleFg,
                        ConsoleColor colorBg      = UISettings.ColorDialogBg,
                        ConsoleColor colorFg      = UISettings.ColorDialogFg)
            : base(name, position, colorBg, colorFg)
        {
            this.title = title;

            this.text = text;

            this.padding = padding;

            this.titleTextMargin = titleTextMargin;

            this.textButtonsMargin = textButtonsMargin;

            this.buttonsMarging = buttonsMargin;

            this.titleColorFg = colorTitleFg;

            this.buttons = new UIButton[2]
            {
                new UIButton("dialogBtn1", this.TopLeft, button1Text, 2,
                             dialogButtonTopBottomPadding,
                             UISettings.ColorDialogButtonBg,
                             UISettings.ColorDialogButtonFg,
                             UISettings.ColorDialogButtonHoverBg,
                             UISettings.ColorDialogButtonHoverFg),

                new UIButton("dialogBtn2", this.TopRight, button2Text, 2,
                             dialogButtonTopBottomPadding,
                             UISettings.ColorDialogButtonBg,
                             UISettings.ColorDialogButtonFg,
                             UISettings.ColorDialogButtonHoverBg,
                             UISettings.ColorDialogButtonHoverFg)
            };
        }
示例#12
0
 /// <summary>
 /// Moves the anchor point.
 /// </summary>
 /// <param name="delta">A <see cref="UIPosition"/> representative of the
 /// desired move delta.</param>
 public void Move(UIPosition delta)
 {
     this.TopLeft += delta;
 }
示例#13
0
 /// <summary>
 /// Sets the anchor position of the element.
 /// </summary>
 /// <param name="newPosition">The new anchor position.</param>
 public void SetPosition(UIPosition newPosition)
 {
     this.TopLeft = newPosition;
 }