Пример #1
0
        public bool Splitting(IntPtr Handle, string FileName)
        {
            MetaForm.vDXF         = new DXFExport();
            MetaForm.Data         = new DXFData();
            MetaForm.vDXF.fOffset = 50f;
            float[] singleArray = new float[] { 5f, default(float) };
            MetaForm.vDXF.AddLType("_SOLID", singleArray);
            MetaForm.vDXF.AddLType("_DASH", new float[] { 5f, -2f });
            MetaForm.vDXF.AddLType("_DOT", new float[] { 2f, -2f });
            MetaForm.vDXF.AddLType("_DASHDOT", new float[] { 5f, -2f, 2f, -2f });
            MetaForm.vDXF.AddLType("_DASHDOTDOT", new float[] { 5f, -2f, 2f, -2f, 2f, -2f });
            MetaForm.Data = new DXFData()
            {
                height   = 50f,
                rotation = 0f
            };
            MetaForm.Data.point.X = 57f;
            MetaForm.Data.point.Y = 0f;
            MetaForm.Data.color   = 1;
            MetaForm.Data.text    = "Trial version";
            MetaForm.vDXF.AddText(MetaForm.Data);
            Graphics graphic  = Graphics.FromHwnd(Handle);
            Graphics graphic1 = graphic;

            using (graphic)
            {
                graphic1.EnumerateMetafile(this.mf, new Point(0, 0), new Rectangle(0, 0, this.mf.Width, this.mf.Height),
                                           GraphicsUnit.Pixel, new Graphics.EnumerateMetafileProc(MetaForm.DelFunc));
            }
            graphic1.Dispose();
            MetaForm.vDXF.SaveToFile(FileName);
            return(true);
        }
Пример #2
0
        protected override bool ReadProperty(Property prop)
        {
            switch (prop.Code)
            {
            case 100: C100 = prop.Value; break;

            case 90: C90 = prop.Value.ToInt(); break;

            case 70: C70 = prop.Value.ToInt(); break;

            case 43: C43 = prop.Value; break;

            case 38: C38 = prop.Value.ToDouble(); break;

            case 39: C39 = prop.Value.ToDouble(); break;

            //case 91: C91 = prop.Value; break;
            case 10:
                P2D.Add(new P2D()
                {
                    X = prop.Value.ToDouble(),
                    Y = DXFData.Next().Value.ToDouble(),
                });
                break;

            default:
                return(base.ReadProperty(prop));
            }
            return(false);
        }
Пример #3
0
        private void method_0(IPointCollection ipointCollection_0, DXFExport dxfexport_0)
        {
            DXFData  dXFDatum = new DXFData();
            DXFPoint dXFPoint = new DXFPoint();

            dXFDatum.points.Add(new ArrayList());
            dXFDatum.count = ipointCollection_0.PointCount;
            for (int i = 0; i < ipointCollection_0.PointCount; i++)
            {
                IPoint point = ipointCollection_0.Point[i];
                ((ArrayList)dXFDatum.points[0]).Add(new DXFPoint((float)point.X, (float)point.Y, 0f));
            }
            dxfexport_0.AddPolyLine(dXFDatum, 0);
        }
Пример #4
0
        protected override Property ReadSonClass(Property prop)
        {
            switch (prop.Value)
            {
            case "TABLE":
                TABLE entity = new TABLE(DXFData, prop);
                TABLEList.Add(entity);
                return(entity.ReadProperties());

            case "ENDTAB":
                return(DXFData.Next());

            default:
                return(base.ReadSonClass(prop));
            }
        }
Пример #5
0
 protected override Property ReadSonClass(Property prop)
 {
     //是属性,那么特别待遇了
     if (prop.Value.Length > 0 && prop.Value[0] == '{')
     {
         ACAD_XDICTIONARY hv = new ACAD_XDICTIONARY(DXFData, prop);
         Sons.Add(hv);
         var lastProp = hv.ReadProperties();
         return(lastProp);
     }
     else if (prop.Code == 102 && prop.Value == "}")
     {
         return(DXFData.Next());
     }
     else
     {
         return(base.ReadSonClass(prop));
     }
 }
Пример #6
0
        private void method_1(IFeatureClass ifeatureClass_0, DXFExport dxfexport_0)
        {
            DXFData dXFDatum;
            int     j;
            IPoint  point;

            dxfexport_0.CurrentLayer = new DXFLayer(ifeatureClass_0.AliasName);
            IFeatureCursor featureCursor = ifeatureClass_0.Search(null, false);

            for (IFeature i = featureCursor.NextFeature(); i != null; i = featureCursor.NextFeature())
            {
                if (this.ifeatureProgress_StepEventHandler_0 != null)
                {
                    this.ifeatureProgress_StepEventHandler_0();
                }
                if (ifeatureClass_0.FeatureType == esriFeatureType.esriFTAnnotation)
                {
                    ITextElement annotation = (i as IAnnotationFeature2).Annotation as ITextElement;
                    if (annotation != null)
                    {
                        double xMin = ((annotation as IElement).Geometry.Envelope.XMin +
                                       (annotation as IElement).Geometry.Envelope.XMax) / 2;
                        double yMin = ((annotation as IElement).Geometry.Envelope.YMin +
                                       (annotation as IElement).Geometry.Envelope.YMax) / 2;
                        dXFDatum = new DXFData();
                        dXFDatum.Clear();
                        dXFDatum.color    = annotation.Symbol.Color.RGB;
                        dXFDatum.height   = (float)(annotation as IElement).Geometry.Envelope.Height;
                        dXFDatum.rotation = (float)annotation.Symbol.Angle;
                        dXFDatum.text     = annotation.Text;
                        dXFDatum.point.X  = (float)xMin;
                        dXFDatum.point.Y  = (float)yMin;
                        dxfexport_0.AddText(dXFDatum);
                    }
                }
                else if (
                    !(ifeatureClass_0.ShapeType == esriGeometryType.esriGeometryPolyline
                        ? false
                        : ifeatureClass_0.ShapeType != esriGeometryType.esriGeometryPolygon))
                {
                    IGeometryCollection shape = i.Shape as IGeometryCollection;
                    if (shape != null)
                    {
                        if (shape.GeometryCount <= 1)
                        {
                            this.method_0(shape as IPointCollection, dxfexport_0);
                        }
                        else
                        {
                            for (j = 0; j < shape.GeometryCount; j++)
                            {
                                this.method_0(shape.Geometry[j] as IPointCollection, dxfexport_0);
                            }
                        }
                    }
                }
                else if (ifeatureClass_0.ShapeType != esriGeometryType.esriGeometryPoint)
                {
                    IPointCollection pointCollection = i.Shape as IPointCollection;
                    if (pointCollection != null)
                    {
                        for (j = 0; j < pointCollection.PointCount; j++)
                        {
                            point    = pointCollection.Point[j];
                            dXFDatum = new DXFData();
                            dXFDatum.Clear();
                            dXFDatum.point.X = (float)point.X;
                            dXFDatum.point.Y = (float)point.Y;
                            dxfexport_0.AddPixel(dXFDatum);
                        }
                    }
                }
                else
                {
                    point = i.Shape as IPoint;
                    if (point != null)
                    {
                        dXFDatum = new DXFData();
                        dXFDatum.Clear();
                        dXFDatum.point.X = (float)point.X;
                        dXFDatum.point.Y = (float)point.Y;
                        dxfexport_0.AddPixel(dXFDatum);
                    }
                }
            }
            ComReleaser.ReleaseCOMObject(featureCursor);
        }
Пример #7
0
 public DXFText(DXFData aData) : base(aData)
 {
 }
Пример #8
0
 public DXFSolid(DXFData aData) : base(aData)
 {
 }
Пример #9
0
 public DXFPixel(DXFData aData) : base(aData)
 {
 }
Пример #10
0
        public static bool Splitting(string pfName, IntPtr Handle, bool DelMeta)
        {
            bool flag;

            MetaForm.tmpName = pfName.Replace(".emf", ".tmp");
            if (File.Exists(MetaForm.tmpName))
            {
                File.Delete(MetaForm.tmpName);
            }
            if (File.Exists(MetaForm.tmpName.Replace(".tmp", "~.tmp")))
            {
                File.Delete(MetaForm.tmpName.Replace(".tmp", "~.tmp"));
            }
            try
            {
                MetaForm.mfImage = new Metafile(pfName);
                goto Label0;
            }
            catch
            {
                MessageBox.Show("Error in .emf file");
                flag = false;
            }
            return(flag);

Label0:
            MetaForm.vDXF         = new DXFExport();
            MetaForm.Data         = new DXFData();
            MetaForm.vDXF.fOffset = 50f;
            float[] singleArray = new float[] { 5f, default(float) };
            MetaForm.vDXF.AddLType("_SOLID", singleArray);
            MetaForm.vDXF.AddLType("_DASH", new float[] { 5f, -2f });
            MetaForm.vDXF.AddLType("_DOT", new float[] { 2f, -2f });
            MetaForm.vDXF.AddLType("_DASHDOT", new float[] { 5f, -2f, 2f, -2f });
            MetaForm.vDXF.AddLType("_DASHDOTDOT", new float[] { 5f, -2f, 2f, -2f, 2f, -2f });
            MetaForm.Data = new DXFData()
            {
                height   = 50f,
                rotation = 0f
            };
            MetaForm.Data.point.X = 57f;
            MetaForm.Data.point.Y = 0f;
            MetaForm.Data.color   = 1;
            MetaForm.Data.text    = "Trial version";
            MetaForm.vDXF.AddText(MetaForm.Data);
            Graphics graphic  = Graphics.FromHwnd(Handle);
            Graphics graphic1 = graphic;

            using (graphic)
            {
                graphic1.EnumerateMetafile(MetaForm.mfImage, new Point(0, 0),
                                           new Rectangle(0, 0, MetaForm.mfImage.Width, MetaForm.mfImage.Height), GraphicsUnit.Pixel,
                                           new Graphics.EnumerateMetafileProc(MetaForm.DelFunc));
            }
            graphic1.Dispose();
            MetaForm.mfImage.Dispose();
            MetaForm.tmpName = pfName.Replace(".emf", ".dxf");
            MetaForm.vDXF.SaveToFile(MetaForm.tmpName);
            if (DelMeta)
            {
                File.Delete(pfName);
            }
            return(true);
        }