/// <summary> /// Comprueba si un nodo estaba en la lista de nodos abiertos /// </summary> private bool CheckExpanded(ExplorerProjectNodeViewModel node, List <Tuple <string, string> > nodesExpanded) { // Recorre la colección foreach (Tuple <string, string> nodeExpanded in nodesExpanded) { if (nodeExpanded.Item1.Equals(node.GetType().ToString(), StringComparison.CurrentCultureIgnoreCase) && nodeExpanded.Item2.Equals(node.ID, StringComparison.CurrentCultureIgnoreCase)) { return(true); } } // Si ha llegado hasta aquí es porque no ha encontrado nada return(false); }
/// <summary> /// Añade un nodo /// </summary> protected ExplorerProjectNodeViewModel AddNode(IHierarchicalViewModel parent, string text, ProjectItemDefinitionModel definition, object tag, bool lazyLoad = false) { ExplorerProjectNodeViewModel node = new ExplorerProjectNodeViewModel(this, parent, text, definition, tag, lazyLoad); // Cambia la negrita node.IsBold = definition?.IsBold ?? false; node.Icon = definition?.Icon; node.Foreground = definition?.Foreground ?? MvvmColor.Black; // Añade el nodo a la lista if (parent == null) { Children.Add(node); } else { parent.Children.Add(node); } // Devuelve el nodo return(node); }
/// <summary> /// Añade un nodo /// </summary> protected ExplorerProjectNodeViewModel AddNode(IHierarchicalViewModel parent, string text, object tag, bool isBold, MvvmColor foreground, string icon, bool lazyLoad = false) { ExplorerProjectNodeViewModel node = new ExplorerProjectNodeViewModel(this, parent, text, null, tag, lazyLoad, foreground); // Cambia la negrita node.IsBold = isBold; node.Icon = icon; node.Foreground = foreground; // Añade el nodo a la lista if (parent == null) { Children.Add(node); } else { parent.Children.Add(node); } // Devuelve el nodo return(node); }
/// <summary> /// Carga los archivos de proyecto /// </summary> protected void LoadProjectFiles(ExplorerProjectNodeViewModel root, string path, string folderDefinitionId) { if (!string.IsNullOrEmpty(path) && System.IO.Directory.Exists(path)) { // Carga las carpetas foreach (string child in System.IO.Directory.GetDirectories(path)) { ExplorerProjectNodeViewModel folder = AddNode(root, System.IO.Path.GetFileName(child), folderDefinitionId, child); LoadProjectFiles(folder, child, folderDefinitionId); } // Carga los archivos foreach (string file in System.IO.Directory.GetFiles(path)) { ProjectItemDefinitionModel definition = Definition.SearchByExtension(System.IO.Path.GetExtension(file)); if (definition != null) { AddNode(root, System.IO.Path.GetFileName(file), definition, file); } } } }
/// <summary> /// Carga los nodos hijo de un nodo /// </summary> protected abstract void LoadChildrenNodes(ExplorerProjectNodeViewModel node);
/// <summary> /// Carga los nodos hijo (necesario porque <see cref="LoadChildrenNodes(ExplorerProjectNodeViewModel)"/> /// es protected y no se puede llamar desde <see cref="ExplorerProjectNodeViewModel"/>) /// </summary> internal void LoadNodes(ExplorerProjectNodeViewModel node) { LoadChildrenNodes(node); }