[Adapdev-commits] Adapdev/src/Adapdev.Windows.Forms SmartTreeView.cs,1.1,1.2
Status: Beta
Brought to you by:
intesar66
From: Sean M. <int...@us...> - 2005-06-02 03:26:11
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.Windows.Forms In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28755/src/Adapdev.Windows.Forms Modified Files: SmartTreeView.cs Log Message: Updated OracleSelectQuery to properly handle SetLimit Updated CrypoTests to pass Modified SmartTreeView to track state of nodes across reloads Small modifications to the caching block Index: SmartTreeView.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Windows.Forms/SmartTreeView.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SmartTreeView.cs 25 May 2005 05:17:48 -0000 1.1 --- SmartTreeView.cs 2 Jun 2005 03:26:00 -0000 1.2 *************** *** 7,16 **** --- 7,20 ---- namespace Adapdev.Windows.Forms { + using System.Text; + public class SmartTreeView : System.Windows.Forms.TreeView { private System.ComponentModel.IContainer components = null; private bool disableAfterSelect = false; + private bool trackState = true; private Color checkedFont = Color.Black; private Color uncheckedFont = Color.LightGray; + private Hashtable state = new Hashtable(); public SmartTreeView() *************** *** 19,22 **** --- 23,27 ---- } + /// <summary> /// Clean up any resources being used. *************** *** 59,62 **** --- 64,69 ---- // Check / Uncheck all children CheckChildren(e.Node); + // Save the nodes state + if(this.TrackState) this.SaveState(e.Node); this.disableAfterSelect = false; } *************** *** 70,73 **** --- 77,82 ---- // Set the parent to the child's checked state treeNode.Parent.Checked = node.Checked; + // Save its state + if(this.TrackState) this.SaveState(treeNode.Parent); // Change the state this.ChangeForeColor(treeNode); *************** *** 85,88 **** --- 94,99 ---- // Change the checked state to that of the parent child.Checked = node.Checked; + // Save its state + if(this.TrackState) this.SaveState(child); // Change the state this.ChangeForeColor(node); *************** *** 119,123 **** } ! } } --- 130,190 ---- } ! [Category("Behavior"), ! Description("Determines whether state should be maintained across reload"), ! DefaultValue(typeof(bool), "True"), ! Browsable(true)] ! public bool TrackState ! { ! get { return trackState; } ! set { trackState = value; } ! } ! ! public string GetUniqueNodeName(TreeNode node) ! { ! StringBuilder sb = new StringBuilder(); ! sb.Append(node.Text); ! while(node.Parent != null) ! { ! sb.Append(node.Parent.Text); ! node = node.Parent; ! } ! return sb.ToString(); ! } ! ! public void SaveState(TreeNode node) ! { ! this.state[this.GetUniqueNodeName(node)] = node.Checked; ! } ! ! public void GetState(TreeNode node) ! { ! string uniqueName = this.GetUniqueNodeName(node); ! if(this.state.ContainsKey(uniqueName)) ! { ! node.Checked = (bool)this.state[uniqueName]; ! } ! } ! ! public void ClearState() ! { ! this.state.Clear(); ! } ! ! public void LoadState() ! { ! foreach(TreeNode node in this.Nodes) ! { ! this.LoadState(node); ! } ! } ! ! protected void LoadState(TreeNode node) ! { ! this.GetState(node); ! foreach(TreeNode child in node.Nodes) ! { ! this.LoadState(child); ! } ! } } } |