Inheritance: ICloneable
コード例 #1
0
 private static void setNodeColour(TreeNode node, IRule rule)
 {
     node.BackColor = rule.enabled_ ? Color.White : Color.Red;
 }
コード例 #2
0
        //Base code from http://www.dotnetjohn.com/articles.aspx?articleid=173

        private string Serialize(IRule rule)
        {
            System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
            System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(IRule));
            XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
            xs.Serialize(xmlTextWriter, rule);
            memoryStream = (System.IO.MemoryStream)xmlTextWriter.BaseStream;

            return UTF8ByteArrayToString(memoryStream.ToArray());
        }
コード例 #3
0
        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();
            }
        }
コード例 #4
0
        private 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();
            currentRule_.SelectName();
        }
コード例 #5
0
        private static void RecurseNode(TreeNode n, IRule r)
        {
            if (n.Nodes.Count == 0) return;

            r.Children = new List<IRule>();
            foreach (TreeNode n1 in n.Nodes)
            {
                IRule r1 = (IRule)n1.Tag;
                if (n1.Nodes.Count > 0) RecurseNode(n1, r1);
                r.Children.Add(r1);
            }
        }
コード例 #6
0
        private void AddNewRule(IRule r)
        {
            if (r == null)
                return;

            SaveCurrentRule();
            history_.Save();

            TreeNode n = new TreeNode(r.Name);
            n.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();
        }
コード例 #7
0
        private void RestoreSelectedRule()
        {
            if (RulesTreeView.SelectedNode == null)
            {
                if (currentRule_ != null)
                {
                    currentRule_.DisposeControl();
                    currentRule_ = null;
                    NoRuleSelectedLabel.Show();
                }
            }
            else
            {
                NoRuleSelectedLabel.Hide();

                IRule oldrule = currentRule_;

                currentRule_ = (IRule)RulesTreeView.SelectedNode.Tag;

                SuspendLayout();

                Point pos = new Point();
                ruleControl_ = null;
                ruleControl_ = currentRule_.CreateControl(this, RuleControlSpace.Controls, pos);
                ruleControl_.Size = RuleControlSpace.Size;

                currentRule_.Name = RulesTreeView.SelectedNode.Text;

                currentRule_.Restore();

                if (oldrule != null)
                {
                    if (!currentRule_.Equals(oldrule))
                        oldrule.DisposeControl();
                }

                ruleControl_.Visible = true;

                ResumeLayout();
            }
            UpdateEnabledStates();
            setTreeViewColours();
        }
コード例 #8
0
ファイル: ReplaceSpecial.cs プロジェクト: svick/AWB
        private void RestoreSelectedRule()
        {
            if (RulesTreeView.SelectedNode == null)
            {
                if (CurrentRule != null)
                {
                    CurrentRule.DisposeControl();
                    CurrentRule = null;
                    NoRuleSelectedLabel.Show();
                }
            }
            else
            {
                NoRuleSelectedLabel.Hide();

                IRule oldrule = CurrentRule;

                CurrentRule = (IRule)RulesTreeView.SelectedNode.Tag;

                SuspendLayout();

                ruleControl_ = CurrentRule.CreateControl(this, RuleControlSpace.Controls, new Point());
                ruleControl_.Size = RuleControlSpace.Size;

                CurrentRule.Name = RulesTreeView.SelectedNode.Text;

                CurrentRule.Restore();

                if (oldrule != null)
                {
                    if (!CurrentRule.Equals(oldrule))
                        oldrule.DisposeControl();
                }

                ruleControl_.Visible = true;

                ResumeLayout();
            }
            UpdateEnabledStates();
            SetTreeViewColours();
        }
コード例 #9
0
ファイル: ReplaceSpecial.cs プロジェクト: svick/AWB
        private void AddNewRule(IRule r, TreeNode tn)
        {
            TreeNode n = new TreeNode(r.Name) {Tag = r};

            tn.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();
            }
        }
コード例 #10
0
 private static void setNodeColour(TreeNode node, IRule rule)
 {
     if (rule.enabled_)
         node.BackColor = Color.White;
     else
         node.BackColor = Color.Red;
 }
コード例 #11
0
 private static void SetNodeColour(TreeNode node, IRule rule)
 {
     node.BackColor = rule.enabled_ ? Color.White : Color.Red;
 }