/// <summary>
 /// Spawns a GUI that lets the user define a rule, then adds it to the list 
 /// </summary>
 private void addRule(object sender, EventArgs e)
 {
     // This approach technically creates a blank rule in the list, then changes its reference to
     // the rule returned from the RuleBuilderGUI
     using (var ruleForm = new RuleBuilderGUI())
     {
         ruleForm.ShowDialog();
         if (ruleForm.Rule != null)
         {
             RulesListbox.Items.Add(new object());
             RulesListbox.Items[RulesListbox.Items.Count - 1] = ruleForm.Rule;
         }
         updateLED();
     }
 }
 /// <summary>
 /// Lets you modify the selected rule
 /// </summary>
 private void RulesListbox_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     int index = this.RulesListbox.IndexFromPoint(e.Location);
     if (index != System.Windows.Forms.ListBox.NoMatches)
     {
         Rule selectedRule = (Rule)RulesListbox.Items[index];
         using (var ruleForm = new RuleBuilderGUI(selectedRule))
         {
             ruleForm.ShowDialog();
             RulesListbox.Items[index] = ruleForm.Rule;
         }
     }
 }