Beispiel #1
0
        protected void drawCenteredText(string s, Point p, bool cx)
        {
            var fs = Context.GetTextSize(s);
            int w  = (int)fs.Width;
            int h2 = (int)fs.Height / 2;

            if (cx)
            {
                adjustBbox(p.X - w / 2, p.Y - h2, p.X + w / 2, p.Y + h2);
            }
            else
            {
                adjustBbox(p.X, p.Y - h2, p.X + w, p.Y + h2);
            }
            Context.DrawCenteredText(s, p.X, p.Y);
        }
Beispiel #2
0
 public void drawChip(CustomGraphics g)
 {
     for (int i = 0; i != PostCount; i++)
     {
         var p = pins[i];
         var a = p.post;
         var b = p.stub;
         drawLead(a, b);
         p.curcount = updateDotCount(p.current, p.curcount);
         drawDots(b, a, p.curcount);
         if (p.bubble)
         {
             g.LineColor = Color.White;
             g.DrawCircle(p.bubblePos, 1);
             g.LineColor = CustomGraphics.GrayColor;
             g.DrawCircle(p.bubblePos, 3);
         }
         g.LineColor = p.selected ? CustomGraphics.SelectColor : CustomGraphics.GrayColor;
         int fsz  = 12 * csize;
         var font = CustomGraphics.FontText;
         while (true)
         {
             int sw = (int)g.GetTextSize(p.text, font).Width;
             /* scale font down if it's too big */
             if (sw > 12 * csize)
             {
                 fsz--;
                 font = new Font(CustomGraphics.FontText.Name, fsz);
                 continue;
             }
             g.DrawCenteredText(p.text, p.textloc.X, p.textloc.Y, font);
             if (p.lineOver)
             {
                 int ya = p.textloc.Y;
                 g.DrawLine(p.textloc.X - sw / 2, ya, p.textloc.X + sw / 2, ya);
             }
             break;
         }
     }
     g.LineColor = NeedsHighlight ? CustomGraphics.SelectColor : CustomGraphics.GrayColor;
     g.DrawPolygon(rectPoints);
     if (clockPoints != null)
     {
         g.DrawPolygon(clockPoints);
     }
     drawPosts();
 }