예제 #1
0
 void ResetParent()
 {
     if (RuleLibrary.GetRuleByName(selectedRule.parentRule) == null)
     {
         parentRule.SelectedItem = noParent;
     }
     else
     {
         parentRule.SelectedItem = selectedRule.parentRule;
     }
 }
예제 #2
0
 private void ParentRule_SelectedIndexChanged(object s, EventArgs e)
 {
     if (selectedRule != null)
     {
         Rule checkedRule = RuleLibrary.GetRuleByName(parentRule.Text);
         while (checkedRule != null)
         {
             checkedRule = RuleLibrary.GetRuleByName(checkedRule.parentRule);
             if (checkedRule == selectedRule)
             {
                 MessageBox.Show("Loops are not allowed in the parent rule chain.");
                 ResetParent();
                 return;
             }
         }
         selectedRule.parentRule = !parentRule.Text.Equals(noParent) ? parentRule.Text : null;
     }
 }
예제 #3
0
 public RuleEditor()
 {
     InitializeComponent();
     defaultFieldColor = ruleName.BackColor;
     targetRoom.Items.Add(new RoomListItem(null));
     targetRoom.Items.Add(new RoomListItem(AllLobbies.Instance));
     Room.ForEach(room => targetRoom.Items.Add(new RoomListItem(room)));
     targetRoom.SelectedIndex = 0;
     PropertyInfo[] properties = typeof(SensorData).GetProperties();
     foreach (PropertyInfo property in properties)
     {
         if (property.PropertyType == typeof(bool) || property.PropertyType == typeof(float))
         {
             targetProperty.Items.Add(new PropertyInfoListItem(property));
         }
     }
     targetProperty.SelectedIndex = 0;
     RuleLibrary.LoadRules();
     UpdateRuleList();
     ruleList.SelectedIndex = 0;
 }
예제 #4
0
 void RuleEditor_FormClosing(object s, FormClosingEventArgs e) => RuleLibrary.SaveRules();