Exemple #1
0
 public void SaveSchedule(PCRSchedule schedule)
 {
     if (this.FileName == String.Empty)
     {
         SaveScheduleAs(schedule);
     }
     else
     {
         String scheduleToSave = JsonConvert.SerializeObject(schedule);
         File.WriteAllText(this.FileName, scheduleToSave);
     }
 }
        public PCRControllerVM()
        {
            Schedule   = new PCRSchedule();
            Serializer = new ScheduleSerializer();
            Serializer.OnNewScheduleLoaded += Serializer_OnNewScheduleLoaded;
            _savePcrSchedule     = new RelayCommand(param => Serializer.SaveSchedule(Schedule));
            _savePcrScheduleAs   = new RelayCommand(param => Serializer.SaveScheduleAs(Schedule));
            _loadPcrSchedule     = new RelayCommand(param => Serializer.LoadSchedule());
            _startStopExperiment = new RelayCommand(param => Device.StartStopExperiment(Experiment.ExperimentRunning));
            _connectToComPort    = new RelayCommand(param => Device.ConnectToDevice());

            Device = new PCRDevice();
            Device.OnDeviceConnected      += Device_OnDeviceConnected;
            Device.OnDeviceDisconnected   += Device_OnDeviceDisconnected;
            Device.OnExperimentStarted    += Device_OnExperimentStarted;
            Device.OnExperimentTerminated += Device_OnExperimentTerminated;
            Experiment        = new ExperimentStatus();
            ComPortDevices    = SerialPort.GetPortNames().ToList <String>();
            ComPortSelected   = false;
            ConnectButtonText = "Connect";
            ConnectionStatus  = Device.ConnectionMessage;
        }
Exemple #3
0
        public void SaveScheduleAs(PCRSchedule schedule)
        {
            // Configure save file dialog box
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.FileName   = "PcrExperiment";                 // Default file name
            dlg.DefaultExt = ".json";                         // Default file extension
            dlg.Filter     = "Text documents (.json)|*.json"; // Filter files by extension

            // Show save file dialog box
            Nullable <bool> result = dlg.ShowDialog();

            // Process save file dialog box results
            if (result == true)
            {
                // Save document
                this.FileName     = dlg.FileName;
                this.LastFilePath = Path.GetFileName(this.FileName);
                String scheduleToSave = JsonConvert.SerializeObject(schedule);
                File.WriteAllText(this.FileName, scheduleToSave);
            }
            //Else user probably hit cancel
        }
 private void Serializer_OnNewScheduleLoaded(object sender, EventArgs e)
 {
     if (sender is ScheduleSerializer)
     {
         Serializer = (ScheduleSerializer)sender;
         PCRSchedule schedule = Serializer.LoadedSchedule;
         InitializationTemp     = schedule.Initialization.Temperature;
         InitializationDuration = schedule.Initialization.Duration;
         DenaturationTemp       = schedule.Denaturation.Temperature;
         DenaturationDuration   = schedule.Denaturation.Duration;
         AnnealingTemp          = schedule.Annealing.Temperature;
         AnnealingDuration      = schedule.Annealing.Duration;
         ElongationTemp         = schedule.Elongation.Temperature;
         ElongationDuration     = schedule.Elongation.Duration;
         FinalHoldTemp          = schedule.FinalHold.Temperature;
         FinalHoldDuration      = schedule.FinalHold.Duration;
         PcrIterations          = schedule.NumberOfIterations;
     }
     else
     {
         throw new Exception();
     }
 }
Exemple #5
0
        public void LoadSchedule()
        {
            Microsoft.Win32.FileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.Filter = "json file (*.json)|*.json";
            if (this.FileName != String.Empty)
            {
                dlg.InitialDirectory = this.FileName;
            }
            Nullable <bool> result = dlg.ShowDialog();

            // Process load file dialog box results
            if (result == true)
            {
                this.FileName     = dlg.FileName;
                this.LastFilePath = Path.GetFileName(this.FileName);
                //Load document
                String json = File.ReadAllText(this.FileName);
                this.LoadedSchedule = JsonConvert.DeserializeObject <PCRSchedule>(json);
                OnNewScheduleLoaded(this, EventArgs.Empty);
                this.LoadedSchedule = null;
            }
            //Else user probably hit cancel
        }