Exemplo n.º 1
0
        /*Draw Line*/
        public static void DrawLine(netDxf.Entities.Line xLine, Canvas mainCanvas)
        {
            double X1 = xLine.StartPoint.X;
            double Y1 = mainCanvas.Height - xLine.StartPoint.Y;
            double X2 = xLine.EndPoint.X;
            double Y2 = mainCanvas.Height - xLine.EndPoint.Y;

            getMaxPt(xLine.StartPoint);
            getMaxPt(xLine.EndPoint);
            System.Windows.Shapes.Line wLine = DrawUtils.GetLine(X1, Y1, X2, Y2);
            TypeConverter.Entity2Shape(xLine, wLine);
            mainCanvas.Children.Add(wLine);
        }
        public static System.Windows.Media.Brush PatternToBrush(HatchPattern myPattern, AciColor myColor)
        {
            VisualBrush vBrush = new VisualBrush();

            System.Windows.Media.Brush resBrush = vBrush;

            if (myPattern.Fill == netDxf.Entities.HatchFillType.PatternFill)
            {
                System.Windows.Shapes.Path path1 = new System.Windows.Shapes.Path();
                path1.StrokeThickness = 1;
                path1.Stroke          = AciColorToBrush(myColor);
                var it1 = new Vector2(myPattern.LineDefinitions[0].Origin.X, myPattern.LineDefinitions[0].Origin.Y);

                System.Windows.Point p0 = TypeConverter.Vertex2ToPoint(it1);
                double deltaY           = myPattern.LineDefinitions[0].Delta.Y;


                if (myPattern.Name == "LINE")
                {
                    System.Windows.Point p1 = p0;
                    System.Windows.Point p2 = new System.Windows.Point(p1.X, p1.Y + 10);
                    /*path1.Data=Geometry.Parse("M 5 0 L 5 10 Z");*/
                    path1.Data = DrawUtils.GetStreamGeoLine(p1, p2);
                }

                vBrush.TileMode = TileMode.Tile;
                vBrush.Viewport = new Rect(p0.X, p0.Y, deltaY, deltaY);

                vBrush.ViewportUnits = BrushMappingMode.Absolute;
                vBrush.Viewbox       = new Rect(p0.X, p0.Y, 10, 10);

                vBrush.ViewboxUnits = BrushMappingMode.Absolute;
                vBrush.Visual       = path1;

                vBrush.RelativeTransform = new RotateTransform(myPattern.Angle, 5, 5);

                resBrush = vBrush;
            }
            else if (myPattern.Fill == netDxf.Entities.HatchFillType.SolidFill)
            {
                if (myPattern.GetType() == typeof(HatchGradientPattern))
                {
                    resBrush = PatternSolidFillToBrush((HatchGradientPattern)myPattern, myColor);
                }
            }

            return(resBrush);
        }
Exemplo n.º 3
0
        /*Draw Mesh*/
        public static void DrawMesh(Mesh xMesh, Canvas mainCanvas)
        {
            System.Windows.Shapes.Polygon wPoly = new System.Windows.Shapes.Polygon();

            foreach (netDxf.Entities.MeshEdge xEdge in xMesh.Edges)
            {
                System.Windows.Point myPt1 = TypeConverter.Vertex3ToPoint(xMesh.Vertexes[xEdge.StartVertexIndex]);
                System.Windows.Point myPt2 = TypeConverter.Vertex3ToPoint(xMesh.Vertexes[xEdge.EndVertexIndex]);
                myPt1.Y = mainCanvas.Height - myPt1.Y;
                myPt2.Y = mainCanvas.Height - myPt2.Y;

                System.Windows.Shapes.Line wLine = DrawUtils.GetLine(myPt1.X, myPt1.Y, myPt2.X, myPt2.Y);


                TypeConverter.Entity2Shape(xMesh, wLine);

                mainCanvas.Children.Add(wLine);
            }
        }
Exemplo n.º 4
0
        /*Draw Solid*/
        public static void DrawSolid(Solid xPoly, Canvas mainCanvas)
        {
            System.Windows.Shapes.Polygon wPoly = new System.Windows.Shapes.Polygon();
            var vct2 = new Vector2(xPoly.FirstVertex.X, xPoly.FirstVertex.Y);

            wPoly.Points.Add(TypeConverter.Vertex2ToPoint(vct2, mainCanvas.Height));
            vct2 = new Vector2(xPoly.SecondVertex.X, xPoly.SecondVertex.Y);

            wPoly.Points.Add(TypeConverter.Vertex2ToPoint(vct2, mainCanvas.Height));
            vct2 = new Vector2(xPoly.FourthVertex.X, xPoly.FourthVertex.Y);

            wPoly.Points.Add(TypeConverter.Vertex2ToPoint(vct2, mainCanvas.Height));

            vct2 = new Vector2(xPoly.ThirdVertex.X, xPoly.ThirdVertex.Y);
            wPoly.Points.Add(TypeConverter.Vertex2ToPoint(vct2, mainCanvas.Height));
            /*TypeConverter.Entity2Shape(xPoly,wPoly);*/
            wPoly.Fill = DrawUtils.GetFillBrush(xPoly.Color, xPoly.Transparency.Value);
            mainCanvas.Children.Add(wPoly);
        }
Exemplo n.º 5
0
 /*Draw Underlay*/
 public static void DrawUnderlay(Underlay xUnderlay, Canvas mainCanvas)
 {
     /*DrawUtils.DrawPoint(xUnderlay.Position, mainCanvas, Colors.Red, 10, 0.5);*/
     DrawUtils.DrawText(xUnderlay.Definition.Name, 10, TypeConverter.ToMediaColor(xUnderlay.Color.ToColor()), xUnderlay.Position.X, xUnderlay.Position.Y + 20, mainCanvas);
 }
Exemplo n.º 6
0
        /*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)
            {
                Vector2 its = new Vector2(xVertex.X, xVertex.Y);
                System.Windows.Point myPt = TypeConverter.Vertex2ToPoint(its);
                myPt.Y = mainCanvas.Height - myPt.Y;
                wPoly.Points.Add(myPt);
            }
            var it = new Vector2(xLeader.Hook.X, xLeader.Hook.Y);

            System.Windows.Point myPt2 = TypeConverter.Vertex2ToPoint(it);
            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)
            {
                Vector2 it1 = new Vector2(xLeader.Vertexes[0].X, xLeader.Vertexes[0].Y);
                Vector2 it2 = new Vector2(xLeader.Vertexes[1].X, xLeader.Vertexes[1].Y);
                System.Windows.Shapes.Polygon arrow = DrawUtils.GetArrowhead(it1, it2, mainCanvas);
                TypeConverter.Entity2Shape(xLeader, arrow);
                arrow.StrokeThickness = 0.1;
                arrow.Fill            = arrow.Stroke;
                mainCanvas.Children.Add(arrow);
            }

            mainCanvas.Children.Add(wPoly);
        }
Exemplo n.º 7
0
        public Grid mainGrid     = new Grid();   //面板 grid

        public Grid GetMainGrid(netDxf.DxfDocument dxfFile, bool avecGrille, bool avecOrigine, Color bgColor)
        {
            try
            {
                mainCanvas.Children.Clear();
                DrawEntities.RazMaxDim();
                DrawEntities.AddNewMaxDim();

                ;
                //  mainGrid = new Grid();
                mainGrid.HorizontalAlignment = HorizontalAlignment.Stretch;
                mainGrid.VerticalAlignment   = VerticalAlignment.Stretch;


                Color m_Color = Color.FromArgb(255, (byte)128, (byte)128, (byte)128);
                mainGrid.Background = new SolidColorBrush(m_Color);


                border.Height = GridHeight;
                border.Width  = GridWidth;
                //

                border.Background          = new SolidColorBrush(m_Color); //UNdone::取消背景颜色
                border.HorizontalAlignment = HorizontalAlignment.Stretch;
                border.VerticalAlignment   = VerticalAlignment.Stretch;
                border.Scale = Scale;//增加比例


                mainCanvas.Name = "mainCanvas";
                if (DxfDoc.DrawingVariables.AcadVer < netDxf.Header.DxfVersion.AutoCad2000)
                {
                    DrawUtils.DrawText("Le format du fichier doit être dxf2000 ou supérieur.", 10, Colors.Red, 20, 50, mainCanvas);
                }
                GetCanvas(DxfDoc, mainCanvas);

                if (avecOrigine == true)
                {
                    DrawEntities.AddNewMaxDim();
                    DrawUtils.DrawOrigin(mainCanvas);
                    DrawEntities.DeleteLastMaxDim();
                }

                if (avecGrille == true)
                {
                    Canvas bgCanvas = new Canvas();
                    if (border.Child == null)
                    {
                        bgCanvas = CreateBgCanvas();
                        bgCanvas.Children.Add(mainCanvas);

                        border.Child = bgCanvas;
                    }
                }
                else
                {
                    border.Child = mainCanvas;
                }

                Canvas.SetTop(mainCanvas, GridHeight / 2);
                Canvas.SetLeft(mainCanvas, GridWidth / 2);

                //  Canvas.SetTop(mainCanvas, 0);
                //  Canvas.SetLeft(mainCanvas, 0);

                //border.Reset(GridHeight,GridWidth,true,ViewHeight,ViewWidth,WinHeight,WinWidth);



                if (mainGrid.Children.Count == 0)
                {
                    //bool res = mainGrid.Children.Contains(border);
                    // if(res==false)
                    mainGrid.Children.Add(border);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }


            return(mainGrid);
        }