Example #1
0
		public XElement MakeSvg()
		{
			m_mathConfig = new MathConfig(m_configFileName);
			MathNode currentNode = new MathNode(
				m_mathDocument.Root.Name.LocalName,
				m_mathDocument.Root.Attributes().ToDictionary(kvp => kvp.Name.ToString(), kvp => kvp.Value),
				m_mathConfig,
				null);
			ParseMML(m_mathDocument.Root, currentNode, 0);
			return currentNode.MakeImage();
		}
Example #2
0
        public XElement MakeSvg()
        {
            m_mathConfig = new MathConfig(m_configFileName);
            MathNode currentNode = new MathNode(
                m_mathDocument.Root.Name.LocalName,
                m_mathDocument.Root.Attributes().ToDictionary(kvp => kvp.Name.ToString(), kvp => kvp.Value),
                m_mathConfig,
                null);

            ParseMML(m_mathDocument.Root, currentNode, 0);
            return(currentNode.MakeImage());
        }
Example #3
0
        public XElement MakeSvg()
        {
            // need to enforce point as decimal seperator, otherwise it will fail.
            CultureInfo customCulture = CultureInfo.CurrentCulture.Clone() as CultureInfo;

            customCulture.NumberFormat.NumberDecimalSeparator = ".";
            CultureInfo.CurrentCulture = customCulture;

            m_mathConfig = new MathConfig(m_configFileName);
            MathNode currentNode = new MathNode(
                m_mathDocument.Root.Name.LocalName,
                m_mathDocument.Root.Attributes().ToDictionary(kvp => kvp.Name.ToString(), kvp => kvp.Value),
                m_mathConfig,
                null);

            ParseMML(m_mathDocument.Root, currentNode, 0);
            return(currentNode.MakeImage());
        }
Example #4
0
		public static void ParseMML(XElement root, MathNode parentNode, MathConfig mc, int depth)
		{
			int recDepth = depth + 1;
			foreach (XElement element in root.Elements())
			{
				//ToDo: implement namespaces
				Console.WriteLine("{0} {1}", new String(' ', recDepth), element.Name);
				MathNode mn = new MathNode(
                    element.Name.LocalName,
                    element.Attributes().ToDictionary(kvp => kvp.Name.ToString(), kvp => kvp.Value),
                    mc, parentNode);
                element.Nodes()
                    .Where(x => x.NodeType == System.Xml.XmlNodeType.Text || x.NodeType == System.Xml.XmlNodeType.Whitespace)
                    .ToList()
                    .ForEach(x => mn.Text = mn.Text + string.Join(" ", ((XText)x).Value.Split(null)));
				ParseMML(element, mn, mc, recDepth);
			}
		}
Example #5
0
 public MathNode(string elementName, Dictionary <string, string> attributes, MathConfig config, MathNode parent)
 {
     ElementName   = elementName;
     Config        = config;
     Text          = "";
     Children      = new List <MathNode>();
     Attributes    = attributes;
     Parent        = parent;
     MetricList    = null;
     FontFamilies  = new List <string>();
     NominalMetric = null;
     if (parent != null)
     {
         NodeIndex    = parent.Children == null ? 0 : parent.Children.Count;
         NodeDefaults = parent.NodeDefaults;
         Parent.Children.Add(this);
     }
     else
     {
         NodeDefaults = MathDefaults.globalDefaults;
         Config.Defaults.Keys.ToList().ForEach(x => NodeDefaults[x] = Config.Defaults[x]);
         NodeIndex = 0;
     }
 }
Example #6
0
        public MathNode(string elementName, Dictionary<string, string> attributes, MathConfig config, MathNode parent)
        {
            ElementName = elementName;
            Config = config;
            Text = "";
            Children = new List<MathNode>();
            Attributes = attributes;
            Parent = parent;
            MetricList = null;
			FontFamilies = new List<string>();
            NominalMetric = null;
            if (parent != null)
            {
                NodeIndex = parent.Children == null ? 0 : parent.Children.Count;
                NodeDefaults = parent.NodeDefaults;
                Parent.Children.Add(this);
            }
            else
            {
                NodeDefaults = MathDefaults.globalDefaults;
                Config.Defaults.Keys.ToList().ForEach(x => NodeDefaults[x] = Config.Defaults[x]);
                NodeIndex = 0;
            }
        }