public void RefreshTrigger(CodeTrigger trigger)
        {
            this.tbGroup.TextChanged     -= this.tbGroup_TextChanged;
            this.tbName.TextChanged      -= this.tbName_TextChanged;
            this.cbActive.CheckedChanged -= this.cbActive_CheckedChanged;
            this.tbCode.TextChanged      -= this.tbCode_TextChanged;

            if (trigger == null)
            {
                tbGroup.Text     = null;
                tbName.Text      = null;
                tbCode.Text      = null;
                cbActive.Checked = false;
            }
            else
            {
                tbGroup.Text     = trigger.Group;
                tbName.Text      = trigger.Name;
                tbCode.Text      = trigger.Code;
                cbActive.Checked = trigger.Active;
            }
            this.tbGroup.TextChanged     += this.tbGroup_TextChanged;
            this.tbName.TextChanged      += this.tbName_TextChanged;
            this.cbActive.CheckedChanged += this.cbActive_CheckedChanged;
            this.tbCode.TextChanged      += this.tbCode_TextChanged;
        }
 private void CreateTrigger()
 {
     currentTrigger = new CodeTrigger {
         Name = $"#{nbTriggers++:00}", Group = "Default"
     };
     triggers.Add(currentTrigger);
 }
 private void tsbCloneTrigger_Click(object sender, System.EventArgs e)
 {
     foreach (int idx in dlvTriggers.SelectedIndices)
     {
         CodeTrigger trig    = triggers[idx];
         var         newTrig = trig.Clone();
         triggers.Add(newTrig);
     }
     RefreshTriggers();
 }
 private void tsbDeleteTrigger_Click(object sender, System.EventArgs e)
 {
     foreach (int idx in dlvTriggers.SelectedIndices)
     {
         CodeTrigger trig = triggers[idx];
         triggers.Remove(trig);
         if (trig == currentTrigger)
         {
             currentTrigger = null;
             Reset();
         }
     }
     RefreshTriggers();
 }
        private void dlvTriggers_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            currentTrigger = dlvTriggers.SelectedObject as CodeTrigger;

            if (currentTrigger != null)
            {
                tbGroup.Text     = currentTrigger.Group;
                tbName.Text      = currentTrigger.Name;
                tbCode.Text      = currentTrigger.Code;
                cbActive.Checked = currentTrigger.Active;
            }
            else
            {
                Reset();
            }
        }
        public CodeTriggersControl()
        {
            InitializeComponent();

            dlvTriggers.CheckStatePutter = (rowObject, value) =>
            {
                CodeTrigger codeTrigger = rowObject as CodeTrigger;
                codeTrigger.Active = (value == CheckState.Checked);
                if (currentTrigger != null)
                {
                    cbActive.Checked = currentTrigger.Active;
                }
                return(value);
            };
            dlvTriggers.CheckStateGetter = rowObject => ((CodeTrigger)rowObject).Active ? CheckState.Checked : CheckState.Unchecked;
            dlvTriggers.InitColumns <CodeTrigger>();
            InitCodeSyntax();
            Reset();
        }
        public void RefreshTrigger(CodeTrigger trigger)
        {
            this.tbGroup.TextChanged -= this.tbGroup_TextChanged;
            this.tbName.TextChanged -= this.tbName_TextChanged;
            this.cbActive.CheckedChanged -= this.cbActive_CheckedChanged;
            this.tbCode.TextChanged -= this.tbCode_TextChanged;

            if (trigger == null) {
                tbGroup.Text = null;
                tbName.Text = null;
                tbCode.Text = null;
                cbActive.Checked = false;
            } else
            {
                tbGroup.Text = trigger.Group;
                tbName.Text = trigger.Name;
                tbCode.Text = trigger.Code;
                cbActive.Checked = trigger.Active;
            }
            this.tbGroup.TextChanged += this.tbGroup_TextChanged;
            this.tbName.TextChanged += this.tbName_TextChanged;
            this.cbActive.CheckedChanged += this.cbActive_CheckedChanged;
            this.tbCode.TextChanged += this.tbCode_TextChanged;
        }
        private void dlvTriggers_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            currentTrigger = dlvTriggers.SelectedObject as CodeTrigger;

            if (currentTrigger != null)
            {
                tbGroup.Text = currentTrigger.Group;
                tbName.Text = currentTrigger.Name;
                tbCode.Text = currentTrigger.Code;
                cbActive.Checked = currentTrigger.Active;
            }
            else
            {
                Reset();
            }
        }
 private void tsbDeleteTrigger_Click(object sender, System.EventArgs e)
 {
     ListView.SelectedIndexCollection selectedTriggers = dlvTriggers.SelectedIndices;
     foreach (int idx in selectedTriggers)
     {
         CodeTrigger trig = triggers[idx];
         triggers.Remove(trig);
         if( trig == currentTrigger)
         {
             currentTrigger = null;
             Reset();
         }
     }
     RefreshTriggers();
 }
示例#10
0
 private void CreateTrigger()
 {
     currentTrigger = new CodeTrigger { Name = $"#{nbTriggers++:00}", Group = "Default" };
     triggers.Add(currentTrigger);
 }