Exemple #1
0
        /// <summary>
        /// Add Cycle Button Function.
        /// </summary>
        private void addCBtn_Click(object sender, EventArgs e)
        {
            if (!Program.running)
            {
                if (stepsList.SelectedNode == null)
                {
                    stepsList.SelectedNode = stepsList.Nodes["Root"];
                }
                addCycleDlg addCycle = new addCycleDlg();
                addCycle.ShowDialog();
                if (Program.OKbtn)
                {
                    int repetitions;
                    int.TryParse(Program.cycleReps, out repetitions);

                    TreeNode newCycle = new TreeNode("Cycle Name: " + Program.cycleName + ", Repetitions: " + Program.cycleReps);
                    newCycle.Tag = repetitions;

                    if (stepsList.SelectedNode.Name == "Root")
                    {
                        stepsList.SelectedNode.Nodes.Add(newCycle);
                        stepsList.SelectedNode.Expand();
                    }
                    else if (stepsList.SelectedNode.Text.Contains("Temperature"))
                    {
                        stepsList.SelectedNode.Parent.Nodes.Insert(stepsList.SelectedNode.Index + 1, newCycle);
                    }
                }
            }
            else
            {
                MessageBox.Show("Can't add cycle while program is running");
            }
        }
Exemple #2
0
 /// <summary>
 /// Edit Selected Element Button Function.
 /// </summary>
 private void editSelectedBtn_Click(object sender, EventArgs e)
 {
     if (!Program.running)
     {
         if (stepsList.SelectedNode == null)
         {
             MessageBox.Show("Select an element to edit");
         }
         else if (stepsList.SelectedNode.Text.Contains("Temperature"))
         {
             addStepDlg addstep = new addStepDlg();
             addstep.Text = "Editing Step";
             addstep.ShowDialog();
             if (Program.OKbtn)
             {
                 float temperature, duration;
                 float.TryParse(Program.stepTemperature, out temperature);
                 float.TryParse(Program.stepDuration, out duration);
                 stepsList.SelectedNode.Text = "Temperature: " + Program.stepTemperature + " °C, Duration: " + Program.stepDuration + " s";
                 stepsList.Tag = new List <float> {
                     temperature, duration
                 };
             }
         }
         else
         {
             addCycleDlg addCycle = new addCycleDlg();
             addCycle.Text = "Editing Cycle";
             addCycle.ShowDialog();
             if (Program.OKbtn)
             {
                 int repetitions;
                 int.TryParse(Program.cycleReps, out repetitions);
                 stepsList.SelectedNode.Text = "Cycle Name: " + Program.cycleName + ", Repetitions: " + Program.cycleReps;
                 stepsList.Tag = repetitions;
             }
         }
     }
     else
     {
         MessageBox.Show("Can't edit step while program is running");
     }
 }