Пример #1
0
        public static void RectangleFilled(Vector2 center, Vector2 size, float angle, Color color,
                                           DrawSpace space = DrawSpace.World)
        {
            if (!Enabled)
            {
                return;
            }

            // TODO: Support angle
            if (angle != 0f)
            {
                throw new NotImplementedException("TODO: Support angle");
            }

            Vector2 bottomLeft  = center - size * 0.5f;
            Vector2 topLeft     = bottomLeft + new Vector2(0f, size.y);
            Vector2 topRight    = topLeft + new Vector2(size.x, 0f);
            Vector2 bottomRight = bottomLeft + new Vector2(size.x, 0f);

            if (space == DrawSpace.World)
            {
                _worldTriangleDrawer.AddTriangle(bottomLeft, bottomRight, topRight, color);
                _worldTriangleDrawer.AddTriangle(bottomLeft, topRight, topLeft, color);
            }
            else
            {
                _screenTriangleDrawer.AddTriangle(bottomLeft, bottomRight, topRight, color);
                _screenTriangleDrawer.AddTriangle(bottomLeft, topRight, topLeft, color);
            }
        }
Пример #2
0
        public override void Draw(DrawSpace ds)
        {
            // border
            ds.Color = IsActive ? ActiveBorderButtonColor : InactiveBorderButtonColor;
            // height is odd
            if( Area.Height == 1 )
            {
                // │ ... │
                ds.PutCharacter(new Point(0,0),             '│');
                ds.PutCharacter(new Point(Area.Width-1,0),  '│');
            }
            else
            {
                var rect = new Rectangle(Point.Empty, Size);
                ds.DrawBorder(rect, DrawSpace.SingleBorder);
            }

            // text
            ds.Color = IsActive ? ActiveTextButtonColor : InactiveTextButtonColor;
            ds.PutString(new Point(1,Area.Height/2), Text, Area.Width-2, centered: true);
            if( Area.Height > 3 )
            {
                // we need to erase spare space
                ds.FillRectangle(new Rectangle(1, 1, Area.Width-2, Area.Height/2-1), ' ');
                ds.FillRectangle(new Rectangle(1, Area.Height/2+1, Area.Width-2, (Area.Height+1)/2-2), ' ');
            }
        }
Пример #3
0
        private void loadImage()
        {
            if (Reticule != null)
            {
                Reticule.Dispose();
            }

            while (true)
            {
                try {
                    Bitmap tempBMP = new Bitmap("ret.bmp");
                    Reticule = new Bitmap(tempBMP);
                    tempBMP.Dispose();

                    this.Size      = Reticule.Size;
                    DrawSpace.Size = Reticule.Size;

                    this.TransparencyKey = Reticule.GetPixel(0, 0);
                    this.BackColor       = this.TransparencyKey;
                    DrawSpace.Image      = Reticule;
                    DrawSpace.Refresh();
                    return;
                } catch (System.IO.FileNotFoundException) {
                    if (MessageBox.Show("Reticule File Not Found, press OK to retry, Cancel to quit", "Error Loading File", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel)
                    {
                        System.Environment.Exit(0);
                    }
                } catch (System.ArgumentException) {
                    if (MessageBox.Show("Reticule File Not Found, press OK to retry, Cancel to quit", "Error Loading File", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel)
                    {
                        System.Environment.Exit(0);
                    }
                }
            }
        }
Пример #4
0
 //Rê chuột
 private void DrawSpace_MouseMove(object sender, MouseEventArgs e)
 {
     //hiện tọa độ
     toaDoX.Text = "" + e.Location.X;
     toaDoY.Text = "" + e.Location.Y;
     //vẽ
     if (curMode == drawMode.Pencil || curMode == drawMode.Brush)
     {
         if (mouseDown == true)
         {
             if (e.Button == MouseButtons.Left)
             {
                 curPoint = e.Location;
                 msPaint.DrawLine(mPen, startPoint, curPoint);
                 startPoint = curPoint;
                 DrawSpace.BackgroundImage = (Bitmap)bm.Clone();
             }
         }
     }
     else
     {
         if (mouseDown == true)
         {
             curPoint = new Point(e.Location.X, e.Location.Y);
             DrawSpace.Refresh();
         }
     }
 }
        public void Initialize()
        {
            Single currentPosX = posX;
            Single currentPosY = posY;
            List<ITile> temp;
            ITile ATile;

            //Fixed objects
            temp = new List<ITile>();
            tiles.Add(temp);
            ATile = new DrawDot(currentPosX, currentPosY, width, height);
            tiles[0].Add(ATile);
            currentPosX += width;
            for (int i = 0; i < 3; i++)
            {
                ATile = new DrawHWall(currentPosX, currentPosY, width, height);
                tiles[0].Add(ATile);
                currentPosX += width;
            }
            currentPosX = posX;
            currentPosY += height;

            temp = new List<ITile>();
            tiles.Add(temp);
            ATile = new DrawVWall(currentPosX, currentPosY, width, height * 3);
            tiles[1].Add(ATile);
            currentPosX += width;
            for (int i = 0; i < 3; i++)
            {
                ATile = new DrawSpace(currentPosX, currentPosY, width, height * 3);
                tiles[1].Add(ATile);
                currentPosX += width;
            }
        }
Пример #6
0
 /// <summary>
 ///     Return the current mouse position in either world or screen space
 /// </summary>
 /// <param name="space">World or Screen space</param>
 /// <returns></returns>
 public Point GetMousePosition(DrawSpace space)
 {
     if (space == DrawSpace.World)
     {
         return(Vector2.Transform(MouseController.CurrentState.Position.ToVector2(),
                                  Matrix.Invert(Camera.TransformMatrix)).ToPoint());
     }
     return(MouseController.CurrentState.Position);
 }
Пример #7
0
        public override void Draw(DrawSpace ds)
        {
            ds.Color = IsActive ? ActiveLineEditColor : InactiveLineEditColor;

            var outText = Text.Substring( TextRolling, Math.Min(Area.Width, Text.Length-TextRolling) );
            if( IsActive && outText.Length < Area.Width )
                outText += "_";

            ds.PutString(Point.Empty, outText, Area.Width);
        }
Пример #8
0
 /// <summary>
 /// Clean up any resources being used.
 /// </summary>
 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing && (components != null))
     {
         components.Dispose();
     }
     DrawSpace.Dispose();
     LayerContainer.Dispose();
     History.Dispose();
     base.Dispose(disposing);
 }
Пример #9
0
        public static void EllipseFilled(Vector2 center, Vector2 size, Color color,
                                         int segments = 16, DrawSpace space = DrawSpace.World)
        {
            if (!Enabled || segments < 3)
            {
                return;
            }

            float   theta      = 0f;
            float   deltaTheta = 2 * Mathf.PI / segments;
            Vector2 first      = default;
            Vector2 end        = default;

            for (int i = 0; i < segments; i++)
            {
                math.sincos(theta, out float y, out float x);
                x *= size.x;
                y *= size.y;

                Vector2 start = end;
                end = center + new Vector2(x, y);

                theta += deltaTheta;

                if (i == 0)
                {
                    first = end;
                    continue;
                }

                if (space == DrawSpace.World)
                {
                    _worldTriangleDrawer.AddTriangle(start, center, end, color);
                }
                else
                {
                    _screenTriangleDrawer.AddTriangle(start, center, end, color);
                }
            }

            if (space == DrawSpace.World)
            {
                _worldTriangleDrawer.AddTriangle(end, center, first, color);
            }
            else
            {
                _screenTriangleDrawer.AddTriangle(end, center, first, color);
            }
        }
Пример #10
0
        public static void Line(Vector2 start, Vector2 end, Color colorStart, Color colorEnd,
                                DrawSpace space = DrawSpace.World)
        {
            if (!Enabled)
            {
                return;
            }

            if (space == DrawSpace.World)
            {
                _worldLineDrawer.AddLine(start, end, colorStart, colorEnd);
            }
            else
            {
                _screenLineDrawer.AddLine(start, end, colorStart, colorEnd);
            }
        }
Пример #11
0
        public static void TriangleFilled(Vector2 v1, Vector2 v2, Vector2 v3, Color color,
                                          DrawSpace space = DrawSpace.World)
        {
            if (!Enabled)
            {
                return;
            }

            if (space == DrawSpace.World)
            {
                _worldTriangleDrawer.AddTriangle(v1, v2, v3, color);
            }
            else
            {
                _screenTriangleDrawer.AddTriangle(v1, v2, v3, color);
            }
        }
Пример #12
0
 public MainForm()
 {
     InitializeComponent();
     msPaint = DrawSpace.CreateGraphics();
     bm      = new Bitmap(DrawSpace.Width, DrawSpace.Height);
     msPaint = Graphics.FromImage(bm);
     /*default color*/
     curColor = Color.Black;
     /*set solid brush*/
     mSolidBrush = new SolidBrush(curColor);
     /*set pen*/
     mPen = new Pen(curColor, curLineSize);
     mPen.SetLineCap(System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.DashCap.Round);
     /*set mode*/
     curMode = drawMode.Pencil;
     /*disable line size*/
     LineSize.Enabled = false;
     LinesSize();
 }
Пример #13
0
        public static void Text(string text, Vector2 position, float size, Color color,
                                TextAnchor anchor = TextAnchor.LowerLeft, DrawSpace space = DrawSpace.World)
        {
            if (!Enabled || string.IsNullOrEmpty(text))
            {
                return;
            }

            // TODO: Support anchor
            if (anchor != TextAnchor.LowerLeft)
            {
                throw new NotImplementedException("TODO: Support anchor");
            }

            if (space == DrawSpace.World)
            {
                _worldTextDrawer.AddText(text, position, size, color);
            }
            else
            {
                _screenTextDrawer.AddText(text, position, size, color);
            }
        }
Пример #14
0
 public static void Text(TextInfo text,
                         TextAnchor anchor = TextAnchor.LowerLeft, DrawSpace space = DrawSpace.World)
 {
     Text(text.Text, text.Position, text.Size, text.Color, anchor, space);
 }
Пример #15
0
 public static void CircleFilled(Vector2 center, float radius, Color color,
                                 int segments    = 16,
                                 DrawSpace space = DrawSpace.World)
 {
     EllipseFilled(center, new Vector2(radius, radius), color, segments, space);
 }
Пример #16
0
 public static void Circle(CircleInfo circle, int segments = 16,
                           DrawSpace space = DrawSpace.World)
 {
     Circle(circle.Center, circle.Radius, circle.Color, segments, space);
 }
Пример #17
0
        public override void Draw(DrawSpace ds)
        {
            ds.Color = IsActive ? ActiveBoxCheckBoxColor : InactiveBoxCheckBoxColor;
            ds.PutString(Point.Empty, State ? CheckCharacter.ToString() : " ", 1);

            ds.Color = IsActive ? ActiveTextCheckBoxColor : InactiveTextCheckBoxColor;
            var outText = " " + Text;

            ds.PutString(new Point(1,0), outText, Area.Width-1);
        }
Пример #18
0
 public static void Ellipse(EllipseInfo ellipse, int segments = 16,
                            DrawSpace space = DrawSpace.World)
 {
     Ellipse(ellipse.Center, ellipse.Size, ellipse.Color, segments, space);
 }
Пример #19
0
        public override void Draw(DrawSpace ds)
        {
            ds.Color = color;

            ds.PutString(new Point(0,0), Text, Area.Width, Centered);
        }
Пример #20
0
 public static void Rectangle(RectangleInfo rectangle,
                              DrawSpace space = DrawSpace.World)
 {
     Rectangle(rectangle.Center, rectangle.Size, 0f, rectangle.Color, space);
 }
Пример #21
0
        public void DrawSprite(Texture2D texture, Transform origin, DVector2 offset, DVector2 size, DrawSpace drawSpace, double rotation, Vector2 pivot, Color color)
        {
            if (!mainCamera)
            {
                System.Console.WriteLine("No Camera");
                return;
            }
            Vector2 pos = ((Transform.GetRelativePos(origin, mainCamera.transform) + offset) / mainCamera.cameraSize).ToVector2();

            pos = new Vector2(pos.X * _screenSize.X, pos.Y * _screenSize.X) + _screenSize / 2;

            if (drawSpace == DrawSpace.World)
            {
                size *= _screenSize.X / mainCamera.cameraSize;
            }
            Rectangle destination = new Rectangle((int)pos.X, (int)_screenSize.Y - (int)pos.Y, (int)size.X, (int)size.Y);

            spriteBatch.Draw(texture, destination, null, color, -(float)rotation, pivot, SpriteEffects.None, 0.0f);
        }
Пример #22
0
 public static void Triangle(TriangleInfo triangle, DrawSpace space = DrawSpace.World)
 {
     Triangle(triangle.Vertex1, triangle.Vertex2, triangle.Vertex3, triangle.Color, space);
 }
Пример #23
0
        public void DrawLine(Texture2D texture, Transform origin, DVector2 position, double width, double length, double rotation, DrawSpace drawSpace, Color color)
        {
            if (!mainCamera)
            {
                System.Console.WriteLine("No Camera");
                return;
            }
            Vector2 pos = ((Transform.GetRelativePos(origin, mainCamera.transform) + position) / mainCamera.cameraSize).ToVector2();

            pos = new Vector2(pos.X * _screenSize.X, pos.Y * _screenSize.X) + _screenSize / 2;

            if (drawSpace == DrawSpace.World)
            {
                length *= _screenSize.X / mainCamera.cameraSize;
            }
            Rectangle destination = new Rectangle((int)pos.X, (int)_screenSize.Y - (int)pos.Y, (int)Math.Ceiling(length), (int)Math.Ceiling(width));

            spriteBatch.Draw(texture, destination, null, color, -(float)rotation, new Vector2(0, ((float)texture.Height) / 2f), SpriteEffects.None, 0.0f);
        }
Пример #24
0
 public static void Line(LineInfo line, DrawSpace space = DrawSpace.World)
 {
     Line(line.Start, line.End, line.StartColor, line.EndColor, space);
 }
Пример #25
0
 protected ScreenComponent(Screen screen, DrawLayer layer, DrawSpace space = DrawSpace.World)
 {
     Screen = screen;
     Layer  = layer;
     Space  = space;
 }
Пример #26
0
 public static void Sprite(Sprite sprite, Vector2 position, float size, Color color,
                           DrawSpace space = DrawSpace.World)
 {
 }
        private ITile CreateTypeOfObject(String input, Single posX, Single posY, Boolean isLongSpace)
        {

            ITile tile;
            Single smallerTileWidth = tileWidth / 4;

            switch (input)
            {
                case ".":
                    tile = new DrawDot(posX, posY, smallerTileWidth, smallerTileWidth);
                    break;
                case "_":
                    tile = new DrawHWall(posX, posY, smallerTileWidth, smallerTileWidth);
                    break;
                case " ":
                    if (isLongSpace == true)
                    {
                        tile = new DrawSpace(posX, posY, smallerTileWidth, smallerTileWidth * 3);
                    }
                    else
                    {
                        tile = new DrawSpace(posX, posY, smallerTileWidth, smallerTileWidth);
                    }
                    break;
                case "|":
                    tile = new DrawVWall(posX, posY, smallerTileWidth, smallerTileWidth * 3);
                    break;
                case "X":
                    tile = new DrawExit(posX - smallerTileWidth, posY, smallerTileWidth * 3, smallerTileWidth * 3);
                    hasExit = true;
                    break;
                case "T":
                    tile = new DrawTheseus(posX - smallerTileWidth, posY, smallerTileWidth * 3, smallerTileWidth * 3);
                    hasTheseus = true;
                    break;
                case "M":
                    tile = new DrawMinotaur(posX - smallerTileWidth, posY, smallerTileWidth * 3, smallerTileWidth * 3);
                    hasMinotaur = true;
                    break;
                default:
                    tile = new DrawDot(posX, posY, smallerTileWidth, smallerTileWidth);
                    break;
            }
            return tile;
        }