Ejemplo n.º 1
0
        /// <summary>
        /// Add Step Button Function.
        /// </summary>
        private void addSBtn_Click(object sender, EventArgs e)
        {
            if (!Program.running)
            {
                if (stepsList.SelectedNode == null)
                {
                    stepsList.SelectedNode = stepsList.Nodes["Root"];
                }
                addStepDlg addstep = new addStepDlg();
                addstep.ShowDialog();
                if (Program.OKbtn)
                {
                    float temperature, duration;
                    float.TryParse(Program.stepTemperature, out temperature);
                    float.TryParse(Program.stepDuration, out duration);

                    TreeNode newStep = new TreeNode("Temperature: " + Program.stepTemperature + " °C, Duration: " + Program.stepDuration + " s");
                    newStep.Tag = new List <float> {
                        temperature, duration
                    };

                    if (stepsList.SelectedNode.Name == "Root")
                    {
                        newStep.Name = "step-" + stepsList.SelectedNode.GetNodeCount(false);
                        stepsList.SelectedNode.Nodes.Add(newStep);
                        stepsList.SelectedNode.Expand();
                    }
                    else if (stepsList.SelectedNode.Text.Contains("Cycle Name"))
                    {
                        newStep.Name = stepsList.SelectedNode.Name + "-step-" + stepsList.SelectedNode.GetNodeCount(false);
                        stepsList.SelectedNode.Nodes.Add(newStep);
                        stepsList.SelectedNode.Expand();
                    }
                    else
                    {
                        stepsList.SelectedNode.Parent.Nodes.Insert(stepsList.SelectedNode.Index + 1, newStep);
                        stepsList.SelectedNode.Parent.Expand();
                    }
                }
            }
            else
            {
                MessageBox.Show("Can't add steps while program is running.");
            }
        }
Ejemplo n.º 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");
     }
 }