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
 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 #3
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 #4
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 #5
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 #6
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);
         }
     }
 }