public static RuleSet Load(ManagedTreeItem mti) { RuleSet ret = new RuleSet(false); Pair <string, object> nameAt = mti.Attributes.FirstOrDefault((Pair <string, object> i) => i.Left == "Name"); ret.Name = ((nameAt != null) ? ((string)nameAt.Right) : ""); Pair <string, object> inp = mti.Attributes.FirstOrDefault((Pair <string, object> i) => i.Left == "InputDeviceID"); ret.InputDeviceID = ((inp != null) ? ((string)inp.Right) : null); Pair <string, object> outp = mti.Attributes.FirstOrDefault((Pair <string, object> i) => i.Left == "OutputDeviceID"); ret.OutputDeviceID = ((outp != null) ? ((string)outp.Right) : null); if (mti.hasValue <string>("GUID")) { ret.GUID = mti.getValue <string>("GUID"); } else { ret.GUID = Guid.NewGuid().ToString(); } ret.genInputLayer(); foreach (ManagedTreeItem item in mti.GetChildren("Rule")) { if (DeviceRule.Load(ret, item) == null) { RuleSet.log.Warn("Failed to load DeviceRule in RuleSet {0}, Invalid Cast and/or constructor missing!", ret.Name); } } foreach (DeviceRule item2 in ret.Rules) { item2.UpdateBacktrack(); } return(ret); }
public static DeviceRule Load(RuleSet r, ManagedTreeItem item) { DeviceRule result; if (!item.hasValue <Type>("Type")) { result = null; } else { Type type = item.getValue <Type>("Type"); DeviceRule o = r.createRule(type); if (o == null) { result = null; } else { o.LoadGUID(item); r.AddRule(o); o.Init(item); result = o; } } return(result); }
private void AddRule(Type t) { DeviceRule r = this.rules.createRule(t); if (r != null) { this.rules.AddRule(r); } }
protected void OnRuleDeleted(DeviceRule r) { if (this.RuleDeleted != null) { this.RuleDeleted(this, new RuleSet.RuleEventArgs { Rule = r }); } }
private void HandleItemAdd(object s, RuleSet.RuleEventArgs e) { DeviceRule item = e.Rule; MidiInputChannel ic = item.GetInputChannel(this); if (ic != null) { this.inputchannels.Add(e.Rule.GUID, ic); this.AddInputChannel(ic); } }
private void DeleteSelected() { if (this.ruleSetGrid.SelectedRows.Count == 1) { DeviceRule rs = (DeviceRule)this.ruleSetGrid.SelectedRows[0].DataBoundItem; this.rules.DeleteRule(rs); if (this.ruleInfo.SelectedObject == rs) { this.ruleInfo.SelectedObject = null; } } }
public static RuleSet LoadFromXml(XElement element) { var ruleset = new RuleSet(true); ruleset.name = element.Attribute("Name").Value; ruleset.genInputLayer(); foreach (var item in element.Elements("Rule")) { ruleset.AddRule(DeviceRule.LoadFromXml(item)); } return(ruleset); }
private void HandleSelectionChanged(object s, EventArgs e) { if (this.ruleSetGrid.SelectedRows.Count > 0) { DataGridViewRow selected = this.ruleSetGrid.SelectedRows[0]; DeviceRule obj = this.rules.Rules[selected.Index]; this.ruleInfo.SelectedObject = obj; this.ruleInfo.ExpandAllGridItems(); } else { this.ruleInfo.SelectedObject = null; } }
public MidiInputChannel(IInputLayer parent, DeviceRule rule, bool registerValueChange = true, bool registerFB = true) : base(rule.GUID, parent) { base.AutofireChangedEvent = true; rule.NameChanged += new EventHandler(this.HandleNameChanged); base.Name = rule.Name; if (registerValueChange) { rule.ValueChanged += new EventHandler <ValueChangedEventArgs>(this.HandleValueChanged); } if (registerFB) { this.FeedbackCB = new InputLayerChangedCallback(this.HandleFeedback); } this.rule = rule; this.Changed += HandleChanged; }
private void BeginLearn() { if (this.ruleSetGrid.SelectedRows.Count > 0) { if (this.rules.InputDevice != null && !this.learning) { this.learning = true; this.beginLearnToolStrip.Enabled = false; this.cancelLearnToolStripMenuItem.Enabled = true; DataGridViewRow selected = this.ruleSetGrid.SelectedRows[0]; DeviceRule obj = this.rules.Rules[selected.Index]; obj.LearningFinished += new EventHandler(this.HandleLearnFinished); obj.BeginLearn(); this.currentlearn = obj; this.ruleSetGrid.Refresh(); this.ruleInfo.Refresh(); this.rules.InputUsed = true; this.rules.InputDevice.LearnMessage += new EventHandler <MidiEventArgs>(this.HandleLearnMessage); this.rules.InputDevice.EnterLearnMode(); } } }
public MidiRangeInputChannel(IInputLayer parent, DeviceRule r) : base(parent, r, true, true) { }
public void DeleteRule(DeviceRule r) { this.Rules.Remove(r); r.MidiMessageSend -= new EventHandler <MidiEventArgs>(this.OnSendMessage); this.OnRuleDeleted(r); }
public void AddRule(DeviceRule r) { this.Rules.Add(r); r.MidiMessageSend += new EventHandler <MidiEventArgs>(this.OnSendMessage); this.OnRuleAdded(r); }
public ButtonInputChannel(DeviceRule d, IInputLayer parent) : base(parent, d, true, true) { }