Exemplo n.º 1
0
        // move selected program item one position up
        private void buttonProgramUp_Click(object sender, RoutedEventArgs e) // n
        {
            int index = listBoxProgram.SelectedIndex;

            if (index >= 1)
            {
                ProgramItem temp = load.ProgramItems[index];
                load.ProgramItems.RemoveAt(index);
                load.ProgramItems.Insert(index - 1, temp);
                listBoxProgram.SelectedIndex = index - 1;
            }
        }
Exemplo n.º 2
0
        // move selected program item one position down
        private void buttonProgramDown_Click(object sender, RoutedEventArgs e) // n
        {
            int index = listBoxProgram.SelectedIndex;

            if ((index >= 0) && (index < load.ProgramItems.Count - 1))
            {
                ProgramItem temp = load.ProgramItems[index];
                load.ProgramItems.RemoveAt(index);
                load.ProgramItems.Insert(index + 1, temp);
                listBoxProgram.SelectedIndex = index + 1;
            }
        }
Exemplo n.º 3
0
        // add new program item (or skip currently executed item)
        private void buttonProgramAdd_Click(object sender, RoutedEventArgs e)
        {
            if (this.load.IsManual) // adds new program item (Add button)
            {
                ProgramItem programItem;
                try
                {
                    double?initialValue = null;
                    if (tabControlProgram.SelectedItem == tabItemProgramConstant) // adds constant program item
                    {
                        if (checkBoxProgramConstantPrevious.IsChecked == false)   // use previously measured value as the starting point if true, parse text box if false
                        {
                            initialValue = Double.Parse(textBoxProgramConstantValue.Text);
                        }

                        if (checkBoxProgramConstantSkip.IsChecked == true) // skip conditions apply
                        {
                            programItem = new ProgramItem((Modes)(comboBoxProgramConstantQuantity.SelectedIndex), initialValue, textBoxProgramConstantDuration.Text, (TimeUnits)(comboBoxProgramConstantUnit.SelectedIndex), (Modes)(comboBoxProgramConstantSkipQuantity.SelectedIndex), (Comparison)(comboBoxProgramConstantSkipComparator.SelectedIndex), Double.Parse(textBoxProgramConstantSkipValue.Text));
                        }
                        else
                        {
                            programItem = new ProgramItem((Modes)(comboBoxProgramConstantQuantity.SelectedIndex), initialValue, textBoxProgramConstantDuration.Text, (TimeUnits)(comboBoxProgramConstantUnit.SelectedIndex));
                        }
                    }
                    else // adds ramp program item
                    {
                        if (checkBoxProgramRampPrevious.IsChecked == false) // use previously measured value as the starting point if true, parse text box if false
                        {
                            initialValue = Double.Parse(textBoxProgramRampInitialValue.Text);
                        }

                        if (checkBoxProgramRampSkip.IsChecked == true) // skip conditions apply
                        {
                            programItem = new ProgramItem((Modes)(comboBoxProgramRampQuantity.SelectedIndex), initialValue, Double.Parse(textBoxProgramRampFinalValue.Text), textBoxProgramRampDuration.Text, (TimeUnits)(comboBoxProgramRampDurationUnit.SelectedIndex), (Modes)(comboBoxProgramRampSkipQuantity.SelectedIndex), (Comparison)(comboBoxProgramRampSkipComparator.SelectedIndex), Double.Parse(textBoxProgramRampSkipValue.Text));
                        }
                        else
                        {
                            programItem = new ProgramItem((Modes)(comboBoxProgramRampQuantity.SelectedIndex), initialValue, Double.Parse(textBoxProgramRampFinalValue.Text), textBoxProgramRampDuration.Text, (TimeUnits)(comboBoxProgramRampDurationUnit.SelectedIndex));
                        }
                    }
                    load.ProgramItems.Add(programItem); // add to program item list
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else  // skips current program item (Skip button)
            {
                this.load.Skip();
            }
        }