Beispiel #1
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);
 }
Beispiel #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
     // 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);
 }