Ejemplo n.º 1
0
        public TVIViewModel(TVIModel model, TVIViewModel parent, bool lazyLoadChildren)
        {
            Tvim        = model;
            this.parent = parent;
            Tvim.Depth  = parent == null ? 0 : parent.Tvim.Depth + 1;

            children = new SIEETreeView(null);
            if (lazyLoadChildren && Tvim.IsFolder)
            {
                children.Add(DummyChild);
            }
        }
Ejemplo n.º 2
0
 public FilesystemFolder(TVIModel parent, string name)
 {
     foreach (DirectoryInfo di in ((FilesystemFolder)parent).DirInfo.GetDirectories())
     {
         if (di.Name.ToLower() == name.ToLower())
         {
             DirInfo    = di;
             FolderPath = Path.Combine(((FilesystemFolder)parent).FolderPath, di.Name);
             break;
         }
     }
 }
Ejemplo n.º 3
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);
        }