public void ToMathMLString_When_UsingPowerBaseUnit_Then_ResultShouldBedExpectedResult(
            MultiplicationSign multiplicationSign)
        {
            string expectedResult =
                $@"<mml:math xmlns:mml=""http://www.w3.org/1998/Math/MathML"">
  <mml:mfrac>
    <mml:mrow>
      <mml:mi mathvariant=""normal"" class=""MathML-Unit"">kg</mml:mi>
      <mml:mo>{MathML.GetMultiplicationSign(multiplicationSign)}</mml:mo>
      <mml:msup>
        <mml:mi mathvariant=""normal"" class=""MathML-Unit"">m</mml:mi>
        <mml:mn>2</mml:mn>
      </mml:msup>
    </mml:mrow>
    <mml:mrow>
      <mml:msup>
        <mml:mi mathvariant=""normal"" class=""MathML-Unit"">s</mml:mi>
        <mml:mn>3</mml:mn>
      </mml:msup>
    </mml:mrow>
  </mml:mfrac>
</mml:math>";
            var power = 54.Watts();

            var result = power.Unit.BaseUnit.ToMathMLString(multiplicationSign);

            result.Should().Be(expectedResult);
        }
Пример #2
0
 public void Test_Generate_XML_1()
 {
     string expr1 = "1+2=3";
     Expr expr = starPadSDK.MathExpr.Text.Convert(expr1);
     var mathml = new MathML();
     XmlDocument xml = mathml.Convert(expr);
     xml.Save("a.xml");
     Console.WriteLine(xml);
 }
Пример #3
0
        public void Test_Generate_XML_1()
        {
            string      expr1  = "1+2=3";
            Expr        expr   = starPadSDK.MathExpr.Text.Convert(expr1);
            var         mathml = new MathML();
            XmlDocument xml    = mathml.Convert(expr);

            xml.Save("a.xml");
            Console.WriteLine(xml);
        }
Пример #4
0
        internal static HandleRef getCPtrAndDisown(MathML obj)
        {
            HandleRef ptr = new HandleRef(null, IntPtr.Zero);

            if (obj != null)
            {
                ptr             = obj.swigCPtr;
                obj.swigCMemOwn = false;
            }

            return(ptr);
        }
Пример #5
0
    static void ComposeText(StringBuilder stb, string rawtext, MathML.Rendering.WinGraphicsRenderer _mmlRendering, Graphics gr)
    {
     

      if (stb.Length == 0)
        stb.Append(textheader);

      int currpos = 0;
      for (; ; )
      {
        int startidx = rawtext.IndexOf("<math>", currpos);
        if (startidx < 0)
          break;
        int endidx = rawtext.IndexOf("</math>", startidx);
        if (endidx < 0)
          break;
        endidx += "</math>".Length;

        // all text from currpos to startidx-1 can be copyied to the stringbuilder
        stb.Append(rawtext, currpos, startidx - currpos);

        // all text from startidx to endidx-1 must be loaded into the control and rendered
        System.IO.StringReader rd = new StringReader(rawtext.Substring(startidx, endidx - startidx));
        MathML.MathMLDocument doc = new MathML.MathMLDocument();
        doc.Load(rd);
        rd.Close();
        _mmlRendering.SetMathElement((MathML.MathMLMathElement)doc.DocumentElement);

        System.Drawing.Image mf = _mmlRendering.GetImage(typeof(Bitmap),gr);
        GraphicsUnit unit = GraphicsUnit.Point;
        RectangleF rect = mf.GetBounds(ref unit);
        string imagetext = GetRtfImage(mf);
        stb.Append(imageheader);
        stb.Append(@"\picwgoal" + Math.Ceiling(15 * rect.Width).ToString());
        stb.Append(@"\pichgoal" + Math.Ceiling(15 * rect.Height).ToString());
        stb.Append(" ");
        stb.Append(imagetext);
        stb.Append(imagetrailer);

        currpos = endidx;
      }

      stb.Append(rawtext, currpos, rawtext.Length - currpos);
    }
Пример #6
0
 internal static HandleRef getCPtr(MathML obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }