Exemplo n.º 1
0
        private void Load_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == true)
            {
                IFormatter formatter = new BinaryFormatter();
                Stream     stream    = null;
                try
                {
                    stream = new FileStream(openFileDialog.FileName, FileMode.Open, FileAccess.Read);
                    Tuple <List <SimpleFunction>, List <AlgorithmParameters> > lists = (Tuple <List <SimpleFunction>, List <AlgorithmParameters> >)formatter.Deserialize(stream);
                    evaluatedFunctionsList.AddRange(SimpleFunction.ConvertToListOfEvaluatedFunction(lists.Item1));
                    algorithmParametersList.AddRange(lists.Item2);
                    stream.Close();
                }
                catch (FileNotFoundException)
                {
                    Debug.WriteLine("FileNotFound");
                }
                catch (SerializationException)
                {
                    Debug.WriteLine("SerializationException");
                    stream.Close();
                }
                AlgorithmGrid.Items.Refresh();
                FunctionGrid.Items.Refresh();
            }
        }
Exemplo n.º 2
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            if (saveFileDialog.ShowDialog() == true)
            {
                IFormatter formatter = new BinaryFormatter();
                Stream     stream    = new FileStream(saveFileDialog.FileName, FileMode.Create, FileAccess.Write);
                formatter.Serialize(stream, new Tuple <List <SimpleFunction>, List <AlgorithmParameters> >(SimpleFunction.ListFromEvaluatedFunction(evaluatedFunctionsList), algorithmParametersList));
                stream.Close();
            }
        }