Ejemplo n.º 1
0
 public void Paint(System.Drawing.Graphics g, int x, int y, int width, int height)
 {
     g.FillRectangle(fillBrush, x, y, width, height);
     if (formula != null)
     {
         formula.Draw(g);
     }
     g.DrawRectangle(rectPen, x, y, width - 1, height - 1);
 }
Ejemplo n.º 2
0
        private void paintDeriv()
        {
            Graphics g = Graphics.FromImage(derivImage);

            g.FillRectangle(fillBrush, derivRect.Left, derivRect.Top, derivRect.Width, derivRect.Height);
            if (derivFormula != null)
            {
                derivFormula.Draw(g);
            }
            g.DrawRectangle(rectPen, derivRect.Left, derivRect.Top, derivRect.Width - 1, derivRect.Height - 1);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates image from formula
        /// </summary>
        /// <param name="formula">Formula</param>
        /// <returns>Image</returns>
        public static Image CreateImage(string formula)
        {
            Image    im = new Bitmap(10, 10);
            Graphics g  = Graphics.FromImage(im);

            SimpleSymbolDrawable.Prepare(new int[] { 8, 6, 5, 4 }, g);
            MathFormulaDrawable f = new MathFormulaDrawable(MathFormula.FromString(new int[] { 8, 6, 5, 4 }, formula), DrawableConverter.Object);

            f.CalculateFullRelativeRectangle();
            Rectangle r = f.FullRelativeRectangle;
            Point     p = new Point(10, -r.Y);

            f.Position = p;
            f.CalculatePositions();
            im = new Bitmap(r.Width + 20, r.Height);
            Brush brush = new SolidBrush(Color.White);

            g = Graphics.FromImage(im);
            g.FillRectangle(brush, 0, 0, im.Width, im.Height);
            f.Draw(g);
            SimpleSymbolDrawable.Prepare(MathSymbolFactory.Sizes, g);
            g.Dispose();
            return(im);
        }