コード例 #1
0
        // Find the node in the tree starting at the current node
        // Expand tree if necessary
        public TVIViewModel FindNodeInTree(string idPath)
        {
            if (this.Count() == 0)
            {
                return(null);
            }
            string concatString = this[0].Tvim.GetPathConcatenationString();

            string[] tokens = idPath.Split(new[] { concatString }, StringSplitOptions.None);

            TVIViewModel currNode = null;
            SIEETreeView currTree = this;

            for (int i = 0; i != tokens.Length; i++)
            {
                if (tokens[i] == string.Empty)
                {
                    continue;
                }
                currNode = currTree.findChild(tokens[i]);
                if (currNode == null)
                {
                    return(null);
                }
                currNode.IsExpanded = true;
                currTree            = currNode.Children;
            }
            return(currNode);
        }
コード例 #2
0
        // Open the tree view according to the serialzed path.
        // Expands all nodes on the way
        public TVIViewModel InitializeTree(List <string> serializedPath, Type modelType)
        {
            if (serializedPath == null)
            {
                return(null);
            }

            SIEETreeView currentTree = this;
            TVIViewModel currItem    = null;

            try
            {
                for (int i = 0; i != serializedPath.Count; i++)
                {
                    TVIModel tvim = (TVIModel)TVIViewModel.deSerialize(serializedPath[i], modelType);

                    currItem = currentTree.findChild(tvim.Id);
                    if (currItem == null)
                    {
                        throw new Exception(tvim.DisplayName + " not found");
                    }
                    currItem.IsExpanded = true;
                    currItem.IsSelected = true;
                    currentTree         = currItem.Children;
                }
            }
            catch (Exception e)
            {
                string errMsg = "No items in tree view";
                string title  = "Error";
                if (this.Count() > 0)
                {
                    TVIModel someModel = this[0].Tvim;
                    errMsg = "Could not locate " + someModel.GetTypeName() + ". Reason:\n" + e.Message;
                    title  = "Navigate to " + someModel.GetTypeName();
                }
                SIEEMessageBox.Show(errMsg, title, System.Windows.MessageBoxImage.Error);
            }
            return(currItem);
        }