using System.Windows.Forms; using System.ComponentModel; using FastReport.Utils; namespace FastReport.Dialog { /// /// Displays a hierarchical collection of labeled items, each represented by a TreeNode. /// Wraps the control. /// public partial class TreeViewControl : DialogControl { private TreeView treeView; private string afterSelectEvent; #region Properties /// /// Occurs after the tree node is selected. /// Wraps the event. /// public event TreeViewEventHandler AfterSelect; /// /// Gets an internal TreeView. /// [Browsable(false)] public TreeView TreeView { get { return treeView; } } /// /// Gets or sets a value indicating whether check boxes are displayed next to the tree nodes in the tree view control. /// Wraps the property. /// [DefaultValue(false)] [Category("Appearance")] public bool CheckBoxes { get { return TreeView.CheckBoxes; } set { TreeView.CheckBoxes = value; } } /// /// Gets or sets a value indicating whether lines are drawn between tree nodes in the tree view control. /// Wraps the property. /// [DefaultValue(true)] [Category("Behavior")] public bool ShowLines { get { return TreeView.ShowLines; } set { TreeView.ShowLines = value; } } /// /// Gets or sets a value indicating whether lines are drawn between the tree nodes that are at the root of the tree view. /// Wraps the property. /// [DefaultValue(true)] [Category("Behavior")] public bool ShowRootLines { get { return TreeView.ShowRootLines; } set { TreeView.ShowRootLines = value; } } /// /// Gets or sets the ImageList that contains the Image objects used by the tree nodes. /// Wraps the property. /// [Browsable(false)] public ImageList ImageList { get { return TreeView.ImageList; } set { TreeView.ImageList = value; } } /// /// Gets the collection of tree nodes that are assigned to the tree view control. /// Wraps the property. /// [Browsable(false)] public TreeNodeCollection Nodes { get { return TreeView.Nodes; } } /// /// Gets or sets the tree node that is currently selected in the tree view control. /// Wraps the property. /// [Browsable(false)] public TreeNode SelectedNode { get { return TreeView.SelectedNode; } set { TreeView.SelectedNode = value; } } /// /// Gets or sets a script method name that will be used to handle the /// event. /// [Category("Events")] public string AfterSelectEvent { get { return afterSelectEvent; } set { afterSelectEvent = value; } } #endregion #region Private Methods private void TreeView_AfterSelect(object sender, TreeViewEventArgs e) { OnAfterSelect(e); } #endregion #region Protected Methods /// protected override void AttachEvents() { base.AttachEvents(); TreeView.AfterSelect += new TreeViewEventHandler(TreeView_AfterSelect); } /// protected override void DetachEvents() { base.DetachEvents(); TreeView.AfterSelect -= new TreeViewEventHandler(TreeView_AfterSelect); } #endregion #region Public Methods /// public override void Serialize(FRWriter writer) { TreeViewControl c = writer.DiffObject as TreeViewControl; base.Serialize(writer); if (CheckBoxes != c.CheckBoxes) writer.WriteBool("CheckBoxes", CheckBoxes); if (ShowLines != c.ShowLines) writer.WriteBool("ShowLines", ShowLines); if (ShowRootLines != c.ShowRootLines) writer.WriteBool("ShowRootLines", ShowRootLines); } /// /// This method fires the AfterSelect event and the script code connected to the AfterSelectEvent. /// /// Event data. public virtual void OnAfterSelect(TreeViewEventArgs e) { if (AfterSelect != null) AfterSelect(this, e); InvokeEvent(AfterSelectEvent, e); } #endregion /// /// Initializes a new instance of the class with default settings. /// public TreeViewControl() { treeView = new TreeView(); Control = treeView; TreeView.HideSelection = false; } } }