예제 #1
0
        public void Read(string filename)
        {
            _defStore       = new DomNodeDefinitionStore();
            ResultMathNodes = new List <math>();
            //read math ml from file
            //for resolve character like &plusmn;
            string      html   = System.Net.WebUtility.HtmlDecode(File.ReadAllText(filename));
            XmlDocument xmldoc = new XmlDocument();

            xmldoc.Load(filename);
            //xmldoc.LoadXml(html);
            //
            //walk /find all <math> node


            foreach (XmlElement mathElm in xmldoc.DocumentElement.SelectNodes("//math")) //select all math nodes in the document
            {
                //begin with math node
                math math = new math();

                Parse(mathElm, math);
                //FINISH each math node
                ResultMathNodes.Add(math);
            }
        }
예제 #2
0
        private void button4_Click(object sender, EventArgs e)
        {
            //test read document
            MathMLReader reader = new MathMLReader();

            //reader.Read("Examples/p28.html");
            if (exampleBox.Items.Count > 0)
            {
                string file = exampleBox.SelectedItem.ToString();
                reader.Read(file);
            }
            else
            {
                reader.Read("Examples/p3314_2.html");
            }
            List <math> resultNodes = reader.ResultMathNodes;

            //test render 1st node
            if (resultNodes.Count > 0)
            {
                boxHelper.FontSize = 40;
                //boxHelper.FontFile = "Fonts/Asana-Math.otf";
                if (_mathTypeface == null)
                {
                    string mathFont = "Fonts/latinmodern-math.otf";
                    using (FileStream fs = new FileStream(mathFont, FileMode.Open))
                    {
                        OpenFontReader fontReader = new OpenFontReader();
                        _mathTypeface = fontReader.Read(fs);
                    }
                }
                boxHelper.MathTypeface = _mathTypeface;



                math m = resultNodes[0];
                //Box box = boxHelper.CreateMathBox(m);
                Box box = boxHelper.CreateMathBoxs(resultNodes);
                box.SetLocation(10, 10);
                box.Layout();
                //present this box in the canvas
                Paint(box);
            }
        }