示例#1
0
        /// <summary>
        /// Draws the control.
        /// </summary>
        protected override void Draw(GraphicBuffer buffer)
        {
            buffer.BackgroundDrawingColor = this.BackgroundColor;
            buffer.ForegroundDrawingColor = this.ForegroundColor;

            buffer.DrawRectangle(' ', Coordinate.Origin, this.Size, true);
        }
示例#2
0
        protected override void Draw(GraphicBuffer buffer)
        {
            base.Draw(buffer);

            buffer.DrawRectangle('#', Coordinate.Origin, new Size(15, 10), true);
            buffer.DrawRectangle('#', new Coordinate(0, 11), new Size(15, 10), false);
        }
        protected override void Draw(GraphicBuffer buffer)
        {
            base.Draw(buffer);

            buffer.DrawEllipse('#', new Coordinate(11, 7), 4, 7);
            buffer.DrawEllipse('#', new Coordinate(11, 25), 7, 7);
        }
示例#4
0
 /// <summary>
 /// Draws the line.
 /// </summary>
 /// <param name="buffer">The graphic buffer.</param>
 public override void Draw(GraphicBuffer buffer)
 {
     foreach (Coordinate point in RasterLine(this.StartPoint.X, this.StartPoint.Y, this.EndPoint.X, this.EndPoint.Y))
     {
         buffer.DrawPixel(this.Token, point);
     }
 }
示例#5
0
        protected override void Draw(GraphicBuffer buffer)
        {
            base.Draw(buffer);

            buffer.DrawLine('#', new Coordinate(0, 2), new Coordinate(15, 2));
            buffer.DrawLine('#', new Coordinate(0, 6), new Coordinate(0, 15));
            buffer.DrawLine('#', new Coordinate(0, 19), new Coordinate(13, 36));
        }
示例#6
0
        /// <summary>
        /// Draws the control.
        /// </summary>
        /// <param name="buffer">The <see cref="GraphicBuffer"/> to draw on.</param>
        protected override void Draw(GraphicBuffer buffer)
        {
            buffer.ForegroundDrawingColor = this.ForegroundColor;
            buffer.BackgroundDrawingColor = this.BackgroundColor;

            buffer.DrawRectangle(' ', Coordinate.Origin, this.Size, true);

            var words = new List<string>();
            words.AddRange(this.Text.Split(' ')); //Split text into words

            var lines = new List<string>();

            // If there is only one word, draw it immediately.
            // This fixes a bug, which caues a cut-off at the end of a line
            // (the cut-off for only one word is desired)
            if (words.Count == 1)
            {
                lines.Add(words[0]);
            }

            else
            {
                do
                {

                    string line = String.Empty;
                    bool first = true;

                    for (int i = 0; i < words.Count; i++)
                    {
                        if (line.Length + words[0].Length < this.Size.Width) //check if the line fits into the label
                        {
                            string space = first ? String.Empty : " ";
                            first = false;

                            line += space + words[0];
                            words.Remove(words[0]);
                            i--;
                        }

                        else
                        {
                            break;
                        }
                    }

                    lines.Add(line);
                }
                while (words.Count > 0 && lines.Count < this.Size.Height);
            }

            for (int i = 0; i < lines.Count; i++)
            {
                buffer.DrawLine(lines[i], new Coordinate(0, i));
            }
        }
示例#7
0
        /// <summary>
        /// Draws the control.
        /// </summary>
        protected override void Draw(GraphicBuffer buffer)
        {
            buffer.BackgroundDrawingColor = this.BackgroundColor;
            buffer.ForegroundDrawingColor = this.ForegroundColor;

            string background = String.Empty;
            background = background.PadRight(this.Length, ' ');

            buffer.DrawLine(background, Coordinate.Origin);

            buffer.DrawLine(this.Text, Coordinate.Origin);
        }
示例#8
0
        /// <summary>
        /// Draws the ellipse.
        /// </summary>
        /// <param name="buffer">The <see cref="GraphicBuffer"/> to draw on.</param>
        public override void Draw(GraphicBuffer buffer)
        {
            var points = this.RasterEllipse
                (
                    this.Centre.X,
                    this.Centre.Y,
                    this.A + (int)(this.A / (1.75)), // Compensate the proportions of the symbols in the console
                    this.B
                );

            foreach (Point point in points)
            {
                buffer.DrawPixel(this.Token, new Coordinate((int)point.X, (int)point.Y));
            }
        }
示例#9
0
        /// <summary>
        /// Draws the ellipse.
        /// </summary>
        /// <param name="buffer">The <see cref="GraphicBuffer"/> to draw on.</param>
        public override void Draw(GraphicBuffer buffer)
        {
            var points = RasterEllipse
                         (
                this.Centre.X,
                this.Centre.Y,
                this.A + (int)(this.A / (1.75)), // Compensate the proportions of the symbols in the console
                this.B
                         );

            foreach (Point point in points)
            {
                buffer.DrawPixel(this.Token, new Coordinate((int)point.X, (int)point.Y));
            }
        }
示例#10
0
        /// <summary>
        /// Merges the specified buffer at the specified location into this buffer.
        /// </summary>
        /// <param name="otherBuffer">The buffer, that should be merged into this instance.</param>
        /// <param name="location">The location.</param>
        public void Merge(GraphicBuffer otherBuffer, Coordinate location)
        {
            var fColor = this.ForegroundDrawingColor;
            var bColor = this.BackgroundDrawingColor;

            otherBuffer.TraversePixels((x, y) =>
            {
                this.ForegroundDrawingColor = otherBuffer.buffer[x, y].ForegroundColor;
                this.BackgroundDrawingColor = otherBuffer.buffer[x, y].BackgroundColor;

                this.DrawPixel(otherBuffer.buffer[x, y].Token, location + new Coordinate(x, y));
            });

            this.ForegroundDrawingColor = fColor;
            this.BackgroundDrawingColor = bColor;
        }
示例#11
0
        /// <summary>
        /// Updates the control if <see cref="Control.IsVisible"/> is set to true.
        /// </summary>
        /// <param name="buffer">The <see cref="GraphicBuffer"/> to draw on.</param>
        public override void Update(GraphicBuffer buffer)
        {
            base.Update(buffer);

            if (this.IsVisible)
            {
                foreach (Control control in this.controls)
                {
                    var localBuffer = new GraphicBuffer(control.Size);

                    control.Update(localBuffer);

                    buffer.Merge(localBuffer, control.RelativeLocation);
                }
            }
        }
示例#12
0
 /// <summary>
 /// Draws the control.
 /// </summary>
 /// <param name="buffer">The <see cref="GraphicBuffer"/> to draw on.</param>
 protected abstract void Draw(GraphicBuffer buffer);
示例#13
0
 /// <summary>
 /// Updates the control if <see cref="IsVisible"/> is set to true.
 /// </summary>
 /// <param name="buffer">The <see cref="GraphicBuffer"/> to draw on.</param>
 public virtual void Update(GraphicBuffer buffer)
 {
     if (this.IsVisible)
     {
         this.Draw(buffer);
     }
 }
示例#14
0
        /// <summary>
        /// Updates the control if <see cref="Control.IsVisible"/> is set to true.
        /// </summary>
        /// <param name="buffer">The <see cref="GraphicBuffer"/> to draw on.</param>
        public override void Update(GraphicBuffer buffer)
        {
            base.Update(buffer);

            buffer.DrawToScreen(this.AbsoluteLocation);
        }
示例#15
0
        /// <summary>
        /// Merges the specified buffer at the specified location into this buffer.
        /// </summary>
        /// <param name="otherBuffer">The buffer, that should be merged into this instance.</param>
        /// <param name="location">The location.</param>
        public void Merge(GraphicBuffer otherBuffer, Coordinate location)
        {
            var fColor = this.ForegroundDrawingColor;
            var bColor = this.BackgroundDrawingColor;

            otherBuffer.TraversePixels((x, y) =>
                {
                    this.ForegroundDrawingColor = otherBuffer.buffer[x, y].ForegroundColor;
                    this.BackgroundDrawingColor = otherBuffer.buffer[x, y].BackgroundColor;

                    this.DrawPixel(otherBuffer.buffer[x, y].Token, location + new Coordinate(x, y));
                });

            this.ForegroundDrawingColor = fColor;
            this.BackgroundDrawingColor = bColor;
        }
示例#16
0
        static void InicializovatHru()
        {
            Console.WindowWidth = 50;
            Console.WindowHeight = 20;

            PoziceHraceX = Console.WindowWidth / 2;
            HraciPlocha = new Pole[Console.WindowHeight, Console.WindowWidth];
            HraciPlochaStrel = new bool[Console.WindowHeight, Console.WindowWidth];
            Buffer = new GraphicBuffer(new Size(Console.WindowWidth, Console.WindowHeight));
            ConsoleEx.CursorVisible = false;

            ZvukExploze = new SoundPlayer(Zvuky.Exploze);
            ZvukBod = new SoundPlayer(Zvuky.Bod);
        }