private static void setNodeColour(TreeNode node, IRule rule) { node.BackColor = rule.enabled_ ? Color.White : Color.Red; }
//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()); }
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(); } }
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(); }
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); } }
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(); }
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(); }
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(); }
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(); } }
private static void setNodeColour(TreeNode node, IRule rule) { if (rule.enabled_) node.BackColor = Color.White; else node.BackColor = Color.Red; }
private static void SetNodeColour(TreeNode node, IRule rule) { node.BackColor = rule.enabled_ ? Color.White : Color.Red; }