示例#1
0
        private void LoadTableFromXML()
        {
            OpenFileDialog openDlg = new OpenFileDialog();

            openDlg.Filter = "XML | *.xml";

            if (openDlg.ShowDialog() == true)
            {
                try
                {
                    Lp = LagrangePolynom.ReadFromXML(openDlg.FileName);
                }
                catch (InvalidOperationException)
                {
                    MessageBox.Show("Invalid XML file!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                Gx            = new ExprTree.Expression(Lp.ToString(), "x");
                this.FileName = openDlg.FileName;

                //show the values in the point grid
                pointsDt.Clear();
                foreach (Point p in Lp.GetPointCollection())
                {
                    DataRow newRow = pointsDt.NewRow();
                    newRow["X"] = p.X;
                    newRow["Y"] = p.Y;
                    pointsDt.Rows.Add(newRow);
                }
                pointGrid.DataContext = pointsDt;
                pointGrid.UpdateLayout();
            }
        }
示例#2
0
 private void ButtonPolynomShow_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         MessageBox.Show(Lp.ToString());
     }
     catch
     {
         MessageBox.Show("You have to load interpolation points table first!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }