Пример #1
0
 private void DeleteRule(RuleItem rule)
 {
     if (File.Exists(rule.FileName))
     {
         File.Delete(rule.FileName);
     }
 }
Пример #2
0
        private void listViewRules_SelectedIndexChanged(object sender, EventArgs e)
        {
            toolStripButtonDeleteRule.Enabled = listViewRules.SelectedItems.Count > 0;
            if (toolStripButtonDeleteRule.Enabled)
            {
                RuleItem ruleItem = listViewRules.SelectedItems[0].Tag as RuleItem;

                SetupUI(ruleItem.Rule);
            }
        }
Пример #3
0
        public bool OnSaveRule(RuleItem rule)
        {
            if (SaveRule != null)
            {
                SaveRuleEventArgs e = new SaveRuleEventArgs(rule);

                SaveRule(this, e);
                return(e.Cancel);
            }
            return(false);
        }
Пример #4
0
        private void AddNewRule()
        {
            ServerRule rule = new ServerRule()
            {
                TrackChanges = true
            };
            RuleItem ruleItem = new RuleItem(rule, string.Empty);

            rule.Name        = GetDefaultRuleName();
            rule.Active      = true;
            rule.Priority    = 1;
            rule.ServerEvent = ServerEvent.ReceiveCStoreRequest;

            AddRule(ruleItem, true);
            SetupUI(rule);
        }
Пример #5
0
        private void AddRule(RuleItem ruleItem, bool select)
        {
            ListViewItem item = new ListViewItem();

            item.Text = ruleItem.Rule.Name;
            item.SubItems.Add(ruleItem.Rule.Priority.ToString());
            item.SubItems.Add(new Described <ServerEvent>(ruleItem.Rule.ServerEvent).ToString());
            item.SubItems.Add(ruleItem.Rule.Active?"YES":"NO");
            item.Selected = select;
            item.Tag      = ruleItem;

            if (select)
            {
                listViewRules.Items.Insert(0, item);
            }
            else
            {
                listViewRules.Items.Add(item);
            }
        }
Пример #6
0
        private void toolStripButtonDeleteRule_Click(object sender, EventArgs e)
        {
            RuleItem rule = CurrentItem;

            if (CurrentItem != null)
            {
                int index = listViewRules.SelectedItems[0].Index;

                listViewRules.Items.Remove(listViewRules.SelectedItems[0]);
                DeleteRule(rule);
                if (listViewRules.Items.Count > 0 && index < listViewRules.Items.Count)
                {
                    listViewRules.SelectedIndices.Add(index);
                }
                else if (listViewRules.Items.Count > 0 && index == listViewRules.Items.Count)
                {
                    listViewRules.SelectedIndices.Add(index - 1);
                }
                else
                {
                    ClearEditor();
                }
            }
        }
Пример #7
0
 public SaveRuleEventArgs(RuleItem rule)
 {
     _RuleItem = rule;
 }