Ejemplo n.º 1
0
        public GPolygon(GCanvas gCanvas, PointCollection points, [Optional] Point Position, [Optional] Point origin) : base(gCanvas)
        {
            ///Set shape properties
            Shape         = Polygon = new Polygon();
            Points        = points;
            this.Position = Position;

            if (origin == default(Point))
            {
                // origin = Points.FirstOrDefault();
            }
            else
            {
                Origin = origin;
            }
            //Set polygon Properties
            if (Position != default(Point))
            {
                var left = Position.X - Origin.X;
                var top  = Position.Y - Origin.Y;
                Polygon.Margin = new Thickness(left, top, 0, 0);
            }

            Polygon.HorizontalAlignment = HorizontalAlignment.Left;
            Polygon.VerticalAlignment   = VerticalAlignment.Center;
        }
Ejemplo n.º 2
0
        public GeometryEngine()
        {
            Shapes = new Dictionary <string, List <GShape> >()
            {
                { "Points", new List <GShape>() },
                { "Lines", new List <GShape>() },
            };

            GCanvas = new GCanvas();
        }
Ejemplo n.º 3
0
 public GShape(GCanvas gCanvas)
 {
     GCanvas         = gCanvas;
     Thickness       = new Thickness(101, -11, 362, 250);
     Visibility      = Visibility.Visible;
     Stroke          = Brushes.Black;
     StrokeThickness = 1;
     Fill            = Brushes.Red;
     //
     Id = GeometryEngine.Id;
     GeometryEngine.Id++;
 }
Ejemplo n.º 4
0
 public GText(GCanvas gCanvas, Point insertionPoint, double size, string text) : base(gCanvas)
 {
     TextBlock = new TextBlock();
     Text      = text;
     Size      = size; //default size  =5
     // defaults;
     Size                      = 5;
     ForegroundColor           = Brushes.Black;
     InsertionPoint            = insertionPoint;
     BackgroundColor           = Brushes.Transparent;
     TextBlock.RenderTransform = new TransformGroup();
     TextBlock.FontWeight      = FontWeights.Normal;
 }
Ejemplo n.º 5
0
 public GLine(GCanvas gCanvas, Point2D startPoint, Point2D endPoint) : base(gCanvas)
 {
     this.startPoint = startPoint;
     this.endPoint   = endPoint;
     Shape           = Line = new Line();
     Line.X1         = StartPoint.X /*Scale*/;
     Line.Y1         = StartPoint.Y;
     //
     Line.X2 = EndPoint.X /*Scale*/;
     Line.Y2 = EndPoint.Y;
     //Add this Shape to Canvas
     Line.RenderTransform = new TransformGroup();
 }
Ejemplo n.º 6
0
 public GTriangle(GCanvas gCanvas, Point top, double sideLength) : base(gCanvas)
 {
     Top        = top;
     SideLength = sideLength * Scale;
     Right      = new Point(top.X + SideLength, top.Y + SideLength);
     Left       = new Point(top.X - SideLength, top.Y + SideLength);
     if (Points == null)
     {
         Points = new PointCollection();
     }
     //add point to the polygon Points Collection
     Points.Add(Top);
     Points.Add(Right);
     Points.Add(Left);
 }
Ejemplo n.º 7
0
        public GCircle(GCanvas gCanvas, Point position, double radius) : base(gCanvas)
        {
            //set shape
            Shape = Circle = new Ellipse();
            //set shape specific property
            Position = position;
            Radius   = radius * Scale;
            //
            Circle.Height = Radius;
            Circle.Width  = Radius;
            var left = Position.X - (Radius / 2);
            var top  = Position.Y - (Radius / 2);

            Circle.Margin          = new Thickness(left, top, 0, 0);
            Fill                   = Brushes.Transparent;
            Circle.RenderTransform = new TransformGroup();
        }
Ejemplo n.º 8
0
        public GRectangle(GCanvas gCanvas, double width, double height, Point position) : base(gCanvas)
        {
            Width    = width;
            Height   = height;
            Position = position;
            //
            Shape             = Rectangle = new Rectangle();
            Rectangle.Width   = Width;
            Rectangle.Height  = Height;
            Rectangle.RadiusX = RadiusX;
            Rectangle.RadiusY = RadiusY;

            var left = Position.X - (Width / 2);
            var top  = Position.Y - (Height / 2);

            Rectangle.Margin = new Thickness(left, top, 0, 0);
            Fill             = Brushes.Transparent;
            //Add this Shape to Canvas
        }
Ejemplo n.º 9
0
        public Arrow(GCanvas gCanvas, Point2D insertionPoint, double length) : base(gCanvas)
        {
            GCanvas        = gCanvas;
            InsertionPoint = insertionPoint;
            Length         = length;
            HeadHeight     = 5;
            var body = new GLine(GCanvas, InsertionPoint, new Point2D(InsertionPoint.X, InsertionPoint.Y + Length));

            var headRightLine = new GLine(GCanvas, InsertionPoint, new Point2D(InsertionPoint.X + HeadHeight, InsertionPoint.Y + HeadHeight));
            var headLeftLine  = new GLine(GCanvas, InsertionPoint, new Point2D(InsertionPoint.X - HeadHeight, InsertionPoint.Y + HeadHeight));

            Lines = new List <GLine>()
            {
                body,
                headRightLine,
                headLeftLine
            };

            foreach (var line in Lines)
            {
                line.Line.RenderTransform = new TransformGroup();
            }
        }
Ejemplo n.º 10
0
 public GText(GCanvas gCanvas, Point insertionPoint, string text) : this(gCanvas, insertionPoint, 5, text)
 {
 }
Ejemplo n.º 11
0
 public GPolygon(GCanvas gCanvas) : this(gCanvas, new PointCollection(), default(Point), default(Point))
 {
 }