コード例 #1
0
        /// <summary>
        /// Adds an item to the tree.
        /// </summary>
        protected virtual TreeItemViewModel AddNode(TreeItemViewModel parent, object item, string text, string icon)
        {
            // create node.
            TreeItemViewModel treeNode = new TreeItemViewModel(NodesTV, parent);

            // update text/icon.
            UpdateNode(treeNode, item, text, icon);

            // add to control.
            if (parent == null)
            {
                NodesTV.TreeItems?.Add(treeNode);
            }
            else
            {
                parent.Children.Add(treeNode);
            }

            // return new tree node.
            return(treeNode);
        }
コード例 #2
0
        /// <summary>
        /// Updates a tree node with the current contents of an object.
        /// </summary>
        protected virtual void UpdateNode(TreeItemViewModel treeNode, object item, string text, string icon)
        {
            treeNode.Text = text;
            treeNode.Item = item;
            treeNode.Icon = icon;
            switch (icon)
            {
            case "Server":
                treeNode.Brush = new SolidColorBrush(Colors.Green);
                break;

            case "ServerStopped":
                treeNode.Brush = new SolidColorBrush(Colors.Red);
                break;

            case "ServerKeepAliveStopped":
                treeNode.Brush = new SolidColorBrush(Colors.Yellow);
                break;

            default:
                treeNode.Brush = null;
                break;
            }
        }
コード例 #3
0
 /// <summary>
 /// Initializes a node before expanding it.
 /// </summary>
 protected virtual Task BeforeExpand(TreeItemViewModel clickedNode)
 {
     return(Task.CompletedTask);
 }
コード例 #4
0
 /// <summary>
 /// Enables the state of menu items.
 /// </summary>
 protected virtual void EnableMenuItems(TreeItemViewModel clickedNode)
 {
     // do nothing.
 }
コード例 #5
0
 /// <summary>
 /// Returns the data to drag.
 /// </summary>
 protected virtual object GetDataToDrag(TreeItemViewModel node)
 {
     return(node.Item);
 }
コード例 #6
0
 /// <summary>
 /// Adds an item to the tree.
 /// </summary>
 protected virtual TreeItemViewModel AddNode(TreeItemViewModel treeNode, object item)
 {
     return(AddNode(treeNode, item, String.Format("{0}", item), "ClosedFolder"));
 }