Exemplo n.º 1
0
        public static void DrawOrigin(Canvas mainCanvas)
        {
            Vector3 V0 = new Vector3(0, 0, 0);
            Vector3 Vx = new Vector3(20, 0, 0);
            Vector3 Vy = new Vector3(0, 20, 0);

            System.Windows.Shapes.Line lx = GetLine(V0, Vx, mainCanvas);
            lx.Stroke          = new SolidColorBrush(Colors.Red);
            lx.StrokeThickness = 0.5;
            lx.X2 = lx.X2 - 3;
            mainCanvas.Children.Add(lx);
            System.Windows.Shapes.Polygon arrowX = DrawUtils.GetArrowhead(TypeConverter.Vertex3ToVertex2(Vx), TypeConverter.Vertex3ToVertex2(V0), mainCanvas);
            arrowX.Stroke          = new SolidColorBrush(Colors.Red);
            arrowX.StrokeThickness = 0.1;
            arrowX.Fill            = arrowX.Stroke;
            mainCanvas.Children.Add(arrowX);

            System.Windows.Shapes.Line ly = GetLine(V0, Vy, mainCanvas);
            ly.Stroke          = new SolidColorBrush(Colors.Green);
            ly.StrokeThickness = 0.5;
            ly.Y2 = ly.Y2 + 3;
            mainCanvas.Children.Add(ly);
            System.Windows.Shapes.Polygon arrowY = DrawUtils.GetArrowhead(TypeConverter.Vertex3ToVertex2(Vy), TypeConverter.Vertex3ToVertex2(V0), mainCanvas);
            arrowY.Stroke          = new SolidColorBrush(Colors.Green);
            arrowY.StrokeThickness = 0.1;
            arrowY.Fill            = arrowY.Stroke;
            mainCanvas.Children.Add(arrowY);
        }
        /*Draw Leader*/
        public static void DrawLeader(Leader xLeader, Canvas mainCanvas)
        {
            Size txtSize = new Size(0, 0);

            /*ajout du texte*/
            if (xLeader.Annotation.Type == EntityType.MText)
            {
                netDxf.Entities.MText mText = (netDxf.Entities.MText)xLeader.Annotation;
                txtSize = DrawMText(mText, mainCanvas);
            }

            if (xLeader.Annotation.Type == EntityType.Text)
            {
                netDxf.Entities.Text mText = (netDxf.Entities.Text)xLeader.Annotation;
                DrawText(mText, mainCanvas);
            }
            if (xLeader.Annotation.Type == EntityType.Insert)
            {
                netDxf.Entities.Insert mText = (netDxf.Entities.Insert)xLeader.Annotation;
                DrawInsert(mText, mainCanvas);
            }



            System.Windows.Shapes.Polyline wPoly = new System.Windows.Shapes.Polyline();

            foreach (netDxf.Vector2 xVertex in xLeader.Vertexes)
            {
                System.Windows.Point myPt = TypeConverter.Vertex2ToPoint(xVertex);
                myPt.Y = mainCanvas.Height - myPt.Y;
                wPoly.Points.Add(myPt);
            }
            System.Windows.Point myPt2 = TypeConverter.Vertex2ToPoint(xLeader.Hook);
            myPt2.Y = mainCanvas.Height - myPt2.Y;
            wPoly.Points.Add(myPt2);

            if (txtSize.Width > 0)
            {
                myPt2.X = myPt2.X + txtSize.Width;
                wPoly.Points.Add(myPt2);
            }

            xLeader.Lineweight = Lineweight.W0;

            TypeConverter.Entity2Shape(xLeader, wPoly);

            if (xLeader.ShowArrowhead == true)
            {
                System.Windows.Shapes.Polygon arrow = DrawUtils.GetArrowhead(xLeader.Vertexes[0], xLeader.Vertexes[1], mainCanvas);
                TypeConverter.Entity2Shape(xLeader, arrow);
                arrow.StrokeThickness = 0.1;
                arrow.Fill            = arrow.Stroke;
                mainCanvas.Children.Add(arrow);
            }

            mainCanvas.Children.Add(wPoly);
        }