コード例 #1
0
 public void OnFunctionChanged(InputFunction Func)
 {
     if (Func == SelectedFunction)
     {
         Owner.BuildPlot();
     }
 }
コード例 #2
0
        private void Button_ClickLoad(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
            openFileDialog.Title  = "Load Function";

            InputFunction InFunction = (InputFunction)Data.SelectedFunction;

            try
            {
                if (openFileDialog.ShowDialog() == true)
                {
                    using (StreamReader Reader = new StreamReader(openFileDialog.FileName))
                    {
                        NumberFormatInfo NFI = new NumberFormatInfo();
                        NFI.NumberDecimalSeparator = ".";

                        uint N = uint.Parse(Reader.ReadLine());
                        InFunction.FileData = new FunctionData(N);

                        for (int i = 0; i < N; ++i)
                        {
                            string[] TX = Reader.ReadLine().Split(' ');
                            double   T  = double.Parse(TX[0], NFI);
                            double   X  = double.Parse(TX[1], NFI);

                            if (T < 0 || (i > 0 && T <= InFunction.FileData.T[i - 1]))
                            {
                                throw new Exception();
                            }

                            InFunction.FileData.T[i] = T;
                            InFunction.FileData.X[i] = X;
                        }
                    }

                    InFunction.UseFile = true;
                }
            }
            catch
            {
                InFunction.FileData = new FunctionData();
                Data.LogString("Error when loading function!");
            }
        }