Exemple #1
0
 public void Paint(DGraphics dg, DPrintSettings dps, Figure backgroundFigure, IList<Figure> figures)
 {
     // margin
     dg.Translate(dps.MarginLeft, dps.MarginTop);
     // scale & center
     double pgAreaX = dps.PageWidth - dps.MarginLeft - dps.MarginRight;
     double pgAreaY = dps.PageHeight - dps.MarginTop - dps.MarginBottom;
     double sx = pgAreaX / PageSize.X;
     double sy = pgAreaY / PageSize.Y;
     if (sx > sy)
     {
         dg.Translate(pgAreaX / 2, 0);
         dg.Scale(sy, sy);
         dg.Translate(- PageSize.X / 2, 0);
     }
     else
     {
         dg.Translate(0, pgAreaY / 2);
         dg.Scale(sx, sx);
         dg.Translate(0, - PageSize.Y / 2);
     }
     // paint figures
     base.Paint(dg, backgroundFigure, figures);
     // paint outline
     dg.DrawRect(0, 0, pageSize.X, pageSize.Y, DColor.Black);
 }
Exemple #2
0
 protected override void PaintBody(DGraphics dg)
 {
     #if BEHAVIOURS
     // select paint properties
     DColor Fill = this.Fill;
     DColor Stroke = this.Stroke;
     double Alpha = this.Alpha;
     if (MouseOver)
     {
         if (MouseOverBehaviour.SetFill)
             Fill = MouseOverBehaviour.Fill;
         if (MouseOverBehaviour.SetStroke)
             Stroke = MouseOverBehaviour.Stroke;
         if (MouseOverBehaviour.SetAlpha)
             Alpha = MouseOverBehaviour.Alpha;
     }
     #endif
     // draw
     DPoints pts = DrawPoints();
     if (UseRealAlpha && Alpha != 1 && StrokeWidth > 0)
     {
         dg.StartGroup(X, Y, Width + StrokeWidth, Height + StrokeWidth, SwHalf, SwHalf);
         dg.FillPolygon(pts, Fill, 1);
         dg.DrawPolyline(pts, Stroke, 1, StrokeWidth, StrokeStyle, StrokeJoin, StrokeCap);
         dg.DrawGroup(Alpha);
     }
     else
     {
         dg.FillPolygon(pts, Fill, Alpha);
         dg.DrawPolyline(pts, Stroke, Alpha, StrokeWidth, StrokeStyle, StrokeJoin, StrokeCap);
     }
 }
Exemple #3
0
        DRect[] MeasureSelectionRects(DGraphics dg, string[] lines, double lineHeight)
        {
            DRect[] res = new DRect[0];
            if (selectionLength != 0)
            {
                // init selection variables
                int selStart;
                int selEnd;
                string wt = WrappedText; 
                if (selectionLength < 0)
                {
                    selStart = WrapPos(wt, cursorPosition + selectionLength);
                    selEnd = WrapPos(wt, cursorPosition);
                }
                else
                {
                    selStart = WrapPos(wt, cursorPosition);
                    selEnd = WrapPos(wt, cursorPosition + selectionLength);
                }
                // start measuring selection rectangles line by line
                int n = 0;
                for (int i = 0; i < lines.Length; i++)
                {
                    string line = lines[i];
                    string selText = null;
                    int selIdx = 0;
                    if (selStart >= n && selStart < n + line.Length) // start line
                    {
                        selIdx = selStart - n;
                        selText = line.Substring(selIdx, Math.Min(selEnd - selStart, line.Length - selIdx));
                    }
                    else if (selEnd > n && selEnd <= n + line.Length) // end line
                    {
                        selIdx = 0;
                        selText = line.Substring(selIdx, selEnd - n);
                    }
                    else if (n > selStart && n < selEnd) // in between line
                    {
                        selIdx = 0;
                        selText = line;
                    }
                    if (selText != null)
                    {
                        // start of selection rect for this line
                        double x;
                        if (selIdx != 0)
                            x = TextHelper.MeasureText(dg, line.Substring(0, selIdx), this).X;
                        else
                            x = 0;
                        // width of selection rect for this line
                        double w = TextHelper.MeasureText(dg, selText, this).X;
                        if (selIdx != 0)
                        {
                            // take into account the space that is put infront of the first character
                            double w2 = GraphicsHelper.MeasureText(string.Concat(selText, selText),
                            FontName, FontSize, Bold, Italics, Underline, Strikethrough).X;
                            w = w2 - w;
                        }
                        // add selection rect to function result
                        Array.Resize(ref res, res.Length + 1);
                        res[res.Length - 1] = new DRect(x, lineHeight * i, w, lineHeight);

                    }
                    n += line.Length + 1;
                }
            }
            return res;
        }
Exemple #4
0
 public override void Paint(DGraphics dg, Figure f, double scale)
 {
     dg.DrawBitmap(bmp, GetRect(Position, f.GetSelectRect(), scale));
 }
Exemple #5
0
 protected void DoNeedRepaint(DGraphics dg)
 {
     if (NeedRepaint != null)
         NeedRepaint(this, dg);
 }
Exemple #6
0
 void WmfUpdateMaxtrix(DGraphics dg, DMatrix m)
 {
     // could not get this working... used wmfApplyTransforms to all points instead :(
     /*
     dg.LoadTransform(m);
     dg.Translate(X - winX, Y - winY);
     //int pW = placeable.Right - placeable.Left, pH = placeable.Bottom - placeable.Top;
     //dg.Scale(Width / pW, Height / pH);
     //if (winWidth != 0 && winHeight != 0)
     //    dg.Scale(pW / winWidth, pH / winHeight);
     if (winWidth != 0 && winHeight != 0)
         dg.Scale(Width / winWidth, Height / winHeight);
     */
 }
Exemple #7
0
 void PaintMetafile(DGraphics dg)
 {
     if (MetafileType == DMetafileType.Wmf && ImageData.Length >= Marshal.SizeOf(typeof(Wmf.Placeable)))
         PaintWmf(dg);
 }
Exemple #8
0
 public static DPoint MeasureText(DGraphics dg, string text, string fontName, double fontSize, bool bold, bool italics, bool underline, bool strikethrough)
 {
     return dg.MeasureText(text, fontName, fontSize, bold, italics, underline, strikethrough);
 }
Exemple #9
0
 public void Paint(DGraphics dg)
 {
     dg.Save();
     ApplyTransforms(dg, true);
     PaintBody(dg);
     if (glyphsVisible && HasGlyphs)
     {
         UnFlipTransform(dg);
         PaintGlyphs(dg);
     }
     dg.Restore();
 }
Exemple #10
0
 void UnFlipTransform(DGraphics dg)
 {
     DPoint ctr = Rect.Center;
     if (FlipX)
     {
         dg.Scale(-1, 1);
         dg.Translate(-ctr.X * 2, 0);
     }
     if (FlipY)
     {
         dg.Scale(1, -1);
         dg.Translate(0, -ctr.Y * 2);
     }
 }
Exemple #11
0
 protected void ApplyTransforms(DGraphics dg, bool doFlips)
 {
     DPoint ctr = Rect.Center;
     dg.Rotate(Rotation, ctr);
     if (doFlips)
     {
         if (FlipX)
         {
             dg.Translate(ctr.X * 2, 0);
             dg.Scale(-1, 1);
         }
         if (FlipY)
         {
             dg.Translate(0, ctr.Y * 2);
             dg.Scale(1, -1);
         }
     }
 }
Exemple #12
0
 protected override void PaintBody(DGraphics dg)
 {
     dg.FillRect(X, Y, Width, Height, Fill, Alpha);
     base.PaintBody(dg);
 }
Exemple #13
0
 public static DPoint MeasureText(DGraphics dg, string text, ITextable itext)
 {
     return GraphicsHelper.MeasureText(dg, text, itext.FontName, itext.FontSize, itext.Bold, itext.Italics, itext.Underline, itext.Strikethrough);
 }
Exemple #14
0
        /* An example figure that show how one can use the CompositingMode
         * to do a decent alpha blend.
         * However this is a bit slower and does not blend the edges of the 
         * bitmap with the canvas when AntiAlias is turned on.
         * 
         * Needs more work/thinking...
         */

        protected override void PaintBody(DGraphics dg)
        {
            if (Width > 0 && Height > 0)
            {
                DBitmap bmp = GraphicsHelper.MakeBitmap(Width, Height);
                DGraphics bmpGfx = GraphicsHelper.MakeGraphics(bmp);
                bmpGfx.AntiAlias = dg.AntiAlias;
                bmpGfx.CompositingMode = DCompositingMode.SourceCopy;
                bmpGfx.FillRect(1, 1, Width - 2, Height - 2, DColor.Blue, Alpha);
                bmpGfx.FillRect(1, 1, 2 * Width / 3, 2 * Height / 3, DColor.Red, Alpha);
                bmpGfx.FillRect(Width / 3, Height / 3, 2 * Width / 3 - 1, 2 * Height / 3 - 1, DColor.Green, Alpha);
                dg.DrawBitmap(bmp, Rect, Alpha);
                bmpGfx.Dispose();
                bmp.Dispose();
            }
        }
Exemple #15
0
 protected override void PaintBody(DGraphics dg)
 {
     if (UseRealAlpha)
     {
         if (Width > 0 && Height > 0)
         {
             DRect rS = GetSelectRect();
             dg.StartGroup(rS.X, rS.Y, rS.Width, rS.Height, 0, 0);
             foreach (Figure f in childFigs)
             {
                 f._controlScale = _controlScale;
                 f.GlyphsVisible = GlyphsVisible;
                 f.Paint(dg);
             }
             dg.DrawGroup(Alpha);
         }
     }
     else
         foreach (Figure f in childFigs)
         {
             f._controlScale = _controlScale;
             f.GlyphsVisible = GlyphsVisible;
             f.Paint(dg);
         }
 }
Exemple #16
0
 protected override void PaintBody(DGraphics dg)
 {
     #if BEHAVIOURS
     // select paint properties
     DColor Fill = this.Fill; ;
     DColor Stroke = this.Stroke;
     double Alpha = this.Alpha;
     if (MouseOver)
     {
         if (MouseOverBehaviour.SetFill)
             Fill = MouseOverBehaviour.Fill;
         if (MouseOverBehaviour.SetStroke)
             Stroke = MouseOverBehaviour.Stroke;
         if (MouseOverBehaviour.SetAlpha)
             Alpha = MouseOverBehaviour.Alpha;
     }
     #endif
     // do painting
     DRect r = GetClockRect();
     const int baseSize = 100;
     if (editing)
         dg.FillRect(r.X, r.Y, r.Width, r.Height, DColor.Black, 1, DFillStyle.ForwardDiagonalHatch);
     dg.FillEllipse(r, Fill, Alpha);
     dg.DrawEllipse(r.X, r.Y, r.Width, r.Height, Stroke, Alpha, StrokeWidth, StrokeStyle);
     double offset = 0.5 * Width / baseSize;
     string[] nums = new string[] { "12", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11" };
     string font = "Arial";
     double fontSz = 6 * Width / baseSize;
     if (fontSz <= 0) fontSz = 6;
     for (int i = 0; i < nums.Length; i++)
     {
         string text = nums[i];
         DPoint textPos = TextPoint(r, i);
         DPoint textSz = dg.MeasureText(text, font, fontSz);
         dg.Save();
         dg.Translate(offset, offset);
         dg.DrawText(text, font, fontSz, new DPoint(textPos.X - textSz.X / 2, textPos.Y - textSz.Y / 2), DColor.Black, Alpha);
         dg.Restore();
         dg.DrawText(text, font, fontSz, new DPoint(textPos.X - textSz.X / 2, textPos.Y - textSz.Y / 2), DColor.White, Alpha);
     }
     double handWidth = 3 * Width / baseSize;
     dg.Save();
     dg.Translate(offset, offset);
     dg.DrawLine(r.Center, FirstHandPoint(r), DColor.Black, Alpha, DStrokeStyle.Solid, handWidth, DStrokeCap.Round);
     dg.DrawLine(r.Center, SecondHandPoint(r), DColor.Black, Alpha, DStrokeStyle.Solid, handWidth, DStrokeCap.Round);
     dg.Restore();
     dg.DrawLine(r.Center, FirstHandPoint(r), DColor.Red, Alpha, DStrokeStyle.Solid, handWidth, DStrokeCap.Round);
     dg.DrawLine(r.Center, SecondHandPoint(r), DColor.Blue, Alpha, DStrokeStyle.Solid, handWidth, DStrokeCap.Round);
 }
Exemple #17
0
 protected override void PaintBody(DGraphics dg)
 {
     base.PaintBody(dg);
     dg.Save();
     dg.Clip(Rect);
     DPoint offset = TextOffset;
     dg.Translate(X + offset.X, Y + offset.Y);
     tf.Paint(dg);
     dg.Restore();
 }
Exemple #18
0
 protected abstract void PaintBody(DGraphics dg);
Exemple #19
0
 protected override void PaintBody(DGraphics dg)
 {
     if (Alpha != 1)
     {
         dg.StartGroup(X, Y, Width, Height, 0, 0);
         PaintMetafile(dg);
         dg.DrawGroup(Alpha);
     }
     else
         PaintMetafile(dg);
 }
Exemple #20
0
 protected virtual void PaintContextHandle(DGraphics dg)
 {
     if (contextHandle)
     {
         double hb = _handleBorder * _controlScale;
         double hb2 = hb + hb;
         DRect r = GetContextHandleRect();
         if (hb != 0)
             r = r.Resize(hb, hb, -hb2, -hb2);
         dg.FillEllipse(r, DColor.White);
         dg.DrawEllipse(r.X, r.Y, r.Width, r.Height, DColor.Black, 1, _controlScale, DStrokeStyle.Solid);
         double qW = r.Width / 4;
         double tH = r.Height / 3;
         DPoints pts = new DPoints();
         pts.Add(new DPoint(r.X + qW, r.Y + tH));
         pts.Add(new DPoint(r.X + qW * 2, r.Y + tH * 2));
         pts.Add(new DPoint(r.X + qW * 3, r.Y + tH));
         dg.DrawPolyline(pts, DColor.Black);
     }
 }
Exemple #21
0
        private void PaintWmf(DGraphics dg)
        {
            dg.Save();
            dg.Clip(Rect);
            // store current matrix
            DMatrix m = dg.SaveTransform();
            // clear gdi objects
            WmfGdiObjects.Clear();
            // check for placeable key
            if (WmfIsPlaceable)
            {
                bytesRead = 0;
                // read placeable header
                placeable = GetWmfPlaceable();
                // checksum
                int sum = 0;
                for (int i = 0; i < (Marshal.SizeOf(typeof(Wmf.Placeable)) - 2 /* WmfPlaceable.Checksum is UInt16 */) / 2; i++)
                    sum = sum ^ BitConverter.ToUInt16(ImageData, i * 2);
                if (sum != placeable.Checksum)
                    System.Diagnostics.Debug.Fail("checksum failed");
                // init matrix
                WmfUpdateMaxtrix(dg, m);
                // read header
                header = GetWmfHeader();
                // iterate draw commands
                bool records = true;
                while (records)
                {
                    int bytesReadPlusFuncHeaderSize = bytesRead;
                    Wmf.FuncHeader fh = GetWmfFuncHeader();
                    bytesReadPlusFuncHeaderSize += (int)fh.Size * 2;
                    bool breakme = false;
                    switch (fh.Function)
                    {
                        case Wmf.SaveDC:
                            break;
                        case Wmf.CreatePalette:
                            break;
                        case Wmf.SetBkMode:
                            int bkMode = GetInt16();
                            break;
                        case Wmf.SetMapMode:
                            int mapMode = GetInt16();
                            break;
                        case Wmf.SetROP2:
                            break;
                        case Wmf.SetRelabs:
                            break;
                        case Wmf.SetPolyFillMode:
                            int polyfillMode = GetInt16();
                            if (polyfillMode == Wmf.PfmAlernate)
                                fillRule = DFillRule.EvenOdd;
                            else
                                fillRule = DFillRule.Winding;
                            break;
                        case Wmf.SetStretchBltMode:
                            break;
                        case Wmf.DeleteObject:
                            WmfDeleteGdiObject(GetInt16());
                            break;
                        case Wmf.RestoreDC:
                            break;
                        case Wmf.SelectObject:
                            WmfSelectGdiObject(GetInt16());
                            break;
                        case Wmf.SetTextAlign:
                            break;
                        case Wmf.SetBkColor:
                            break;
                        case Wmf.SetTextColor:
                            break;
                        case Wmf.SetWindowOrg:
                            winY = GetInt16();
                            winX = GetInt16();
                            WmfUpdateMaxtrix(dg, m);
                            break;
                        case Wmf.SetWindowExt:
                            winHeight = GetInt16();
                            winWidth = GetInt16();
                            WmfUpdateMaxtrix(dg, m);
                            break;
                        case Wmf.SetViewportOrg:
                            viewY = GetInt16();
                            viewX = GetInt16();
                            //wmfUpdateMaxtrix(dg, m);
                            break;
                        case Wmf.SetViewportExt:
                            viewHeight = GetInt16();
                            viewWidth = GetInt16();
                            //wmfUpdateMaxtrix(dg, m);
                            break;
                        case Wmf.LineTo:
                            DPoint pt = GetPoint();
                            if (StrokeValid)
                                dg.DrawLine(curPoint, pt, stroke, 1, strokeStyle, strokeWidth, strokeCap);
                            curPoint = pt;
                            break;
                        case Wmf.MoveTo:
                            curPoint = GetPoint();
                            break;
                        case Wmf.SelectPalette:
                            break;
                        case Wmf.CreatePenIndirect:
                            int gdiPenStyle = GetInt16();
                            int widthX = GetInt16();
                            int widthY = GetInt16();
                            DColor penColor = GetColor();
                            double penWidth = widthX;
                            WmfApplyTransforms(ref penWidth);
                            DStrokeStyle penStyle = DStrokeStyle.Solid;
                            DStrokeCap penCap = DStrokeCap.Round;
                            DStrokeJoin penJoin = DStrokeJoin.Round;

                            if ((gdiPenStyle & Wmf.PS_DASHDOTDOT) == Wmf.PS_DASHDOTDOT)
                                penStyle = DStrokeStyle.DashDotDot;
                            else if ((gdiPenStyle & Wmf.PS_DASHDOT) == Wmf.PS_DASHDOT)
                                penStyle = DStrokeStyle.DashDot;
                            else if ((gdiPenStyle & Wmf.PS_DOT) == Wmf.PS_DOT)
                                penStyle = DStrokeStyle.Dot;
                            else if ((gdiPenStyle & Wmf.PS_DASH) == Wmf.PS_DASH)
                                penStyle = DStrokeStyle.Dash;
                            else
                                penStyle = DStrokeStyle.Solid;

                            if ((gdiPenStyle & Wmf.PS_ENDCAP_FLAT) == Wmf.PS_ENDCAP_FLAT)
                                penCap = DStrokeCap.Butt;
                            else if ((gdiPenStyle & Wmf.PS_ENDCAP_SQUARE) == Wmf.PS_ENDCAP_SQUARE)
                                penCap = DStrokeCap.Square;
                            else
                                penCap = DStrokeCap.Round;

                            if ((gdiPenStyle & Wmf.PS_JOIN_MITER) == Wmf.PS_JOIN_MITER)
                                penJoin = DStrokeJoin.Mitre;
                            else if ((gdiPenStyle & Wmf.PS_JOIN_BEVEL) == Wmf.PS_JOIN_BEVEL)
                                penJoin = DStrokeJoin.Bevel;
                            else
                                penJoin = DStrokeJoin.Round;

                            if ((gdiPenStyle & Wmf.PS_NULL) == Wmf.PS_NULL)
                                WmfAddGdiObject(new WmfGdiPen(DColor.Empty, penWidth, penStyle, penCap, penJoin));
                            else
                                WmfAddGdiObject(new WmfGdiPen(penColor, penWidth, penStyle, penCap, penJoin));
                            break;
                        case Wmf.CreateFontIndirect:
                            WmfAddGdiObject("font");
                            break;
                        case Wmf.CreateBrushIndirect:
                            int brushStyle = GetInt16();
                            DColor brushColor = GetColor();
                            int brushHatch = GetInt16();
                            if ((brushStyle & Wmf.BS_NULL) == Wmf.BS_NULL)
                                WmfAddGdiObject(new WmfGdiBrush(DColor.Empty));
                            else
                                WmfAddGdiObject(new WmfGdiBrush(brushColor));
                            break;
                        case Wmf.Polygon:
                            DPoints polygonPts = GetPolyPoints(GetInt16(), true);
                            if (FillValid)
                                dg.FillPolygon(polygonPts, fill, 1, fillRule);
                            if (StrokeValid)
                                dg.DrawPolyline(polygonPts, stroke, 1, strokeWidth, strokeStyle, strokeJoin, strokeCap);
                            break;
                        case Wmf.Polyline:
                            DPoints polylinePts = GetPolyPoints(GetInt16(), false);
                            if (StrokeValid)
                                dg.DrawPolyline(polylinePts, stroke, 1, strokeWidth, strokeStyle, strokeJoin, strokeCap);
                            break;
                        case Wmf.Ellipse:
                            goto case Wmf.Rectangle;
                        case Wmf.Rectangle:
                            DPoint br = GetPoint();
                            DPoint tl = GetPoint();
                            if (FillValid)
                            {
                                if (fh.Function == Wmf.Rectangle)
                                    dg.FillRect(tl.X, tl.Y, br.X - tl.X, br.Y - tl.Y, fill, 1);
                                else if (fh.Function == Wmf.Ellipse)
                                    dg.FillEllipse(tl.X, tl.Y, br.X - tl.X, br.Y - tl.Y, fill, 1);
                            }
                            if (StrokeValid)
                            {
                                if (fh.Function == Wmf.Rectangle)
                                    dg.DrawRect(tl.X, tl.Y, br.X - tl.X, br.Y - tl.Y, stroke, 1, strokeWidth, strokeStyle, strokeJoin);
                                else if (fh.Function == Wmf.Ellipse)
                                    dg.DrawEllipse(tl.X, tl.Y, br.X - tl.X, br.Y - tl.Y, stroke, 1, strokeWidth, strokeStyle);
                            }
                            break;
                        case Wmf.PolyPolygon:
                            // find out how many points
                            int numPolygons = GetInt16();
                            int[] numPoints = new int[numPolygons];
                            for (int i = 0; i < numPolygons; i++)
                                numPoints[i] = GetInt16();
                            // join polygons together
                            DPoints polyPolyPoints = new DPoints();
                            for (int i = 0; i < numPolygons; i++)
                                foreach (DPoint polyPolyPt in GetPolyPoints(numPoints[i], true))
                                    polyPolyPoints.Add(polyPolyPt);
                            // draw
                            if (FillValid)
                                dg.FillPolygon(polyPolyPoints, fill, 1, fillRule);
                            if (StrokeValid)
                                dg.DrawPolyline(polyPolyPoints, stroke, 1, strokeWidth, strokeStyle, strokeJoin, strokeCap);
                            break;
                        case Wmf.Escape:
                            break;
                        default:
                            breakme = true;
                            break;
                    }

                    if (bytesRead != bytesReadPlusFuncHeaderSize)
                        bytesRead = bytesReadPlusFuncHeaderSize;
                    if (breakme)
                        break;
                }
            }
            dg.Restore();
        }
Exemple #22
0
 protected virtual void PaintLockHandle(DGraphics dg)
 {
     if (contextHandle)
     {
         double hb = _handleBorder * _controlScale;
         double hb2 = hb + hb;
         DRect r = GetContextHandleRect();
         if (hb != 0)
             r = r.Resize(hb, hb, -hb2, -hb2);
         dg.FillEllipse(r, DColor.White);
         dg.DrawEllipse(r.X, r.Y, r.Width, r.Height, DColor.Black, 1, _controlScale, DStrokeStyle.Solid);
         double qW = r.Width / 4;
         double qH = r.Height / 4;
         dg.DrawLine(new DPoint(r.X + qW, r.Y + qW), new DPoint(r.X + qW * 3, r.Y + qW * 3), DColor.Red);
         dg.DrawLine(new DPoint(r.X + qW, r.Y + qW * 3), new DPoint(r.X + qW * 3, r.Y + qW), DColor.Red);
     }
 }
Exemple #23
0
 public void Paint(DGraphics dg, Figure backgroundFigure, IList<Figure> figures, Figure[] controlFigures)
 {
     // set antialias value
     dg.AntiAlias = AntiAlias;
     // draw backround and transform canvas accordind to the pagesize
     if (Preview)
         dg.Scale(Width / PageSize.X, Height / PageSize.Y); // scale to width & height as this is a preview viewer
     else
     {
         dg.FillRect(0, 0, Width, Height, DColor.LightGray, 1); // gray background
         DPoint offset = CanvasOffset();
         dg.Translate(offset.X, offset.Y); // center drawing
         dg.Scale(scale, scale); // scale canvas
         dg.FillRect(SHADOW_OFFSET, SHADOW_OFFSET, PageSize.X, PageSize.Y, DColor.Black, 1); // draw black canvas shadow
     }
     // paint figures
     if (backgroundFigure != null)
     {
         backgroundFigure.Width = PageSize.X;
         backgroundFigure.Height = PageSize.Y;
         backgroundFigure.Paint(dg);
     }
     if (!Preview && Grid > 0)
     {
         for (int i = 1; i < (PageSize.X / Grid); i++)
             dg.DrawLine(new DPoint(i * grid, 0), new DPoint(i * grid, PageSize.Y), DColor.LightGray, 1, DStrokeStyle.Solid, 1, DStrokeCap.Butt);
         for (int i = 1; i < (PageSize.Y / Grid); i++)
             dg.DrawLine(new DPoint(0, i * grid), new DPoint(PageSize.X, i * grid), DColor.LightGray, 1, DStrokeStyle.Solid, 1, DStrokeCap.Butt);
     }
     double invScale = 1 / scale;
     foreach (Figure figure in figures)
     {
         figure._controlScale = invScale;
         figure.GlyphsVisible = editFigures;
         figure.Paint(dg);
     }
     if (editFigures)
     {
         foreach (Figure figure in figures)
             figure.PaintSelectionChrome(dg);
         if (controlFigures != null)
             foreach (Figure figure in controlFigures)
             {
                 figure._controlScale = invScale;
                 figure.Paint(dg);
             }
     }
 }
Exemple #24
0
 public virtual void PaintSelectionChrome(DGraphics dg)
 {
     if (Selected)
     {
         // save current transform
         DMatrix m = dg.SaveTransform();
         // apply transform
         ApplyTransforms(dg, false);
         // draw selection rectangle
         DRect r = GetSelectRect();
         double selectRectY = r.Y;
         dg.DrawRect(r.X, r.Y, r.Width, r.Height, DColor.White, 1, _controlScale);
         dg.DrawRect(r.X, r.Y, r.Width, r.Height, DColor.Black, 1, _controlScale, DStrokeStyle.Dot, DStrokeJoin.Mitre);
         if (Locked)
             PaintLockHandle(dg);
         else
         {
             // draw context handle
             PaintContextHandle(dg);
             // draw resize handle
             double hb = _handleBorder * _controlScale;
             double hb2 = hb + hb;
             r = GetResizeHandleRect();
             if (hb != 0)
                 r = r.Resize(hb, hb, -hb2, -hb2);
             dg.FillEllipse(r, DColor.Red);
             dg.DrawEllipse(r.X, r.Y, r.Width, r.Height, DColor.Black, 1, _controlScale, DStrokeStyle.Solid);
             // draw rotate handle
             r = GetRotateHandleRect();
             if (hb != 0)
                 r = r.Resize(hb, hb, -hb2, -hb2);
             DPoint p1 = r.Center;
             DPoint p2 = new DPoint(p1.X, selectRectY);
             dg.DrawLine(p1, p2, DColor.White, 1, DStrokeStyle.Solid, _controlScale, DStrokeCap.Butt);
             dg.DrawLine(p1, p2, DColor.Black, 1, DStrokeStyle.Dot, _controlScale, DStrokeCap.Butt);
             dg.FillEllipse(r, DColor.Blue);
             dg.DrawEllipse(r.X, r.Y, r.Width, r.Height, DColor.Black, 1, _controlScale, DStrokeStyle.Solid);
         }
         //r = GetEncompassingRect();
         //dg.DrawRect(r.X, r.Y, r.Width, r.Height, DColor.Black, 1, Scale);
         // load previous transform
         dg.LoadTransform(m);
     }
 }
Exemple #25
0
 public void Paint(DGraphics dg, Figure backgroundFigure, IList<Figure> figures)
 {
     // paint figures
     if (backgroundFigure != null)
         backgroundFigure.Paint(dg);
     foreach (Figure figure in figures)
     {
         figure.GlyphsVisible = false;
         figure.Paint(dg);
     }
 }
Exemple #26
0
 public virtual void PaintGlyphs(DGraphics dg)
 {
     if (glyphs != null && glyphs.Count > 0)
         foreach (IGlyph g in glyphs)
             if (g.IsVisible(selected))
                 g.Paint(dg, this, _controlScale);
 }
Exemple #27
0
 public abstract void Paint(DGraphics dg, Figure f, double scale);
Exemple #28
0
 // viewer events
 void dv_NeedRepaint(DTkViewer dv, DGraphics dg)
 {
     if (NeedRepaint != null)
         NeedRepaint(dv, dg);
 }
Exemple #29
0
 protected override void PaintBody(DGraphics dg)
 {
     dg.DrawRect(X, Y, Width, Height, DColor.White, Alpha, strokeWidth * _controlScale);
     dg.DrawRect(X, Y, Width, Height, color, Alpha, strokeWidth * _controlScale, DStrokeStyle.Dot, DStrokeJoin.Mitre);
 }
Exemple #30
0
 // viewer events
 void dv_NeedRepaint(DTkViewer dv,DGraphics dg)
 {
     Figure[] controlFigures = null;
     if (drawSelection || drawEraser)
     {
         controlFigures = new Figure[0];
         if (drawSelection)
         {
             Array.Resize(ref controlFigures, controlFigures.Length + 1);
             controlFigures[controlFigures.Length - 1] = figureHandler.SelectionFigure;
         }
         if (drawEraser)
         {
             Array.Resize(ref controlFigures, controlFigures.Length + 1);
             controlFigures[controlFigures.Length - 1] = figureHandler.EraserFigure;
         }
     }
     dv.Paint(dg, figureHandler.BackgroundFigure, figureHandler.Figures, controlFigures);
 }