コード例 #1
0
 private void Canvas_MouseDown(object sender, MouseButtonEventArgs e)
 {
     _currentState |= State.LEFTMOUSE_DOWN;
     if (_currentState.HasFlag(State.DRAWING))
     {
         _lastDownedPoint = GetDot(e.GetPosition(shapeCanvas).ToVector());
         _movingPoint     = GDot.FromCoord(e.GetPosition(shapeCanvas).ToVector());
         if (_drawingShape == null)
         {
             if (_currentState.HasFlag(State.CIRCLE))
             {
                 _drawingShape = GCircle.FromTwoDots(_lastDownedPoint, _movingPoint);
             }
             else if (_currentState.HasFlag(State.LINE))
             {
                 _drawingShape = GLine.FromTwoDots(_lastDownedPoint, _movingPoint);
             }
             else if (_currentState.HasFlag(State.DOT))
             {
                 _drawingShape = _lastDownedPoint;
             }
             _drawingShape.Control.Stroke = Brushes.Blue;
             shapeCanvas.Children.Add(_drawingShape.Control);
         }
     }
 }
コード例 #2
0
        public void CircleCircle()
        {
            GCircle c1 = new GCircle(new PointF(5, 5), 10);
            GCircle c2 = new GCircle(new PointF(0, 0), 20);

            c1.IntersectWith(c2);
            var ss = c1.IntersectionResults;

            Assert.IsTrue(c1.IntersectionResults.Count > 0);
        }
コード例 #3
0
        private void Btn_DrawLine_Click(object sender, RoutedEventArgs e)
        {
            // GeometryEngine.Remove("Supports");

            // var traingle = new GTriangle(GeometryEngine.GCanvas, new Point(60, 60), 20);
            l                      = new GLine(GeometryEngine.GCanvas, new Point(60, 60), new Point(100, 200));
            c                      = new GCircle(GeometryEngine.GCanvas, new Point(200, 200), 50);
            c.Fill                 = Brushes.Green;
            hinged                 = new Hinged(GeometryEngine.GCanvas, new Point(500, 500));
            hinged.Fill            = Brushes.Transparent;
            hinged.Stroke          = Brushes.Red;
            hinged.StrokeThickness = 2;
            roller                 = new Roller(GeometryEngine.GCanvas, new Point(160, 60));
            roller.Fill            = Brushes.Transparent;
            roller.StrokeThickness = 2;
            //var rectangle = new GRectangle(GeometryEngine.GCanvas, 30, 15, new Point(140, 60+15));
            fixd                      = new Fixed(GeometryEngine.GCanvas, new Point(100, 60), 20);
            fixd.Fill                 = Brushes.Orange;
            fixd.StrokeThickness      = 2;
            arrow                     = new Arrow(GeometryEngine.GCanvas, new Point(220, 60), 20);
            arrow.Stroke              = Brushes.Yellow;
            arrow.StrokeThickness     = 4;
            arrowLoad                 = new ArrowLoad(GeometryEngine.GCanvas, new Point(100, 120), new Point(200, 120), 20);
            arrowLoad.Stroke          = Brushes.Blue;
            arrowLoad.StrokeThickness = 2;

            gText      = new GText(GeometryEngine.GCanvas, new Point(500, 500), "Hello Text!");
            gText.Text = "Hello Text!";

            gText.Render();


            //arrow.Rotate(45);
            //render on Screen
            //GeometryEngine.RenderAll();
            //   GeometryEngine.Render(new List<GShape>() { roller, hinged, fixd });
            GeometryEngine.Shapes["Beams"].Add(c);
            GeometryEngine.Shapes["Beams"].Add(arrow);
            GeometryEngine.Shapes["Supports"].Add(arrowLoad);

            GeometryEngine.Shapes["Supports"].Add(roller);
            GeometryEngine.Shapes["Supports"].Add(fixd);
            GeometryEngine.Shapes["Supports"].Add(l);
            GeometryEngine.Shapes["Supports"].Add(hinged);
            //  GeometryEngine.Shapes["Supports"].Add(gText);
            // GeometryEngine.Render("Beams");
            // GeometryEngine.Render("Supports");
            l.Stroke          = Brushes.Red;
            l.StrokeThickness = 4;

            GeometryEngine.RenderAll();
        }
コード例 #4
0
ファイル: Polynomial.cs プロジェクト: AmrFayez/SimpleEditor
        public static Polynomial FromCircle(GCircle circle)
        {
            var   c  = circle.Center;
            float r  = circle.Radius;
            var   p1 = new PointF(c.X + r, c.Y);
            var   p2 = new PointF(-(c.X + r), c.Y);
            var   p3 = new PointF(c.X + r, c.Y + r);

            return(new Polynomial(new List <PointF>()
            {
                p1, p2, p3
            }));
        }