Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        private void AddRule(Type t)
        {
            DeviceRule r = this.rules.createRule(t);

            if (r != null)
            {
                this.rules.AddRule(r);
            }
        }
Ejemplo n.º 4
0
 protected void OnRuleDeleted(DeviceRule r)
 {
     if (this.RuleDeleted != null)
     {
         this.RuleDeleted(this, new RuleSet.RuleEventArgs
         {
             Rule = r
         });
     }
 }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
 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;
         }
     }
 }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
 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;
     }
 }
Ejemplo n.º 9
0
 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;
 }
Ejemplo n.º 10
0
 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();
         }
     }
 }
Ejemplo n.º 11
0
 public MidiRangeInputChannel(IInputLayer parent, DeviceRule r) : base(parent, r, true, true)
 {
 }
Ejemplo n.º 12
0
 public void DeleteRule(DeviceRule r)
 {
     this.Rules.Remove(r);
     r.MidiMessageSend -= new EventHandler <MidiEventArgs>(this.OnSendMessage);
     this.OnRuleDeleted(r);
 }
Ejemplo n.º 13
0
 public void AddRule(DeviceRule r)
 {
     this.Rules.Add(r);
     r.MidiMessageSend += new EventHandler <MidiEventArgs>(this.OnSendMessage);
     this.OnRuleAdded(r);
 }
Ejemplo n.º 14
0
 public ButtonInputChannel(DeviceRule d, IInputLayer parent) : base(parent, d, true, true)
 {
 }