Exemple #1
0
 private void miLoadMachineList_Click(object sender, EventArgs e)
 {
     // execute the open file dialog
     if (ofd.ShowDialog() == DialogResult.OK)
     {
         try
         {
             // load the database
             List <MachineParameters> machines = MachineParameters.ReadMachineParametersFromFile(ofd.FileName);
             // save the new machines
             _machines = machines;
             // clear the combo box
             cbMachines.Items.Clear();
             // add the machines to the combo box
             foreach (MachineParameters machine in _machines)
             {
                 cbMachines.Items.Add(machine.Name);
             }
             // select the first
             cbMachines.SelectedIndex = 0;
         }
         catch (Exception ex)
         {
             // display a hint
             MessageBox.Show("Error loading machine database: " + ex.Message, "Error loading file!");
         }
     }
 }
Exemple #2
0
        private void fMain_Load(object sender, EventArgs e)
        {
            // the filename for our settings file
            _machinesConfigFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "cmbTea\\MachineParameters.machinedb");
            // try to load it
            _machines = MachineParameters.ReadMachineParametersFromFile(_machinesConfigFile);
            // if it fails, build the default list
            if (_machines == null)
            {
                _machines = MachineParameters.BuildDefaultMachineList();
                // and save it
                try
                {
                    // write the file
                    MachineParameters.WriteMachineParametersToFile(_machines, _machinesConfigFile);
                }
                catch (Exception ex)
                {
                    // something went wrong
                    MessageBox.Show("Error writing " + _machinesConfigFile + ". Error message is: " + ex.Message, "Error", MessageBoxButtons.OK);
                }
            }
            // create a custom machine
            MachineParameters custom = new MachineParameters("Custom", 50, 29, 12);

            // add it to the list
            _machines.Add(custom);
            // add the machines to the combo box
            foreach (MachineParameters machine in _machines)
            {
                cbMachines.Items.Add(machine.Name);
            }
            // load defaults
            cbMachines.SelectedIndex    = Properties.Settings.Default.SelectedMachineIndex;
            txtWheelDiameter.Text       = Properties.Settings.Default.WheelDiameter.ToString("0.0");
            txtJigProjectionLength.Text = Properties.Settings.Default.JigProjectionLength.ToString("0.0");
            txtTargetAngle.Text         = Properties.Settings.Default.TargetAngle.ToString("0.0");
            // calculate it
            Calculate();
        }