Example #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);
 }
Example #2
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);
     }
 }
Example #3
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);
             }
     }
 }
Example #4
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);
         }
     }
 }