Ejemplo n.º 1
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++;
     }
 }
Ejemplo n.º 2
0
 private void btnDelayInstruction_Click(object sender, EventArgs e)
 {
     int DelayTime = 0;
     try
     {
         DelayTime = Convert.ToInt32(txtDelayMinutes.Text);
         if (DelayTime <= 0) { throw new Exception(); }
     }
     catch { MessageBox.Show("The delay time you entered is not valid", "Invalid time", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; }
     ListBoxDelayItem newDelay = new ListBoxDelayItem();
     newDelay.delay.minutes = DelayTime;
     newDelay.InstructionNumber = GetNextInstructionNumber();
     lstProtocol.Items.Add(newDelay);
 }