Ejemplo n.º 1
0
        private void AddNewSubrule(IRule r)
        {
            SaveCurrentRule();

            TreeNode s = RulesTreeView.SelectedNode;

            if (s == null)
            {
                return;
            }

            History.Save();

            TreeNode n = new TreeNode(r.Name)
            {
                Tag = r
            };

            s.Nodes.Add(n);
            RulesTreeView.SelectedNode = n;
            RulesTreeView.Select();

            RestoreSelectedRule();
            CurrentRule.SelectName();
        }
        private void DeleteCmd()
        {
            TreeNode st = RulesTreeView.SelectedNode;

            if (st == null)
            {
                return;
            }

            SaveCurrentRule();

            History.Save();

            TreeNode nt = st.NextNode;

            TreeNode parent = st.Parent;

            if (parent != null)
            {
                IRule rule = (IRule)parent.Tag;
                rule.Children.Remove((IRule)st.Tag);
            }

            RulesTreeView.Nodes.Remove(st);

            RulesTreeView.SelectedNode = nt;
            RulesTreeView.Select();
            RestoreSelectedRule();
            SetTreeViewColours();
        }
        void PasteCmd()
        {
            SaveCurrentRule();
            if (clipboard_ == null)
            {
                return;
            }
            history_.Save();
            TreeNode c = IRule.CloneTreeNode(clipboard_);
            TreeNode s = RulesTreeView.SelectedNode;

            if (s == null)
            {
                RulesTreeView.Nodes.Add(c);
            }
            else
            {
                TreeNodeCollection col = this.GetOwningNodes(s);
                col.Insert(col.IndexOf(s), c);
            }
            RulesTreeView.SelectedNode = c;
            RulesTreeView.Select();
            RestoreSelectedRule();
            RulesTreeView.ExpandAll();
        }
Ejemplo n.º 4
0
        private void PasteCmd()
        {
            SaveCurrentRule();
            History.Save();

            AddNewRule(Deserialize(Clipboard.GetDataObject().GetData(typeof(string)).ToString()));

            RulesTreeView.Select();
            RestoreSelectedRule();
            RulesTreeView.ExpandAll();
        }
Ejemplo n.º 5
0
        private void AddNewRule(IRule r)
        {
            if (r == null)
            {
                return;
            }

            SaveCurrentRule();
            History.Save();

            TreeNode n = new TreeNode(r.Name)
            {
                Tag = r
            };

            TreeNode s = RulesTreeView.SelectedNode;

            if (s != null)
            {
                TreeNode p = s.Parent;
                if (p == null)
                {
                    RulesTreeView.Nodes.Insert(RulesTreeView.Nodes.IndexOf(s) + 1, n);
                }
                else
                {
                    p.Nodes.Insert(p.Nodes.IndexOf(s) + 1, n);
                }
            }
            else
            {
                RulesTreeView.Nodes.Add(n);
            }

            if (r.Children != null && r.Children.Count > 0)
            {
                foreach (IRule rnew in r.Children)
                {
                    AddNewRule(rnew, n);
                }
            }
            else
            {
                RulesTreeView.SelectedNode = n;
                RulesTreeView.Select();
            }

            RestoreSelectedRule();
            CurrentRule.SelectName();
        }
        private void AppendRule(IRule r)
        {
            TreeNode n = new TreeNode(r.Name);

            n.Tag = r;

            RulesTreeView.Nodes.Add(n);

            if (r.Children != null && r.Children.Count > 0)
            {
                foreach (IRule rnew in r.Children)
                {
                    AddNewRule(rnew, n);
                }
            }
            else
            {
                RulesTreeView.SelectedNode = n;
                RulesTreeView.Select();
            }
        }
Ejemplo n.º 7
0
        private void DeleteCmd()
        {
            TreeNode st = RulesTreeView.SelectedNode;

            if (st == null)
            {
                return;
            }

            SaveCurrentRule();

            History.Save();

            TreeNode nt = st.NextNode;

            RulesTreeView.Nodes.Remove(st);

            RulesTreeView.SelectedNode = nt;
            RulesTreeView.Select();
            RestoreSelectedRule();
            SetTreeViewColours();
        }
Ejemplo n.º 8
0
        private void MoveSelectedUp()
        {
            TreeNode tn = RulesTreeView.SelectedNode;

            if (tn == null)
            {
                return;
            }

            RulesTreeView.Select();

            TreeNodeCollection col = GetOwningNodes(tn);

            if (col.Count < 2)
            {
                return;
            }

            TreeNode p = tn.PrevNode;

            if (p == null)
            {
                return;
            }

            History.Save();

            col.Remove(tn);
            int i = col.IndexOf(p);

            col.Insert(i, tn);

            RulesTreeView.SelectedNode = tn;
            RulesTreeView.Select();
            //RulesTreeView.ExpandAll();
            RestoreSelectedRule();
        }
Ejemplo n.º 9
0
        private void DownButton_Click(object sender, EventArgs e)
        {
            TreeNode tn = RulesTreeView.SelectedNode;

            if (tn == null)
            {
                return;
            }

            RulesTreeView.Select();

            TreeNodeCollection col = GetOwningNodes(tn);

            if (col.Count < 2)
            {
                return;
            }

            TreeNode p = tn.NextNode;

            if (p == null)
            {
                return;
            }

            History.Save();

            int i = col.IndexOf(p);

            col.Remove(tn);
            col.Insert(i, tn);

            RulesTreeView.SelectedNode = tn;
            //RulesTreeView.ExpandAll();
            RestoreSelectedRule();
        }
        void AddNewSubrule(IRule r)
        {
            SaveCurrentRule();

            TreeNode s = RulesTreeView.SelectedNode;

            if (s == null)
            {
                return;
            }

            history_.Save();

            TreeNode n = new TreeNode(r.Name);

            n.Tag = r;

            s.Nodes.Add(n);
            RulesTreeView.SelectedNode = n;
            RulesTreeView.Select();

            RestoreSelectedRule();
            this.currentRule_.SelectName();
        }