Example #1
0
 public MathFormulaDrawable(MathFormula formula, IMathSymbolConverter converter)
     : base(formula.Level, formula.Sizes)
 {
     sizes = formula.Sizes;
     for (int i = 0; i < formula.Count; i++)
     {
         MathSymbol s   = formula[i];
         MathSymbol sym = converter.Convert(s);
         sym.Sizes = sizes;
         sym.Append(this);
         sym = Last;
         for (int j = 0; j < s.Count; j++)
         {
             if (j >= sym.Count)
             {
                 break;
             }
             if (s[j] != null)
             {
                 s[j].Sizes = sizes;
                 sym[j]     = new MathFormulaDrawable(s[j], converter);
             }
         }
     }
 }
Example #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="control">component the editor component</param>
        /// <param name="formula">formula the formula for edit</param>
        public FormulaEditorPerformer(IControl control, MathFormulaDrawable formula)
        {
            this.virtualControl = control;
            this.formula        = formula;
            newCursor           = formula;

            /*     keyPressEventHandler = new KeyPressEventHandler(keyPress);
             *   keyUpEventHandler = new KeyEventHandler(keyUp);
             *   keySymbol = this;*/
        }
Example #3
0
 /// <summary>
 /// Copies this formula
 /// </summary>
 /// <returns>the copy</returns>
 public override MathFormula Copy()
 {
     form = new MathFormulaDrawable(new MathFormula(level, sizes), DrawableConverter.Object);
     for (int i = 0; i < Count; i++)
     {
         MathSymbol s = this[i].Copy();
         s.Parent = form;
         form.Add(s);
     }
     return(form);
 }
Example #4
0
        /// <summary>
        /// Sets formula
        /// </summary>
        /// <param name="str"></param>
        /// <param name="sizes"></param>
        public void SetFormula(string str, int[] sizes)
        {
            string s = "";

            if (str != null)
            {
                s = str;
            }
            MathFormula         f    = MathFormula.FromString(sizes, s);
            MathFormulaDrawable form = new MathFormulaDrawable(f, DrawableConverter.Object);

            form.Sizes = sizes;
            formula    = form;
            newCursor  = form;
            DrawFormula();
        }
Example #5
0
        /// <summary>
        /// Sets a new editing formula
        /// </summary>
        /// <param name="formula">The formula</param>
        /// <param name="rectangle">The new rectangle of new formula</param>
        public void SetFormula(MathFormulaDrawable formula, Rectangle rectangle)
        {
            this.formula = formula;
            newCursor    = this.formula;
            Rectangle r = formulaRectangle;

            r.X      = rectangle.X;
            r.Y      = rectangle.Y;
            r.Width  = rectangle.Width;
            r.Height = rectangle.Height;
            Point p = pointFormula;

            p.X = r.X + 20;
            p.Y = r.Y + r.Height / 2;
            this.formula.Position = p;
            this.formula.CalculateFullRelativeRectangle();
            this.formula.CalculatePositions();
        }