예제 #1
0
 /// <summary>
 /// Remove Deleted Child TreeNodes
 /// </summary>
 /// <param name="parentNode">The Parent TreeNode</param>
 /// <remarks>
 /// If a label has been deleted, we want to remove it from the tree node,
 /// and have it as little akward as possible.
 /// To do this, rather than clear the tree nodes as we refresh them, I'm taking more of a merge appraoch.
 /// So this will allow us to remove nodes we no longer need, without having the navigation bounce around,
 /// collapse etc.
 /// </remarks>
 private void RemoveDeletedChildTreeNodes(NavigationTreeNodes.LabelTreeNode parentNode)
 {
     try
     {
         /*
          * Checking for null here, because if the cast wont work, eg an incompatible node is selected, this should
          * exit pretty gracefully
          */
         if (parentNode == null)
         {
             return;
         }
         var pulledChildLabels = _labelManagementService.GetChildLabels(parentNode.BoundLabel);
         var keysToRemove      = new List <string>();
         var nodeEnumerator    = parentNode.Nodes.GetEnumerator();
         while (nodeEnumerator.MoveNext())
         {
             var currentNode = nodeEnumerator.Current as TreeNode;
             if (!pulledChildLabels.Any(l => Convert.ToString(l.ID) == currentNode.Name))
             {
                 keysToRemove.Add(currentNode.Name);
             }
         }
         foreach (var key in keysToRemove)
         {
             parentNode.Nodes.RemoveByKey(key);
         }
     }
     catch (Exception caught)
     {
         logger.Error("Unexpected Error Removing Deleted Child TreeNodes", caught);
         throw;
     }
 }
예제 #2
0
        /// <summary>
        /// Prefetch Child Treenodes
        /// </summary>
        /// <param name="parentNode">The Parent Label TreeNode</param>
        private void PrefetchChildTreeNodes(NavigationTreeNodes.LabelTreeNode parentNode)
        {
            try
            {
                /*
                 * Checking for null here, because if the cast wont work, eg an incompatible node is selected, this should
                 * exit pretty gracefully
                 */
                if (parentNode == null)
                {
                    return;
                }

                TreeView.SuspendLayout();

                //parentNode.Nodes.Clear();
                var pulledChildLabels = _labelManagementService.GetChildLabels(parentNode.BoundLabel);
                foreach (var childLabel in pulledChildLabels)
                {
                    NavigationTreeNodes.LabelTreeNode labelTreeNode = null;
                    if (parentNode.Nodes.ContainsKey(Convert.ToString(childLabel.ID)))
                    {
                        labelTreeNode = parentNode.Nodes[Convert.ToString(childLabel.ID)] as NavigationTreeNodes.LabelTreeNode;
                    }
                    else
                    {
                        labelTreeNode = new NavigationTreeNodes.LabelTreeNode(childLabel);
                        parentNode.Nodes.Add(labelTreeNode);
                    }

                    //Testing this out, doing a very explicit pull of the secondary label level
                    var secondLevelChildLabels = _labelManagementService.GetChildLabels(labelTreeNode.BoundLabel);
                    foreach (var secondChildLevel in secondLevelChildLabels)
                    {
                        if (!labelTreeNode.Nodes.ContainsKey(Convert.ToString(secondChildLevel.ID)))
                        {
                            var secondLevelTreeNode = new NavigationTreeNodes.LabelTreeNode(secondChildLevel);
                            labelTreeNode.Nodes.Add(secondLevelTreeNode);
                        }
                    }
                }

                TreeView.ResumeLayout();

                //TODO: Implement Label to Macro Join Table, and supporting service interfaces

                //TODO: OK, we need to create a macro list view for the right side pane.  Then we can trigger an event or something to have that know to fill.
            }
            catch (Exception caught)
            {
                logger.Error("Unexpected Error Prefetching Child TreeNodes", caught);
                throw;
            }
        }
예제 #3
0
        /// <summary>
        /// Attach Child Label to TreeNode
        /// </summary>
        /// <param name="parentNode">The Parent TreeNode</param>
        /// <param name="label">The Child Label</param>
        private void AttachChildLabelToNode(TreeNode parentNode, DataContract.Metadata.Label label)
        {
            try
            {
                if (parentNode == null)
                {
                    throw new ArgumentNullException("parentNode");
                }
                if (label == null)
                {
                    throw new ArgumentNullException("label");
                }

                var newChildLabelNode = new NavigationTreeNodes.LabelTreeNode(label);
                parentNode.Nodes.Add(newChildLabelNode);
                TreeView.SelectedNode = newChildLabelNode;
            }
            catch (Exception caught)
            {
                logger.Error("Unexpected Error Attaching Child Label to TreeNode", caught);
                throw;
            }
        }
예제 #4
0
        /// <summary>
        /// Refresh Root LabelNode
        /// </summary>
        private void RefreshRootLabelNode()
        {
            try
            {
                TreeView.SuspendLayout();

                _rootLabelsTreeNode.Nodes.Clear();
                var topLevelLabels = _labelManagementService.GetTopLevelLabels();
                foreach (var label in topLevelLabels)
                {
                    var labelTreeNode = new NavigationTreeNodes.LabelTreeNode(label);
                    _rootLabelsTreeNode.Nodes.Add(labelTreeNode);
                    PrefetchChildTreeNodes(labelTreeNode);
                }
                _rootLabelsTreeNode.Expand();

                TreeView.ResumeLayout();
            }
            catch (Exception caught)
            {
                logger.Error("Unexpected Error Refreshing Root LabelNode", caught);
                throw;
            }
        }