void IDrawableSymbol.Prepare(FormulaEditorPerformer performer) { Font f; if (italic) { f = PureDrawableSymbol.FontsItalic[0]; } else { f = PureDrawableSymbol.FontsBold[0]; } pDrawable.Font = f; IControl c = performer.EditControl; Graphics g = c.Graphics; int h = (int)((1 + 2 * PureDrawableSymbol.C_HEIGHT) * pDrawable.Font.Height); int w = (int)g.MeasureString(s + "iw", pDrawable.Font).Width; int w1 = (int)g.MeasureString(s, pDrawable.Font).Width; g.Dispose(); Bitmap im = new Bitmap(w, h); Graphics gr = Graphics.FromImage(im); Pen pen = new Pen(Color.Black); Brush brush = new SolidBrush(Color.White); gr.FillRectangle(brush, 1, 1, w - 2, h - 2); gr.DrawRectangle(pen, 0, 0, w - 1, h - 1); int x = (int)gr.MeasureString("i", pDrawable.Font).Width / 2; gr.DrawString(s, pDrawable.Font, PureDrawableSymbol.SymbolBrush, x, PureDrawableSymbol.TOP_SHIFT); gr.Dispose(); im.MakeTransparent(Color.White); pDrawable.SetImage(im); }
/// <summary> /// Preparation of symbol /// </summary> /// <param name="performer">The editor performer</param> public void Prepare(FormulaEditorPerformer performer) { IControl c = performer.EditControl; Graphics g = c.Graphics; int h = (int)(fontB.Height); int w = (int)g.MeasureString(s + "ii", fontB).Width; Image image = new Bitmap(w, h); Graphics gr = Graphics.FromImage(image); gr.FillRectangle(PureDrawableSymbol.WhiteBrush, 0, 0, w, h); gr.DrawString(s, fontB, PureDrawableSymbol.SymbolBrush, gr.MeasureString("i", fontB).Width, PureDrawableSymbol.TOP_SHIFT); ((Bitmap)image).MakeTransparent(Color.White); pDrawable.SetImage(image); }