コード例 #1
0
        /*Draw Solid*/
        public static void DrawSolid(Solid xPoly, Canvas mainCanvas)
        {
            System.Windows.Shapes.Polygon wPoly = new System.Windows.Shapes.Polygon();

            wPoly.Points.Add(TypeConverter.Vertex2ToPoint(xPoly.FirstVertex, mainCanvas.Height));
            wPoly.Points.Add(TypeConverter.Vertex2ToPoint(xPoly.SecondVertex, mainCanvas.Height));
            wPoly.Points.Add(TypeConverter.Vertex2ToPoint(xPoly.FourthVertex, mainCanvas.Height));
            wPoly.Points.Add(TypeConverter.Vertex2ToPoint(xPoly.ThirdVertex, mainCanvas.Height));
            /*TypeConverter.Entity2Shape(xPoly,wPoly);*/
            wPoly.Fill = DrawUtils.GetFillBrush(xPoly.getColor(), xPoly.Transparency.Value);
            mainCanvas.Children.Add(wPoly);
        }
コード例 #2
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);
        }
コード例 #3
0
        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);

                System.Windows.Point p0 = TypeConverter.Vertex2ToPoint(myPattern.LineDefinitions[0].Origin);
                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);
        }
コード例 #4
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);
            }
        }
コード例 #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.FileName, 10, TypeConverter.ToMediaColor(xUnderlay.getColor().ToColor()), xUnderlay.Position.X, xUnderlay.Position.Y + 20, mainCanvas);
 }