public void RestoreState(NodeState state)
 {
     AssertIsValid ();
     NodeState.RestoreState (pad, this, state);
 }
			public void RestoreState (NodeState state)
			{
				NodeState.RestoreState (tree, this, state);
			}
		static NodeState SaveStateRec (ExtensibleTreeView pad, ITreeNavigator nav)
		{
			List<NodeState> childrenState = null;

			if (nav.Filled && nav.MoveToFirstChild ()) {
				do {
					NodeState cs = SaveStateRec (pad, nav);
					if (cs != null) {
						cs.NodeName = nav.NodeName;
						if (childrenState == null) 
							childrenState = new List<NodeState> ();
						childrenState.Add (cs);
					}
				} while (nav.MoveNext ());
				nav.MoveToParent ();
			}
			
			ExtensibleTreeView.TreeOptions ops = pad.GetNodeOptions (nav);
			
			if (ops != null || nav.Expanded || childrenState != null || nav.Selected) {
				NodeState es = new NodeState ();
				es.Expanded = nav.Expanded;
				es.Selected = nav.Selected;
				es.Options = ops;
				es.ChildrenState = childrenState;
				return es;
			} else
				return null;
		}
		internal static void RestoreState (ExtensibleTreeView pad, ITreeNavigator nav, NodeState es)
		{
			if (es == null) 
				return;
			
			if (es.Options != null) 
				pad.SetNodeOptions (nav, es.Options);
			
			pad.ResetState (nav);
			nav.Expanded = es.Expanded;
			
			if (es.ChildrenState != null) {
				foreach (NodeState ces in es.ChildrenState) {
					if (nav.MoveToChild (ces.NodeName, null)) {
						RestoreState (pad, nav, ces);
						nav.MoveToParent ();
					}
				}
			}
			
			if (es.Selected)
				nav.Selected = true;
		}
		ICustomXmlSerializer ReadFrom (XmlReader reader, ExtensibleTreeView.TreeOptions parentOptions)
		{
			NodeState result = new NodeState ();
			result.NodeName = reader.GetAttribute (nameAttribute);
			if (!String.IsNullOrEmpty (reader.GetAttribute (expandedAttribute)))
				result.Expanded = Boolean.Parse (reader.GetAttribute (expandedAttribute));
			if (!String.IsNullOrEmpty (reader.GetAttribute (selectedAttribute)))
				result.Selected = Boolean.Parse (reader.GetAttribute (selectedAttribute));
				
			XmlReadHelper.ReadList (reader, reader.LocalName, delegate () {
				switch (reader.LocalName) {
				case "Option":
					if (result.Options == null) 
						result.Options = parentOptions != null ? parentOptions.CloneOptions (Gtk.TreeIter.Zero) : new ExtensibleTreeView.TreeOptions ();   
					result.Options [reader.GetAttribute ("id")] = bool.Parse (reader.GetAttribute ("value"));
					return true;
				case "Node":
					if (result.ChildrenState == null)
						result.ChildrenState = new List<NodeState> ();
					result.ChildrenState.Add ((NodeState)ReadFrom (reader, result.Options != null ? result.Options : parentOptions));
					return true;
				}
				return false;
			});
			return result;
		}
Esempio n. 6
0
		ICustomXmlSerializer ReadFrom (XmlReader reader)
		{
			NodeState result = new NodeState ();
			result.NodeName = reader.GetAttribute (nameAttribute);
			if (!String.IsNullOrEmpty (reader.GetAttribute (expandedAttribute)))
				result.Expanded = Boolean.Parse (reader.GetAttribute (expandedAttribute));
			if (!String.IsNullOrEmpty (reader.GetAttribute (selectedAttribute)))
				result.Selected = Boolean.Parse (reader.GetAttribute (selectedAttribute));

			XmlReadHelper.ReadList (reader, reader.LocalName, delegate () {
				switch (reader.LocalName) {
				case "Option":
					if (result.Options == null) 
						result.Options = new Dictionary<string, bool> ();
					result.Options [reader.GetAttribute ("id")] = bool.Parse (reader.GetAttribute ("value"));
					return true;
				case "Node":
					if (result.ChildrenState == null)
						result.ChildrenState = new List<NodeState> ();
					result.ChildrenState.Add ((NodeState)ReadFrom (reader));
					return true;
				}
				return false;
			});
			return result;
		}
Esempio n. 7
0
 public NodeState SaveState()
 {
     AssertIsValid();
     return(NodeState.SaveState(pad, this));
 }
Esempio n. 8
0
 public void RestoreState(NodeState state)
 {
     NodeState.RestoreState(tree, this, state);
 }
Esempio n. 9
0
 public NodeState SaveState()
 {
     return(NodeState.SaveState(tree, this));
 }