예제 #1
0
        /// <summary>
        /// Creates element from formula
        /// </summary>
        /// <param name="formula">Formula</param>
        /// <param name="document">Document</param>
        /// <param name="creator">Creator</param>
        /// <returns>Element</returns>
        public static XElement CreateElement(MathFormula formula,
                                             IXmlSymbolCreator creator)
        {
            XElement e = formula.CreateXElement("F");

            for (int i = 0; i < formula.Count; i++)
            {
                XElement el = MathSymbol.CreateElement(formula[i], creator);
                e.Add(el);
            }
            return(e);
        }
예제 #2
0
        /// <summary>
        /// Creates Element from symbol
        /// </summary>
        /// <param name="symbol">The symbol</param>
        /// <param name="document">The doucument</param>
        /// <param name="creator">Creator</param>
        /// <returns>The element</returns>
        public static XElement CreateElement(MathSymbol symbol,
                                             IXmlSymbolCreator creator)
        {
            XElement e = creator.CreateElement(symbol);

            for (int i = 0; i < symbol.Count; i++)
            {
                XElement el = MathFormula.CreateElement(symbol[i], creator);
                e.Add(el);
            }
            return(e);
        }
예제 #3
0
        /// <summary>
        /// Creates formula from Xml element
        /// </summary>
        /// <param name="e">Element</param>
        /// <param name="creator">Creator of symbols</param>
        /// <returns>Formula</returns>
        public static MathFormula CreateFormula(XElement e, IXmlSymbolCreator creator)
        {
            MathFormula            f = new MathFormula((byte)0);
            IEnumerable <XElement> l = e.GetElementsByTagName("S");

            foreach (XElement el in l)
            {
                if (el.Parent != e)
                {
                    continue;
                }
                MathSymbol s = MathSymbol.CreateSymbol(el, creator);
                s.AppendWithChildren(f);
            }
            return(f);
        }
예제 #4
0
        /// <summary>
        /// Craeates symbol from Xml element
        /// </summary>
        /// <param name="e">The element</param>
        /// <param name="creator">The creator</param>
        /// <returns>The symbol</returns>
        public static MathSymbol CreateSymbol(XElement e, IXmlSymbolCreator creator)
        {
            MathSymbol             s    = creator.CreateSymbol(e);
            IEnumerable <XElement> l    = e.GetElementsByTagName("F");
            List <MathFormula>     list = new List <MathFormula>();

            foreach (XElement el in l)
            {
                if (el.Parent != e)
                {
                    continue;
                }
                MathFormula f = MathFormula.CreateFormula(el, creator);
                list.Add(f);
            }
            s.Children = list;
            return(s);
        }
예제 #5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="creator">Creator of symbols</param>
 public XmlFormulaSaver(IXmlSymbolCreator creator)
 {
     this.creator = creator;
 }