/// <summary> /// Create Event Handlers and attach to the Rule Collection /// </summary> /// <param name="ruleCollection"></param> public void RegisterRuleList(PDB holder, RuleList ruleCollection) { this._rule_holder = holder; this._rules = ruleCollection; this.RuleAddedHandler = new RuleEventHandler(this.OnRuleAsserted); this.RuleRemovedHandler = new RuleEventHandler(this.OnRuleRetracted); this.AttachEventHandlers(this._rules); }
/// <summary> /// Helper method for raising the <see cref="RuleRemoved">Rule Removed</see> event /// </summary> /// <param name="t">Rule</param> protected void RaiseRuleRemoved(Rule t) { RuleEventHandler d = this.RuleRemoved; if (d != null) { d(this, new RuleEventArgs(t, null, false)); } }
/// <summary> /// Helper method for raising the <see cref="RuleRetracted">Rule Retracted</see> event manually /// </summary> /// <param name="args"></param> protected void RaiseRuleRetracted(RuleEventArgs args) { RuleEventHandler d = this.RuleRetracted; args.PrologKB = this; if (d != null) { d(this, args); } this.RaisePrologMtChanged(args); }
/// <summary> /// Helper method for raising the <see cref="RuleRetracted">Rule Retracted</see> event manually /// </summary> /// <param name="t">Rule</param> protected void RaiseRuleRetracted(Rule t) { RuleEventHandler d = this.RuleRetracted; PrologMtEventHandler e = this.Changed; if (d != null || e != null) { RuleEventArgs args = new RuleEventArgs(t, (PNode)this, false); if (d != null) { d(this, args); } if (e != null) { e(this, new PrologMtEventArgs((PNode)this, args)); } } }
internal void addRuleEventHandler(RuleEventHandler handler) { Log.LogMessage(Log.LogLevels.DETAILED, "Adding rule event handler for : " + this.dataPoint.GetName()); this.ruleEventHandlers.Add(handler); }
/******************************************************************************/ public FuzzyRule(Control parent, int rule_index, RuleEventHandler handler) { _rule_index = rule_index; _handler = handler; Font f_reg = new Font("Microsoft Sans Serif", 6); if(_label_if == null) { _label_if = new Label(); _label_if.Font = f_reg; _label_if.Text = LABEL_IF_STR; _label_if.AutoSize = false; _label_if.Size = new Size(LABEL_IF_WIDTH, LABEL_HEIGHT); _label_if.Location = new Point(LABEL_IF_LEFT, LABEL_TOP + (CBO_HEIGHT * rule_index)); parent.Controls.Add(_label_if); } if(_cbo_pos == null) { _cbo_pos = new ComboBox(); _cbo_pos.Name = "cbo_pos_" + rule_index.ToString(); _cbo_pos.Font = f_reg; _cbo_pos.Size = new Size(CBO_WIDTH, CBO_HEIGHT); _cbo_pos.Location = new Point(CBO_POS_LEFT, CBO_TOP + (CBO_HEIGHT * rule_index)); // Prevent user from editing drop down list _cbo_pos.DropDownStyle = ComboBoxStyle.DropDownList; parent.Controls.Add(_cbo_pos); } if(_label_and == null) { _label_and = new Label(); _label_and.Font = f_reg; _label_and.Text = LABEL_AND_STR; _label_and.AutoSize = false; _label_and.Size = new Size(LABEL_AND_WIDTH, LABEL_HEIGHT); _label_and.Location = new Point(LABEL_AND_LEFT, LABEL_TOP + (CBO_HEIGHT * rule_index)); parent.Controls.Add(_label_and); } if(_cbo_spd == null) { _cbo_spd = new ComboBox(); _cbo_spd.Name = "cbo_spd_" + rule_index.ToString(); _cbo_spd.Font = f_reg; _cbo_spd.Size = new Size(CBO_WIDTH, CBO_HEIGHT); _cbo_spd.Location = new Point(CBO_SPD_LEFT, CBO_TOP + (CBO_HEIGHT * rule_index)); _cbo_spd.DropDownStyle = ComboBoxStyle.DropDownList; parent.Controls.Add(_cbo_spd); } if(_label_then == null) { _label_then = new Label(); _label_then.Font = f_reg; _label_then.Text = LABEL_THEN_STR; _label_then.AutoSize = false; _label_then.Size = new Size(LABEL_THEN_WIDTH, LABEL_HEIGHT); _label_then.Location = new Point(LABEL_THEN_LEFT, LABEL_TOP + (CBO_HEIGHT * rule_index)); parent.Controls.Add(_label_then); } if(_cbo_out == null) { _cbo_out = new ComboBox(); _cbo_out.Name = "cbo_out_" + rule_index.ToString(); _cbo_out.Font = f_reg; _cbo_out.Size = new Size(CBO_WIDTH, CBO_HEIGHT); _cbo_out.Location = new Point(CBO_OUT_LEFT, CBO_TOP + (CBO_HEIGHT * rule_index)); _cbo_out.DropDownStyle = ComboBoxStyle.DropDownList; parent.Controls.Add(_cbo_out); } }