Exemplo n.º 1
0
 public bool Edit(string key,Trigger trigger)
 {
     if (key != trigger.Key && _sortedlist.ContainsKey(trigger.Key))
         return false;
     if (!Remove(key))
         return false;
     return Add(trigger);
 }
Exemplo n.º 2
0
 public bool Add(Trigger trigger,bool update=true)
 {
     if (_sortedlist.ContainsKey(trigger.Key))
         return false;
     _sortedlist.Add(trigger.Key, trigger);
     if(update)
         updateTList();
     return true;
 }
Exemplo n.º 3
0
        //入力内容からTriggerクラスを作成
        Trigger getTrigger()
        {
            Trigger item = new Trigger
            {
                Name = this.textBoxName.Text,
                RegEx = this.comboBoxRegex.Text,
                Match = this.textBoxMatch.Text
            };
            if (item.Name == string.Empty)
            {
                MessageBox.Show("Please enter a Name", "Trigger", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBoxName.Focus();
                return null;
            }
            if (item.RegEx == string.Empty)
            {
                MessageBox.Show("Please enter a Regex", "Trigger", MessageBoxButtons.OK, MessageBoxIcon.Error);
                comboBoxRegex.Focus();
                return null;
            }
            if (!item.EnableRegex())
            {
                MessageBox.Show("bad Regex", "Trigger", MessageBoxButtons.OK, MessageBoxIcon.Error);
                comboBoxRegex.Focus();
                return null;
            }
            foreach (var i in checkedListBoxEnable.CheckedItems)
            {
                string check = i.ToString();
                if (check.EndsWith(CustomTriggerSuffix))
                {
                    item.EnableCustomTriggers.Add(
                        check.Substring(0, check.Length - CustomTriggerSuffix.Length)
                        );
                }
                else if (check.EndsWith(SpellTimerSuffix))
                {
                    item.EnableSpellTimers.Add(
                        check.Substring(0, check.Length - SpellTimerSuffix.Length)
                        );
                }
            }

            foreach (var i in checkedListBoxDisable.CheckedItems)
            {
                string check = i.ToString();
                if (check.EndsWith(CustomTriggerSuffix))
                {
                    item.DisableCustomTriggers.Add(
                        check.Substring(0, check.Length - CustomTriggerSuffix.Length)
                        );
                }
                else if (check.EndsWith(SpellTimerSuffix))
                {
                    item.DisableSpellTimers.Add(
                        check.Substring(0, check.Length - SpellTimerSuffix.Length)
                        );
                }
            }
            if (item.EnableCustomTriggers.Count == 0
                && item.EnableSpellTimers.Count == 0
                && item.DisableCustomTriggers.Count == 0
                && item.DisableSpellTimers.Count == 0)
            {
                MessageBox.Show("Please check", "Trigger", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return null;
            }

            return item;
        }