/// <summary> /// Construction /// </summary> public TreeView() { // initialization Width = 280; Height = 240; Left = 2; Top = 2; m_NodesValueMember = new Hashtable(); // optimize scrolling - no flicker SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.SupportsTransparentBackColor, true); SetStyle(ControlStyles.ResizeRedraw, true); m_aNodes = new NodeCollection(this); m_oStyle = new TreeViewStyle(this); m_oScrollBar.Scroll += new ScrollEventHandler(OnScrollItems); m_oScrollBar.MouseEnter += new EventHandler(OnScrollMouseEnter); m_oScrollBar.MouseLeave += new EventHandler(OnScrollMouseLeave); m_oHScrollBar.Scroll += new ScrollEventHandler(OnScrollItemsHorizontal); m_oHScrollBar.MouseEnter += new EventHandler(OnScrollMouseEnter); m_oHScrollBar.MouseLeave += new EventHandler(OnScrollMouseLeave); this.BackColor = Color.White; m_OnInplaceEditLostFocus = new EventHandler(OnInplaceEditLostFocus); m_OnInplaceEditKeyPress = new KeyPressEventHandler(OnInplaceEditKeyPress); m_textBox.Visible = false; MethodInfo[] methods = typeof (ContextMenu).GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.NonPublic); foreach (MethodInfo method in methods) { if (method.Name == "OnPopup") { m_OnPopupMenu = method; break; } } }
/// <summary> /// The copy construction /// </summary> public NodeEnumerator(NodeCollection oCollection) { this.m_oCollection = ((IEnumerable)(oCollection)); this.m_oEnumerator = m_oCollection.GetEnumerator(); }
/// <summary> /// Gets the node by its name /// </summary> /// <param name="oCollection">Collection to check</param> /// <param name="sNode">Node text to check</param> /// <returns>Node object if found, null otherwise</returns> private Node GetCollectionNode(NodeCollection oCollection, string sNode) { foreach (Node oNode in oCollection) if (oNode.Text == sNode) return oNode; return null; }
public NodeCollection(NodeCollection oCollection) : this() { AddRange(oCollection); }
/// <summary> /// The copy construction /// </summary> public NodeEnumerator(NodeCollection oCollection) { this.m_oCollection = ((IEnumerable)(oCollection)); this.m_oEnumerator = m_oCollection.GetEnumerator(); }
public void AddRange(NodeCollection value) { foreach (Node oItem in value) { Add(oItem); } }
public NodeCollection(NodeCollection oCollection) : this() { AddRange(oCollection); }
private void SaveNodes(NodeCollection nc) { for (int i=0; i<nc.Count; i++) { try { xtw.WriteStartElement("Node"); xtw.WriteAttributeString("CheckBoxVisible",nc[i].CheckBoxVisible.ToString()); xtw.WriteAttributeString("FlagVisible",nc[i].FlagVisible.ToString()); xtw.WriteAttributeString("ImageIndex",nc[i].ImageIndex.ToString()); xtw.WriteAttributeString("Checked",nc[i].Checked.ToString()); xtw.WriteAttributeString("NodeStyleSource",nc[i].NodeStyleSource.ToString()); xtw.WriteAttributeString("Underline",nc[i].Underline.ToString()); xtw.WriteAttributeString("Visible",nc[i].Visible.ToString()); if (nc[i].Key != null) xtw.WriteAttributeString("Key",nc[i].Key.ToString()); if (nc[i].Tag is string) { xtw.WriteAttributeString("Tag",nc[i].Tag.ToString()); } SaveMultiLineText(nc[i].Text, "Text"); SaveObject(nc[i].Flag, "Flag"); SaveMultiLineText(nc[i].Tooltip, "Tooltip"); if (nc[i].NodeStyleSource == PureComponents.TreeView.NodeStyleSource.Local) { SaveObject(nc[i].NodeStyle, "NodeStyle"); } if (nc[i].Nodes.Count > 0) { SaveNodes(nc[i].Nodes); } xtw.WriteFullEndElement(); } catch(Exception ex) { MessageBox.Show(ex.ToString()); } } }