Exemplo n.º 1
0
 private void RealPaintingCanvas_Paint(object sender, PaintEventArgs e)
 {
     System.Drawing.Drawing2D.GraphicsContainer containerState = e.Graphics.BeginContainer();
     e.Graphics.ScaleTransform(1.0F, -1.0F);
     e.Graphics.TranslateTransform(0.0F, -(float)this.realPaintingCanvas.Height + 1.0f);
     if (actualDrawingStructure != null)
     {
         foreach (DXFentryForDisplay item in actualDrawingStructure)
         {
             if (item is MyDxfLineForDisplay)
             {
                 MyDxfLineForDisplay item2 = item as MyDxfLineForDisplay;
                 e.Graphics.DrawLine(item2.penStructure,
                                     (float)(item2.XStart * internalScaleFactor + 1),
                                     (float)(item2.YStart * internalScaleFactor + 1),
                                     (float)(item2.XEnd * internalScaleFactor + 1),
                                     (float)(item2.YEnd * internalScaleFactor + 1));
             }
             else if (item is MyDxfArcForDisplay)
             {
                 MyDxfArcForDisplay item2 = item as MyDxfArcForDisplay;
                 e.Graphics.DrawArc(item2.penStructure,
                                    (float)(item2.XUpper * internalScaleFactor + 1),
                                    (float)(item2.YUpper * internalScaleFactor + 1),
                                    (float)(item2.Width * internalScaleFactor), (float)(item2.Height * internalScaleFactor),
                                    (float)item2.startAngle, (float)item2.sweepAngle);
             }
         }
     }
     e.Graphics.EndContainer(containerState);
 }
Exemplo 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
        }