Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            // Displays an OpenFileDialog so the user can select a Cursor.
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter = "Dxf Files|*.dxf";
            openFileDialog1.Title  = "Select Dxf File";
            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                // get here a path to dxf file
                string obtainedFileName = openFileDialog1.FileName;
                textBox1.Text = obtainedFileName;
                //unroll wrapper for reading
                DxfReadWrapper DxfReadWrapperInstance = new DxfReadWrapper();
                //prepare struct for obtaining data
                completeDxfStruct structToObtain = DxfReadWrapperInstance.processDxfFile(obtainedFileName);
                userControlForPaint1.structToRender = structToObtain;

                /*
                 * toolStripStatusLabel2.Text = myDxfControl1.horizontalDimensionDxf.ToString();
                 * toolStripStatusLabel4.Text = myDxfControl1.verticalDimensionDxf.ToString();
                 * toolStripStatusLabel6.Text = myDxfControl1.getCurrentTransformationAngle().ToString();
                 */
                userControlForPaint1.recalculateScaleToFitAll();
                userControlForPaint1.Refresh();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Setup only INITIAL logical and graphical datastructures.
        /// </summary>
        /// <param name="in_savedStructureOfDxf">Logical structure of DXF as read from file</param>
        public void setupLogicalAndGraphicalDXFstructures(LOGICAL.completeDxfStruct in_savedStructureOfDxf)
        {
            savedStructureOfDxf = in_savedStructureOfDxf;
            //generate primal drawing structure
            MyDxfBoundingBox obtainedBox2 = savedStructureOfDxf.GetBoundingBox();

            if (obtainedBox2.XLowerLeft != 0)
            {
                offsetOfDxfHorizontal = 0 - obtainedBox2.XLowerLeft;
            }
            if (obtainedBox2.YLowerLeft != 0)
            {
                offsetOfDxfVertical = 0 - obtainedBox2.YLowerLeft;
            }
            primalDrawingStructure = new CompleteDxfDrawingStruct(null);
            int currentSizeOfDxfStruct = savedStructureOfDxf.getSize();

            for (int i = 0; i < currentSizeOfDxfStruct; i++)
            {
                DXFdrawingEntry  someEntry   = savedStructureOfDxf.getItemByIndex(i);
                MyDxfBoundingBox obtainedBox = someEntry.GetBoundingBox();
                //offsets to centralize the drawing in the box
                Pen usedPen = null;
                if ((collectionOfLayerDefinitions != null) && (collectionOfLayerDefinitions.ContainsKey(someEntry.layerIdentifier)))
                {
                    usedPen = collectionOfLayerDefinitions[someEntry.layerIdentifier].Item2;
                }
                else
                {
                    usedPen = new Pen(Color.Black);
                }

                if (someEntry is MyDxfLine)
                {
                    MyDxfLine castLine = someEntry as MyDxfLine;

                    DXFentryForDisplay theLineForDisplay = new MyDxfLineForDisplay(castLine.XStart + offsetOfDxfHorizontal, castLine.YStart + offsetOfDxfVertical, castLine.XEnd + offsetOfDxfHorizontal, castLine.YEnd + offsetOfDxfVertical, usedPen);
                    primalDrawingStructure.addSingleEntry(theLineForDisplay, obtainedBox.XLowerLeft + offsetOfDxfHorizontal, obtainedBox.YLowerLeft + offsetOfDxfVertical, obtainedBox.XUpperRight + offsetOfDxfHorizontal, obtainedBox.YUpperRight + offsetOfDxfVertical);
                }
                else if (someEntry is MyDxfArc)
                {
                    MyDxfArc           castArc          = someEntry as MyDxfArc;
                    DXFentryForDisplay theArcForDisplay = new MyDxfArcForDisplay(castArc.XCenter + offsetOfDxfHorizontal, castArc.YCenter + offsetOfDxfVertical, castArc.Radius, castArc.StartAngleDegree, castArc.EndAngleDegree, usedPen);
                    primalDrawingStructure.addSingleEntry(theArcForDisplay, obtainedBox.XLowerLeft + offsetOfDxfHorizontal, obtainedBox.YLowerLeft + offsetOfDxfVertical, obtainedBox.XUpperRight + offsetOfDxfHorizontal, obtainedBox.YUpperRight + offsetOfDxfVertical);
                }
            }
            //performing flip on draw structure is done by means of graphical container
        }