Exemplo n.º 1
0
        private void miRestoreDefaultMachineList_Click(object sender, EventArgs e)
        {
            // load the default machine data
            _machines = MachineParameters.BuildDefaultMachineList();
            // create a custom machine
            MachineParameters custom = new MachineParameters("Custom", 50, 29, 12);

            // add it to the list
            _machines.Add(custom);
            // 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;
            // flag that the machines have been changed
            _machinesChanged = true;
        }
Exemplo n.º 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();
        }