Example #1
0
        /// <summary>
        /// save image to bmp or to wmf.
        /// </summary>
        /// <param name="usedFname">path to file (full). Should end with .bmp or .wmf</param>
        /// <param name="in_structToUse"> structure to render. If you rendering bmp then pass null </param>
        internal void saveGraphicalDataToFile(string usedFname, DXFRendering.LOGICAL.completeDxfStruct in_structToUse)
        {
            System.IO.FileInfo usedFnameInfo = new System.IO.FileInfo(usedFname);
            string             usedFExt      = usedFnameInfo.Extension.ToLower();

            switch (usedFExt)
            {
            case (".bmp"):     {
                this.bitmapRender.Save(usedFname);
                break;
            }

            case (".wmf"):     {
                //prepare scale factor
                //this.currentscalefactor
                if (in_structToUse != null)
                {
                    DXFRenderingBitmap.WMF.ExportDXFtoWMF.exportCompleteDrawingStructToWMF(usedFname, this.currentscalefactor, in_structToUse);
                }
                break;
            }

            default:
                break;
            }
        }
        private void handleFile(String in_PathToDXF)
        {
            try
            {
                //retrieve the logical structure of dxf file
                DXFRendering.LOGICAL.completeDxfStruct obtainedStruct = DXFRendering.LOGICAL.DxfReadWrapper.processDxfFile(in_PathToDXF);
                DXFRendering.LOGICAL.MyDxfBoundingBox  boundStruct    = obtainedStruct.GetBoundingBox();
                //all these things are fine, but they are done in user control for drawing
                //get the graphical structure of file, prepared for display, with scale one-by-one (we apply scale factor later)
                //render the structure to bitmap using scale
                //rotate the bitmap (= not used in this edition) and render it to another bitmap which will be displayed every time we redraw control
                userControlForPaint1.setupCollectionOfLayerDefinitions();
                keptDxfStruct = obtainedStruct;
                userControlForPaint1.prepareGraphicalDataStruct(obtainedStruct);
                //calculate
                double wdxf = Math.Abs(obtainedStruct.GetBoundingBox().XLowerLeft - obtainedStruct.GetBoundingBox().XUpperRight);
                double hdxf = Math.Abs(obtainedStruct.GetBoundingBox().YLowerLeft - obtainedStruct.GetBoundingBox().YUpperRight);
                double wimg = userControlForPaint1.Width;
                double himg = userControlForPaint1.Height;
                double scalew = wimg / wdxf; double scaleh = himg / hdxf;
                double scaleCurrent = Math.Min(scalew, scaleh);
                userControlForPaint1.currentscalefactor = scaleCurrent;

                userControlForPaint1.drawImageToBitmapUsingCurrentScaleFactor();
                this.userControlForPaint1.Refresh();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Example #3
0
        private void ListBoxDxfFiles_SelectedValueChanged(object sender, EventArgs e)
        {
            DXFRendering.LOGICAL.singleDXFListBoxItem value = (DXFRendering.LOGICAL.singleDXFListBoxItem) this.listBoxDxfFiles.SelectedItem;
            //retrieve the logical structure of dxf file
            DXFRendering.LOGICAL.completeDxfStruct obtainedStruct = DXFRendering.LOGICAL.DxfReadWrapper.processDxfFile(value.fullPath);
            //transform it to initial graphical structure used during rendering
            this.userControlForPaint1.VerticalScroll.Value   = 0;
            this.userControlForPaint1.HorizontalScroll.Value = 0;
            this.userControlForPaint1.setupLogicalAndGraphicalDXFstructures(obtainedStruct);
            this.userControlForPaint1.prepareActualGraphicalDXFStructure();
            //invoke transformations on graphical structure (later, when needed)
            // MEOW!
            //redraw?
            this.userControlForPaint1.Refresh();

            //crutch to position drawing thing properly
            //this.userControlForPaint1.UserControlForPaint_Resize(null, null);
            //crutch to remove stray scrollbars
            this.userControlForPaint1.PerformLayout();
        }
Example #4
0
        //step 0. get the file structure from dxf and gradually turn it into drawing struct
        public void prepareGraphicalDataStruct(DXFRendering.LOGICAL.completeDxfStruct in_structFromFile)
        {
            unscaledGraphicalData = new DXFRendering.GRAPHICAL.CompleteDxfDrawingStruct();
            int lngthOfStruct = in_structFromFile.getSize();

            for (int i = 0; i < lngthOfStruct; i++)   //read and convert entries from supplied struct to display struct with data ready to display
            {
                DXFRendering.LOGICAL.DXFdrawingEntry someEntry = in_structFromFile.getItemByIndex(i);
                Pen usedPen = null;
                if ((collectionOfLayerDefinitions != null) && (collectionOfLayerDefinitions.ContainsKey(someEntry.layerIdentifier)))
                {
                    usedPen = collectionOfLayerDefinitions[someEntry.layerIdentifier].Item2;
                }
                else
                {
                    usedPen = new Pen(Color.Black);
                }
                DXFRendering.LOGICAL.MyDxfBoundingBox     tmpboundbox = someEntry.GetBoundingBox();
                DXFRendering.GRAPHICAL.DXFentryForDisplay tmpEntry2   = null;
                if (someEntry is DXFRendering.LOGICAL.MyDxfLine)
                {
                    tmpEntry2 = new DXFRendering.GRAPHICAL.MyDxfLineForDisplay(
                        (someEntry as DXFRendering.LOGICAL.MyDxfLine).XStart,
                        (someEntry as DXFRendering.LOGICAL.MyDxfLine).YStart,
                        (someEntry as DXFRendering.LOGICAL.MyDxfLine).XEnd,
                        (someEntry as DXFRendering.LOGICAL.MyDxfLine).YEnd, usedPen);
                }
                else if (someEntry is DXFRendering.LOGICAL.MyDxfArc)
                {
                    DXFRendering.LOGICAL.MyDxfArc castArc = someEntry as DXFRendering.LOGICAL.MyDxfArc;
                    tmpEntry2 = new DXFRendering.GRAPHICAL.MyDxfArcForDisplay(castArc.XCenter, castArc.YCenter, castArc.Radius, castArc.StartAngleDegree, castArc.EndAngleDegree, usedPen);
                }
                // distilled it
                this.unscaledGraphicalData.addSingleEntry(tmpEntry2, tmpboundbox.XLowerLeft, tmpboundbox.YLowerLeft, tmpboundbox.XUpperRight, tmpboundbox.YUpperRight);
            }
        }