Exemple #1
0
 private void btnAddInstruction_Click(object sender, EventArgs e)
 {
     int LoopStart = 0;
     int LoopCount = 0;
     try
     {
         LoopStart = Convert.ToInt32(txtLoopStart.Text);
         if (LoopStart > lstProtocol.Items.Count)
         {
             MessageBox.Show("You cannot start a loop at an instruction number that does not exist", "Bad entry", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
     }
     catch { MessageBox.Show("You did not enter a valid instruction number to start at", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
     try
     {
         LoopCount = Convert.ToInt32(txtNumberOfLoops.Text);
     }
     catch { MessageBox.Show("You did not enter a valid number of loops", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
     ListBoxRepeatItem NewLoop = new ListBoxRepeatItem();
     NewLoop.RepeatInstruction.StartInstruction = LoopStart;
     NewLoop.RefToActualInstruction = (ListBoxProtocolItem)lstProtocol.Items[LoopStart - 1];
     NewLoop.RepeatInstruction.TimesToRepeat = LoopCount;
     NewLoop.InstructionNumber = GetNextInstructionNumber();
     lstProtocol.Items.Add(NewLoop);
 }
Exemple #2
0
 public static void ProtocolItemsToListBoxProtocolItems(List<ProtocolInstruction> Instructions, System.Windows.Forms.ListBox ListBoxToFill, bool AddToCurrent)
 {
     int index = 1;
     if (AddToCurrent)
     {
         index = ListBoxToFill.Items.Count + 1;
     }
     foreach (ProtocolInstruction Instruction in Instructions)
     {
         if (Instruction is StaticProtocolItem)
         {
             ListBoxProtocolItem inst = new ListBoxProtocolItem();
             inst.InstructionNumber = index;
             inst.Instruction = (StaticProtocolItem)Instruction;
             ListBoxToFill.Items.Add(inst);
         }
         else if (Instruction is LoopInstruction)
         {
             ListBoxRepeatItem rep = new ListBoxRepeatItem();
             rep.InstructionNumber = index;
             rep.RepeatInstruction = (LoopInstruction)Instruction;
             ListBoxToFill.Items.Add(rep);
         }
         else if (Instruction is DelayTime)
         {
             ListBoxDelayItem del = new ListBoxDelayItem();
             del.delay = (DelayTime)Instruction;
             del.InstructionNumber = index;
             ListBoxToFill.Items.Add(del);
         }
         index++;
     }
 }