Esempio n. 1
0
        internal void AddPatternXData()
        {
            if (this.XData.ContainsKey(ApplicationRegistry.Default.Name))
            {
                XData xdataEntry = this.XData[ApplicationRegistry.Default.Name];
                xdataEntry.XDataRecord.Clear();
                xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.RealX, this.Pattern.Origin.X));
                xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.RealY, this.Pattern.Origin.Y));
                xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.RealZ, 0.0));
            }
            else
            {
                XData xdataEntry = new XData(new ApplicationRegistry(ApplicationRegistry.Default.Name));
                xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.RealX, this.Pattern.Origin.X));
                xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.RealY, this.Pattern.Origin.Y));
                xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.RealZ, 0.0));
                this.XData.Add(xdataEntry.ApplicationRegistry.Name, xdataEntry);
            }

            if (!(this.Pattern is HatchGradientPattern))
            {
                return;
            }

            HatchGradientPattern grad = (HatchGradientPattern)this.Pattern;

            if (this.XData.ContainsKey("GradientColor1ACI"))
            {
                XData       xdataEntry = this.XData["GradientColor1ACI"];
                XDataRecord record     = new XDataRecord(XDataCode.Int16, grad.Color1.Index);
                xdataEntry.XDataRecord.Clear();
                xdataEntry.XDataRecord.Add(record);
            }
            else
            {
                XData xdataEntry = new XData(new ApplicationRegistry("GradientColor1ACI"));
                xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, grad.Color1.Index));
                this.XData.Add(xdataEntry.ApplicationRegistry.Name, xdataEntry);
            }

            if (this.XData.ContainsKey("GradientColor2ACI"))
            {
                XData       xdataEntry = this.XData["GradientColor2ACI"];
                XDataRecord record     = new XDataRecord(XDataCode.Int16, grad.Color2.Index);
                xdataEntry.XDataRecord.Clear();
                xdataEntry.XDataRecord.Add(record);
            }
            else
            {
                XData xdataEntry = new XData(new ApplicationRegistry("GradientColor2ACI"));
                xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, grad.Color2.Index));
                this.XData.Add(xdataEntry.ApplicationRegistry.Name, xdataEntry);
            }
        }
Esempio n. 2
0
        public override object Clone()
        {
            HatchGradientPattern copy = new HatchGradientPattern {
                // Pattern
                Fill   = this.Fill,
                Type   = this.Type,
                Origin = this.Origin,
                Angle  = this.Angle,
                Scale  = this.Scale,
                Style  = this.Style,
                // GraientPattern
                GradientType = this.gradientType,
                Color1       = (AciColor)this.color1.Clone(),
                Color2       = (AciColor)this.color2.Clone(),
                SingleColor  = this.singleColor,
                Tint         = this.tint,
                Centered     = this.centered
            };

            return(copy);
        }
Esempio n. 3
0
        public override object Clone()
        {
            HatchGradientPattern copy = new HatchGradientPattern
            {
                // Pattern
                Fill   = Fill,
                Type   = Type,
                Origin = Origin,
                Angle  = Angle,
                Scale  = Scale,
                Style  = Style,
                // GraientPattern
                GradientType = gradientType,
                Color1       = (AciColor)color1.Clone(),
                Color2       = (AciColor)color2.Clone(),
                SingleColor  = singleColor,
                Tint         = tint,
                Centered     = centered
            };

            return(copy);
        }
 private void WriteGradientHatchPattern(HatchGradientPattern pattern)
 {
     // again the order of codes shown in the documentation will not work
     this.chunk.Write(450, 1);
     this.chunk.Write(451, 0);
     this.chunk.Write(460, pattern.Angle*MathHelper.DegToRad);
     this.chunk.Write(461, pattern.Centered ? 0.0 : 1.0);
     this.chunk.Write(452, pattern.SingleColor ? 1 : 0);
     this.chunk.Write(462, pattern.Tint);
     this.chunk.Write(453, 2);
     this.chunk.Write(463, 0.0);
     this.chunk.Write(63, pattern.Color1.Index);
     this.chunk.Write(421, AciColor.ToTrueColor(pattern.Color1));
     this.chunk.Write(463, 1.0);
     this.chunk.Write(63, pattern.Color2.Index);
     this.chunk.Write(421, AciColor.ToTrueColor(pattern.Color2));
     this.chunk.Write(470, StringEnum.GetStringValue(pattern.GradientType));
 }
Esempio n. 5
0
        public override object Clone()
        {
            HatchGradientPattern copy = new HatchGradientPattern
            {
                // Pattern
                Fill = this.Fill,
                Type = this.Type,
                Origin = this.Origin,
                Angle = this.Angle,
                Scale = this.Scale,
                Style = this.Style,
                // GraientPattern
                GradientType = this.gradientType,
                Color1 = (AciColor) this.color1.Clone(),
                Color2 = (AciColor) this.color2.Clone(),
                SingleColor = this.singleColor,
                Tint = this.tint,
                Centered = this.centered
            };

            return copy;
        }
Esempio n. 6
0
        private static void HatchTest4()
        {
            DxfDocument dxf = new DxfDocument(DxfVersion.AutoCad2010);

            LwPolyline poly = new LwPolyline();
            poly.Vertexes.Add(new LwPolylineVertex(-10, -10));
            poly.Vertexes.Add(new LwPolylineVertex(10, -10));
            poly.Vertexes.Add(new LwPolylineVertex(10, 10));
            poly.Vertexes.Add(new LwPolylineVertex(-10, 10));
            poly.IsClosed = true;

            List<HatchBoundaryPath> boundary = new List<HatchBoundaryPath>() { new HatchBoundaryPath(new List<EntityObject>()) }; ;
            //List<HatchBoundaryPath> boundary = new List<HatchBoundaryPath> {new HatchBoundaryPath(new List<Entity> {poly})};
            HatchGradientPattern pattern = new HatchGradientPattern(AciColor.Yellow, AciColor.Blue, HatchGradientPatternType.Linear);
            pattern.Origin = new Vector2(120, -365);
            Hatch hatch = new Hatch(pattern, boundary, true);
            dxf.AddEntity(hatch);
            dxf.AddEntity(hatch.CreateBoundary(true));
            
            dxf.Save("HatchTest4.dxf");
            dxf = DxfDocument.Load("HatchTest4.dxf");
            dxf.Save("HatchTest4 copy.dxf");

        }
Esempio n. 7
0
        private static void WriteGradientPattern()
        {
            List<LwPolylineVertex> vertexes = new List<LwPolylineVertex>
                                            {
                                                new LwPolylineVertex(new Vector2(0, 0)),
                                                new LwPolylineVertex(new Vector2(0, 150)),
                                                new LwPolylineVertex(new Vector2(150, 150)),
                                                new LwPolylineVertex(new Vector2(150, 0))
                                            };
            LwPolyline pol = new LwPolyline(vertexes, true);


            Line line1 = new Line(new Vector2(0, 0), new Vector2(0, 150));
            Line line2 = new Line(new Vector2(0, 150), new Vector2(150, 150));
            Line line3 = new Line(new Vector2(150, 150), new Vector2(150, 0));
            Line line4 = new Line(new Vector2(150, 0), new Vector2(0, 0));

            AciColor color = new AciColor(63, 79, 127);
            HatchGradientPattern gradient = new HatchGradientPattern(color, AciColor.Blue, HatchGradientPatternType.Linear);
            //HatchGradientPattern gradient = new HatchGradientPattern(AciColor.Red, 0.75, HatchGradientPatternType.Linear);
            gradient.Angle = 30;

            List<HatchBoundaryPath> boundary = new List<HatchBoundaryPath>
                                                    {
                                                        new HatchBoundaryPath(new List<EntityObject> {pol})
                                                    };
            Hatch hatch = new Hatch(gradient, boundary, true);
            
            // gradients are only supported for AutoCad2004 and later
            DxfDocument dxf = new DxfDocument(DxfVersion.AutoCad2004);
            dxf.AddEntity(hatch);
            dxf.Save("gradient test.dxf");

            //DxfDocument dxf2 = DxfDocument.Load("gradient test.dxf");

            //dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2000;

            //dxf.Save("gradient test 2000.dxf");

        }