コード例 #1
0
ファイル: Canvas.cs プロジェクト: vanattab/ochregui
        // /////////////////////////////////////////////////////////////////////////////////

        // /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Sets the pigment of a single character at the given coordinates.
        /// </summary>
        /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="pigment"/>
        /// is null</exception>
        public void SetCharPigment(int x, int y, Pigment pigment)
        {
            if (pigment == null)
            {
                throw new ArgumentNullException("pigment");
            }

            Console.setCharBackground(x, y, pigment.Background.GetTCODColor());
            Console.setCharForeground(x, y, pigment.Foreground.GetTCODColor());
        }
コード例 #2
0
ファイル: Canvas.cs プロジェクト: vanattab/ochregui
        // /////////////////////////////////////////////////////////////////////////////////
        #endregion
        #region Public Methods
        // /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Sets the default pigment for this Canvas.  If no other pigment is specified
        /// for drawing operations, this pigment is used.
        /// </summary>
        /// <exception cref="System.ArgumentNullException">Thrown if <paramref name="pigment"/>
        /// is null</exception>
        public void SetDefaultPigment(Pigment pigment)
        {
            if (pigment == null)
            {
                throw new ArgumentNullException("pigment");
            }

            defaultPigment = pigment;
            SetPigment(pigment);
        }
コード例 #3
0
ファイル: Canvas.cs プロジェクト: vanattab/ochregui
        // /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Construct a Canvas object of the given size.
        /// </summary>
        /// <exception cref="System.ArgumentOutOfRangeException">Thrown when the specified
        /// <paramref name="size"/> is larger than the screen size</exception>
        public Canvas(Size size)
        {
            if (size.Width > Application.ScreenSize.Width ||
                size.Height > Application.ScreenSize.Height)
            {
                throw new ArgumentOutOfRangeException("size", "The specified size must be equal to or smaller than the screen size");
            }

            defaultPigment = new Pigment(0xffffff, 0x000000);
            Console        = new TCODConsole(size.Width, size.Height);
            this.Size      = size;
        }
コード例 #4
0
ファイル: Canvas.cs プロジェクト: vanattab/ochregui
        /// <summary>
        /// Draws a vertical line of the given length and starting coordinates
        /// </summary>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// Thrown when the specified <paramref name="startPos"/> is outside of this Canvas region</exception>
        public void DrawVLine(Point startPos, int length, Pigment pigment = null)
        {
            if (startPos.X < 0 || startPos.X >= this.Size.Width)
            {
                throw new ArgumentOutOfRangeException("startPos", "The specified x coordinate is invalid.");
            }

            if (startPos.Y < 0 || startPos.Y >= this.Size.Height)
            {
                throw new ArgumentOutOfRangeException("startPos", "The specified y coordinate is invalid.");
            }

            DrawVLine(startPos.X, startPos.Y, length, pigment);
        }
コード例 #5
0
ファイル: Canvas.cs プロジェクト: vanattab/ochregui
        // /////////////////////////////////////////////////////////////////////////////////

        // /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Prints a single character at the specified coordinates.
        /// </summary>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// Thrown when the specified <paramref name="lPos"/> is outside of this Canvas region</exception>
        public void PrintChar(Point lPos, int character, Pigment pigment = null)
        {
            if (lPos.X < 0 || lPos.X >= this.Size.Width)
            {
                throw new ArgumentOutOfRangeException("lPos", "The specified x coordinate is invalid.");
            }

            if (lPos.Y < 0 || lPos.Y >= this.Size.Height)
            {
                throw new ArgumentOutOfRangeException("lPos", "The specified y coordinate is invalid.");
            }

            PrintChar(lPos.X, lPos.Y, character, pigment);
        }
コード例 #6
0
ファイル: Canvas.cs プロジェクト: vanattab/ochregui
        // /////////////////////////////////////////////////////////////////////////////////

        // /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Prints the specified string at the given coordinates.
        /// </summary>
        /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="text"/> is
        /// null</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// Thrown when the specified <paramref name="lPos"/> is outside of this Canvas region</exception>
        public void PrintString(Point lPos, string text, Pigment pigment = null)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            if (lPos.X < 0 || lPos.X >= this.Size.Width)
            {
                throw new ArgumentOutOfRangeException("lPos", "The specified x coordinate is invalid.");
            }

            if (lPos.Y < 0 || lPos.Y >= this.Size.Height)
            {
                throw new ArgumentOutOfRangeException("lPos", "The specified y coordinate is invalid.");
            }

            PrintString(lPos.X, lPos.Y, text, pigment);
        }
コード例 #7
0
ファイル: Canvas.cs プロジェクト: vanattab/ochregui
        /// <summary>
        /// Sets the pigment of a single character at the given coordinates.
        /// </summary>
        /// <exception cref="System.ArgumentNullException">Thrown when pigment is null</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// Thrown when the specified <paramref name="position"/> is outside of this Canvas region</exception>
        public void SetCharPigment(Point position, Pigment pigment)
        {
            if (pigment == null)
            {
                throw new ArgumentNullException("pigment");
            }

            if (position.X < 0 || position.X >= this.Size.Width)
            {
                throw new ArgumentOutOfRangeException("position", "The specified x coordinate is invalid.");
            }

            if (position.Y < 0 || position.Y >= this.Size.Width)
            {
                throw new ArgumentOutOfRangeException("position", "The specified y coordinate is invalid.");
            }

            SetCharPigment(position.X, position.Y, pigment);
        }
コード例 #8
0
ファイル: Canvas.cs プロジェクト: vanattab/ochregui
        // /////////////////////////////////////////////////////////////////////////////////

        // /////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Prints the specified string at the given coordinates.  The text is aligned
        /// both horizontally and vertically with the specified alignments, and within
        /// the specified size of the field.
        /// If the text length is larger than the field width, then the text will be trimmed to fit.
        /// The field width and height must be equal to or greater than 1, or an exception will
        /// be thrown.
        /// </summary>
        /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="text"/> is
        /// null</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// Thrown when the specified position is outside of this Canvas region</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// Thrown when the width or height of the field size is less than 1</exception>
        public void PrintStringAligned(int x, int y, string text, HorizontalAlignment hAlign,
                                       VerticalAlignment vAlign, Size fieldSize, Pigment pigment = null)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            if (x < 0 || x >= this.Size.Width)
            {
                throw new ArgumentOutOfRangeException("x", "The specified x coordinate is invalid.");
            }

            if (y < 0 || y >= this.Size.Height)
            {
                throw new ArgumentOutOfRangeException("y", "The specified y coordinate is invalid.");
            }

            if (fieldSize.Width < 1)
            {
                throw new ArgumentOutOfRangeException("fieldSize", "The specified width of fieldSize is less than 1");
            }

            if (fieldSize.Height < 1)
            {
                throw new ArgumentOutOfRangeException("fieldSize", "The specified height of fieldSize is less than 1");
            }

            if (fieldSize.Width < TextLength(text))
            {
                text = TrimText(text, fieldSize.Width);
            }

            Point pos = GetHVAlign(new Point(x, y), text, hAlign, vAlign, fieldSize);

            PrintString(pos, text, pigment);
        }
コード例 #9
0
ファイル: Canvas.cs プロジェクト: vanattab/ochregui
        /// <summary>
        /// Draws a vertical line of the given length and starting coordinates
        /// </summary>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// Thrown when the specified position is outside of this Canvas region</exception>
        public void DrawVLine(int x, int y, int length, Pigment pigment = null)
        {
            if (x < 0 || x >= this.Size.Width)
            {
                throw new ArgumentOutOfRangeException("x", "The specified x coordinate is invalid.");
            }

            if (y < 0 || y >= this.Size.Height)
            {
                throw new ArgumentOutOfRangeException("y", "The specified y coordinate is invalid.");
            }

            if (pigment != null)
            {
                SetPigment(pigment);
            }

            Console.vline(x, y, length);

            if (pigment != null)
            {
                SetPigment(defaultPigment);
            }
        }
コード例 #10
0
ファイル: Canvas.cs プロジェクト: vanattab/ochregui
        // /////////////////////////////////////////////////////////////////////////////////


        /// <summary>
        /// Draws a horizontal line of the given length and starting coordinates
        /// </summary>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// Thrown when the specified position is outside of this Canvas region</exception>
        public void DrawHLine(int startX, int startY, int length, Pigment pigment = null)
        {
            if (startX < 0 || startX >= this.Size.Width)
            {
                throw new ArgumentOutOfRangeException("startX", "The specified x coordinate is invalid.");
            }

            if (startY < 0 || startY >= this.Size.Height)
            {
                throw new ArgumentOutOfRangeException("startY", "The specified y coordinate is invalid.");
            }

            if (pigment != null)
            {
                SetPigment(pigment);
            }

            Console.hline(startX, startY, length);

            if (pigment != null)
            {
                SetPigment(defaultPigment);
            }
        }
コード例 #11
0
ファイル: Canvas.cs プロジェクト: vanattab/ochregui
        // /////////////////////////////////////////////////////////////////////////////////

        // /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Prints a single character at the specified coordinates.
        /// </summary>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// Thrown when the specified position is outside of this Canvas region</exception>
        public void PrintChar(int x, int y, int character, Pigment pigment = null)
        {
            if (x < 0 || x >= this.Size.Width)
            {
                throw new ArgumentOutOfRangeException("x", "The specified x coordinate is invalid.");
            }

            if (y < 0 || y >= this.Size.Height)
            {
                throw new ArgumentOutOfRangeException("y", "The specified y coordinate is invalid.");
            }

            if (pigment != null)
            {
                SetPigment(pigment);
            }

            Console.putChar(x, y, character);

            if (pigment != null)
            {
                SetPigment(defaultPigment);
            }
        }
コード例 #12
0
ファイル: Canvas.cs プロジェクト: vanattab/ochregui
 // /////////////////////////////////////////////////////////////////////////////////
 private void SetPigment(Pigment pigment)
 {
     Console.setBackgroundColor(pigment.Background.GetTCODColor());
     Console.setBackgroundFlag(pigment.BackgroundFlag);
     Console.setForegroundColor(pigment.Foreground.GetTCODColor());
 }
コード例 #13
0
ファイル: Canvas.cs プロジェクト: vanattab/ochregui
        // /////////////////////////////////////////////////////////////////////////////////

        // /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Prints the specified string at the given coordinates.  The text is aligned
        /// horizontally with the specified alignment and within the specified field length.
        /// If the text length is larger than the field length, then the text will be trimmed to fit.
        /// The field length must be equal to or greater than 1, or an exception will be thrown.
        /// </summary>
        /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="text"/> is
        /// null</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// Thrown when the specified <paramref name="lPos"/> is outside of this Canvas region</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// Thrown when the specified field length is less than 1</exception>
        public void PrintStringAligned(Point lPos, string text,
                                       HorizontalAlignment alignment, int fieldLength, Pigment pigment = null)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            if (lPos.X < 0 || lPos.X >= this.Size.Width)
            {
                throw new ArgumentOutOfRangeException("lPos", "The specified x coordinate is invalid.");
            }

            if (lPos.Y < 0 || lPos.Y >= this.Size.Height)
            {
                throw new ArgumentOutOfRangeException("lPos", "The specified y coordinate is invalid.");
            }

            if (fieldLength < 1)
            {
                throw new ArgumentOutOfRangeException("fieldLength",
                                                      "The field length must equal to or greater than 1");
            }

            PrintStringAligned(lPos.X, lPos.Y, text, alignment, fieldLength, pigment);
        }
コード例 #14
0
ファイル: Canvas.cs プロジェクト: vanattab/ochregui
        // /////////////////////////////////////////////////////////////////////////////////

        // /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Prints the specified string at the given coordinates.  The text is aligned
        /// horizontally with the specified alignment and within the specified field length.
        /// If the text length is larger than the field length, then the text will be trimmed to fit.
        /// The field length must be equal to or greater than 1, or an exception will be thrown.
        /// </summary>
        /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="text"/> is
        /// null</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// Thrown when the specified position is outside of this Canvas region</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// Thrown when the specified field length is less than 1</exception>
        public void PrintStringAligned(int x, int y, string text,
                                       HorizontalAlignment alignment, int fieldLength, Pigment pigment = null)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            if (x < 0 || x >= this.Size.Width)
            {
                throw new ArgumentOutOfRangeException("x", "The specified x coordinate is invalid.");
            }

            if (y < 0 || y >= this.Size.Height)
            {
                throw new ArgumentOutOfRangeException("y", "The specified y coordinate is invalid.");
            }

            if (fieldLength < 1)
            {
                throw new ArgumentOutOfRangeException("fieldLength",
                                                      "The field length must equal to or greater than 1");
            }

            Point pos = GetHorAlign(new Point(x, y), text, alignment, fieldLength);

            if (fieldLength < TextLength(text))
            {
                text = TrimText(text, fieldLength);
            }

            PrintString(pos, text, pigment);
        }
コード例 #15
0
ファイル: Control.cs プロジェクト: AIBrain/ochregui
 // /////////////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Draw a frame around the control border.  If the <paramref name="pigment"/> is null,
 /// the frame will drawn with the Canvas' current default pigment.
 /// </summary>
 protected void DrawFrame(Pigment pigment = null)
 {
     if (this.Size.Width > 2 && this.Size.Height > 2)
     {
         Canvas.PrintFrame(null, pigment);
     }
 }
コード例 #16
0
ファイル: Program.cs プロジェクト: AIBrain/ochregui
        protected override void OnSettingUp()
        {
            base.OnSettingUp();

            Color yellow = Color.DARK_AMBER;
            Color blue = Color.BLUE;

            CheckBox cb1 = new CheckBox(new CheckBoxTemplate()
            {
                UpperLeftPos = new Point(1,1),
                Label = yellow.DoForegroundCode() + " A check" + blue.DoBackgroundCode() + "box",
                MinimumWidth = 13,
                HasFrameBorder = false,
                //LabelAlignment = HorizontalAlignment.Center,
                Tooltip = "Testing" + blue.DoBackgroundCode() + " Tootlip"
            });

            Button b1 = new Button(new ButtonTemplate()
            {
                UpperLeftPos = new Point(1,2),
                Label = yellow.DoForegroundCode() + "A " + blue.DoBackgroundCode()+ "button",
                MinimumWidth = 11,
                LabelAlignment = HorizontalAlignment.Center
            });

            CheckBox cb3 = new CheckBox(new CheckBoxTemplate()
            {
                UpperLeftPos = new Point(1, 5),
                Label = yellow.DoForegroundCode() + "che" +
                    Color.StopColorCode + "cbox 3",
                AutoSizeOverride = new Size(5,3),
                HasFrameBorder = false,
                LabelAlignment = HorizontalAlignment.Center,
                CheckOnLeft = false,
            });

            CheckBox cb4 = new CheckBox(new CheckBoxTemplate()
            {
                UpperLeftPos = new Point(1, 7),
                Label = "check4",
                HasFrameBorder = false,
                AutoSizeOverride = new Size(11, 1),
                LabelAlignment = HorizontalAlignment.Center,
                CheckOnLeft = false,
            });

            ValueBar vb = new ValueBar(new ValueBarTemplate()
            {
                UpperLeftPos = new Point(1,12),
                MaximumValue = 100,
                StartingValue = 50,
                MinimumBGIntensity = .3f,
                MinimumFGIntensity = .5f,
                Width = 15,
                Tooltip = "Testing Tooltip"
            });

            Pigment p = new Pigment(0xffffff, 0x334455);

            AddControls(cb3);

            AddSchedule(new Schedule(Callback, 2));
        }