void ResetParent() { if (RuleLibrary.GetRuleByName(selectedRule.parentRule) == null) { parentRule.SelectedItem = noParent; } else { parentRule.SelectedItem = selectedRule.parentRule; } }
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; } }
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; }
void RuleEditor_FormClosing(object s, FormClosingEventArgs e) => RuleLibrary.SaveRules();