示例#1
0
        /// <summary>
        /// Called when the application is closing
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (LoggingEnabled)
            {
                LoggingEnabled = false;
                Thread.Sleep(1000);
            }

            try
            {
                File.WriteAllText(Constants.CalibrationFile, SerDes.Serialize(CalData));
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was a problem writing the calibration data: " + ex.Message);
            }

            try
            {
                File.WriteAllText(Constants.SettingsFile, SerDes.Serialize(AppSettings));
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was a problem writing the settings data: " + ex.Message);
            }

            Hardware.Close();
        }
示例#2
0
        private void Form1_Load(object sender, EventArgs e)
        {
#if !DEBUG
            flashVirginDeviceToolStripMenuItem.Visible = false;
#endif
            statusStrip1.Items.Add("");
            statusStrip1.Items.Add("");

            if (File.Exists(Constants.SettingsFile))
            {
                // There's a settings file here. See if we can load it
                try
                {
                    AppSettings = (Settings)SerDes.Deserialize(typeof(Settings), File.ReadAllText(Constants.SettingsFile));
                }
                catch (Exception ex)
                {
                    // Something went wrong. Delete it.
                    MessageBox.Show(string.Format("There was a problem loading your settings from: {0}. The exception was: {1}", Constants.SettingsFile, ex.Message));
                    File.Delete(Constants.SettingsFile);
                }
            }

            // Never want this to persist. Too confusing
            AppSettings.Math      = 1.0;
            AppSettings.MathLabel = "";
            label12.Visible       = false;

            // If needed directories aren't present, create them
            if (Directory.Exists(Constants.DataFilePath) == false)
            {
                Directory.CreateDirectory(Constants.DataFilePath);
            }

            // Check if cal data exists and use it if it does
            if (File.Exists(Constants.CalibrationFile))
            {
                CalData = (CalibrationClass)SerDes.Deserialize(typeof(CalibrationClass), File.ReadAllText(Constants.CalibrationFile));
            }
            else
            {
                MessageBox.Show("A calibration file could not be loaded. A default file will be created");
                CalData = new CalibrationClass();
            }

            // Check if the user has calibrated the device yet
            if (CalData.IsDefault)
            {
                UncalLabel.Text = "UNCALIBRATED";
            }
            else
            {
                UncalLabel.Text = "";
            }

            // Indicate we are NOT in relative mode by hiding the label
            RelModeLabel.Visible = false;
            LoggingLabel.Visible = false;

            //Label_2p5sps.Visible = true;
            //Label_1ksps.Visible = false;
            //SampleRate = SampleRateEnum.Slow_2p5Hz;
            DcBtn_Pressed(null, null);

            LoadFontData();

            InitGraphs();

            Text += "  (" + Constants.Version.ToString("0.000") + ")";

            // Not ready yet
            analysisToolStripMenuItem.Visible = false;

            LEDKickerTimer.Enabled = true;
            TryConnect();

            SetTempStatus(int.MaxValue);
        }