コード例 #1
0
        private void openFile(string fileName)
        {
            Stream                   stream    = new FileStream(fileName, FileMode.Open);
            BinaryFormatter          formatter = new BinaryFormatter();
            ExperimentSerializedData esd       = (ExperimentSerializedData)formatter.Deserialize(stream);

            criticalityVariations = new CriticalityVariations(esd.criticalityVariations);
            precursors            = new Precursors(esd.precursors);
            stream.Close();
            stream.Dispose();
            reactor = new Reactor(criticalityVariations, precursors);
            UpdateDataGridViewPrecursors(precursors);
            Display();
            buttonCalculatePopulations.Visible = false;
        }
コード例 #2
0
 private void save()
 {
     if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         /* System.IO.StreamReader sr = new
          *  System.IO.StreamReader(openFileDialog1.FileName);
          * MessageBox.Show(sr.ReadToEnd());
          * sr.Close(); */
         ExperimentSerializedData esd       = new ExperimentSerializedData(criticalityVariations, precursors);
         BinaryFormatter          formatter = new BinaryFormatter();
         Stream stream = new FileStream(saveFileDialog.FileName, FileMode.Create);
         try
         {
             formatter.Serialize(stream, esd);
             saved = true;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex + " File could not be saved. Please Retry.");
         }
         stream.Close();
         stream.Dispose();
     }
 }