コード例 #1
0
        private async Task <string> TutorResult(string Method, string RawMatrix)
        {
            MathMLBuilder MathBuilder = default;
            var           engine      = new MapleLinearAlgebra(DefaultPath);

            if (RawMatrix.EndsWith(";"))
            {
                RawMatrix = RawMatrix.Remove(RawMatrix.Length - 1, 1).Replace("\r\n", string.Empty);
            }

            engine.Open();
            var minified = await engine.LPrint(RawMatrix);

            minified = minified.Replace("\r\n", "");

            MapleMatrix matrix = default;

            try
            {
                matrix = new MapleMatrix(minified);
            }
            catch (ArgumentException)
            {
                MessageBox.Show("Matrix kunne ikke fortolkes. Vær sikker på du har kopieret fra maple");
                engine.Close();
                return(default);
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: rasm586c/BasisMat2
        public MainWindow()
        {
            InitializeComponent();
            UpdateMaplePath();



            //mathBrowser.Navigate(new Uri(@"file:///C:/Users/Rsoeb/source/repos/BasisMat2/BasisMat2/bin/Debug/MathML/Index.html"));

            #region Test (Kan blive slettet NP)
            MathMLBuilder MathBuilder = default;

            btnTest.Click += (s, e) => {
                var engine = new MapleLinearAlgebra(Settings.Default.Path);


                /*
                 * var matrix = new MapleMatrix(new string[][]
                 *  {
                 *      new string[] {   "a",      "2",     "3"    },
                 *      new string[] {   "1",     "-4",   "-19"    },
                 *      new string[] {  "-1",      "3",    "14"    }
                 *  });
                 */

                btnCopy.IsEnabled = false;
                btnTest.IsEnabled = false;
                btnTest.Content   = "Udregner...";

                var gaussMatrixRaw = txtGaussMatrix.Text.Trim();
                if (gaussMatrixRaw.EndsWith(";"))
                {
                    gaussMatrixRaw = gaussMatrixRaw.Remove(gaussMatrixRaw.Length - 1, 1);
                }

                Task.Run(async() => {
                    engine.Open();

                    var minified = await engine.LPrint(gaussMatrixRaw);
                    minified     = minified.Replace("\r\n", "");

                    MapleMatrix matrix = default;

                    try
                    {
                        matrix = new MapleMatrix(minified);
                    } catch (ArgumentException) {
                        MessageBox.Show("Matrix kunne ikke fortolkes. Vær sikker på du har kopieret fra maple");
                        rtOutput.Dispatcher.Invoke(() => {
                            btnTest.Content   = "Udregn Matrix";
                            btnTest.IsEnabled = true;
                        });
                        engine.Close();
                        return;
                    }

                    var TutorResult = await JavaWin.JavaMapletInteractor.GaussJordanEliminationTutor(engine, matrix);
                    engine.Close();

                    MathBuilder = new MathMLBuilder(TutorResult.MathML);
                    MathBuilder.AddText("\nOpskriver Ligninger:\n");

                    var MapleML = new MapleMathML(Settings.Default.Path);
                    MapleML.Open();

                    var ML_Test = await MapleML.Export("Matrix(3, 3, [[-2, 5, -7], [3, -4, 7], [3, -5, 8]])^2 = (Matrix(3, 3, [[-2, 5, -7], [3, -4, 7], [3, -5, 8]])) . (Matrix(3, 3, [[-2, 5, -7], [3, -4, 7], [3, -5, 8]]))");
                    MathBuilder.MergeML(ML_Test);

                    var ML_Console = await MapleML.Import(MathBuilder.ToString());

                    rtOutput.Dispatcher.Invoke(() => {
                        rtOutput.Document.Blocks.Clear();
                        //rtOutput.AppendText(string.Join("\n", TutorResult.OperationsDa));
                        rtOutput.AppendText(ML_Console);

                        btnTest.Content   = "Udregn Matrix";
                        btnTest.IsEnabled = true;
                    });

                    MapleML.Close();
                });
            };
            #endregion

            btnCopy.Click += (s, e) => {
                Clipboard.SetText(MathBuilder.ToString());
                btnCopy.IsEnabled = false;
                btnCopy.Content   = "Kopieret";

                Task.Run(async() => {
                    await Task.Delay(3000);
                    btnCopy.Dispatcher.Invoke(() => {
                        btnCopy.IsEnabled = true;
                        btnCopy.Content   = "Kopier (Maple)";
                    });
                });
            };
        }