private void OpenToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            var fileContent = string.Empty;
            var filePath    = string.Empty;

            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.InitialDirectory = "c:\\";
                openFileDialog.Filter           = "xml files (*.xml)|*.xml|All files (*.*)|*.*";
                openFileDialog.FilterIndex      = 2;
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    //Get the path of specified file
                    filePath = openFileDialog.FileName;

                    //Read the contents of the file into a stream
                    var fileStream = openFileDialog.OpenFile();

                    XmlDictionaryReader reader =
                        XmlDictionaryReader.CreateTextReader(fileStream, new XmlDictionaryReaderQuotas());
                    DataContractSerializer ser = new DataContractSerializer(typeof(ChemHazardViewModel));

                    // Deserialize the data and read it from the instance.
                    ChemHazardViewModel diskVM =
                        (ChemHazardViewModel)ser.ReadObject(reader, true);
                    reader.Close();

                    fileStream.Close();

                    // update the View Model with the values from disk.
                    // We do it this way to trigger property change notifications
                    // so the UI is updated with the values.
                    vm.AgentName         = diskVM.AgentName;
                    vm.WeaponName        = diskVM.WeaponName;
                    vm.ICT50Dosage       = diskVM.ICT50Dosage;
                    vm.LCT50Dosage       = diskVM.LCT50Dosage;
                    vm.ThresholdDosage   = diskVM.ThresholdDosage;
                    vm.Qkg               = diskVM.Qkg;
                    vm.UKts              = diskVM.UKts;
                    vm.Tst               = diskVM.Tst;
                    vm.Psc               = diskVM.Psc;
                    vm.CalculatedPattern = diskVM.CalculatedPattern;
                }
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            AtmosphericStability.DataSource = Enum.GetValues(typeof(AdvancedATP45.ChemHazard.PasquillStabilityCategory));

            vm = new ChemHazardViewModel();

            // set up the form data bindings to the view model
            AtmosphericStability.DataBindings.Add(new Binding("SelectedItem", vm, "Psc", true,
                                                              DataSourceUpdateMode.OnPropertyChanged));

            TSTButtonLand.DataBindings.Add(new Binding("Checked", vm, "TstButtonLand", true,
                                                       DataSourceUpdateMode.OnPropertyChanged));

            TSTButtonSea.DataBindings.Add(new Binding("Checked", vm, "TstButtonSea", true,
                                                      DataSourceUpdateMode.OnPropertyChanged));

            MphKphLabel.DataBindings.Add(new Binding("Text", vm, "MphKphLabelString", true,
                                                     DataSourceUpdateMode.OnPropertyChanged));

            WindspeedUpDown.DataBindings.Add(new Binding("Value", vm, "UKts", true,
                                                         DataSourceUpdateMode.OnPropertyChanged));

            WeaponNameTextbox.DataBindings.Add(new Binding("Text", vm, "WeaponName", true,
                                                           DataSourceUpdateMode.OnPropertyChanged));

            AgentNameTextbox.DataBindings.Add(new Binding("Text", vm, "AgentName", true,
                                                          DataSourceUpdateMode.OnPropertyChanged));

            FillWeightUpDown.DataBindings.Add(new Binding("Value", vm, "Qkg", true,
                                                          DataSourceUpdateMode.OnPropertyChanged));

            ThresholdUpDown.DataBindings.Add(new Binding("Value", vm, "ThresholdDosage", true,
                                                         DataSourceUpdateMode.OnPropertyChanged));

            ICT50UpDown.DataBindings.Add(new Binding("Value", vm, "ICT50Dosage", true,
                                                     DataSourceUpdateMode.OnPropertyChanged));

            LCT50UpDown.DataBindings.Add(new Binding("Value", vm, "LCT50Dosage", true,
                                                     DataSourceUpdateMode.OnPropertyChanged));

            CalculateButton.DataBindings.Add(new Binding("Enabled", vm, "EnableCalculate", true,
                                                         DataSourceUpdateMode.OnPropertyChanged));

            ClearButton.Enabled = true;
        }