//----------------------------------------------------------------------------------------- public static List <CommentsCollection> BuildList(string _folder) { try { List <CommentsCollection> result = new List <CommentsCollection>(); List <string> listSub = new List <string>(); if (Directory.Exists(_folder)) { listSub.AddRange(Directory.GetDirectories(_folder).ToList()); } //if (Directory.Exists(TaxonUtils.GetCommentDirectory())) // listSub.Add(TaxonUtils.GetCommentDirectory()); foreach (string s in listSub) { string subFolder = s.Split(System.IO.Path.DirectorySeparatorChar).Last(); if (subFolder.StartsWith("_")) { continue; } CommentsCollection collection = new CommentsCollection(s, System.IO.Path.GetFileName(s)); result.Add(collection); } SortList(result); return(result); } catch (Exception) { } return(null); }
public static CommentFileCreateResult CommentFileCreate(TaxonTreeNode _node) { if (_node == null) { return(CommentFileCreateResult.Failed); } if (TaxonComments.Manager.AvailableCollections.Count == 0) { return(CommentFileCreateResult.NoCollection); } CommentsCollection collection = TaxonComments.Manager.AvailableCollections[0]; string name = CommentFilename(_node.Desc); if (string.IsNullOrEmpty(name)) { return(CommentFileCreateResult.NoNameAndID); } string path = CommentFileDesc.BuildHtlmName(collection, name); if (File.Exists(path)) { return(CommentFileCreateResult.ExistsAlready); } Manager.CreateHtmlComment(path, name); Manager.CleanCommentInMemory(0); return(CommentFileCreateResult.Success); }
public void MoveDown(CommentsCollection _collection) { if (!CanMoveDown(_collection)) { return; } foreach (CommentsCollection collection in AvailableCollections) { collection.PriorityOrder = 2 * (collection.PriorityOrder + 1); } _collection.PriorityOrder += 3; CommentsCollection.SortList(Collections); }
public static CommentFileDesc CreateOnlyIfFileExists(CommentsCollection _collection, string _name) { try { string path = Path.Combine(_collection.Path, _name + ".html"); if (File.Exists(path)) { return(new CommentFileDesc(_collection, _name)); } } catch (Exception e) { Loggers.WriteError(LogTags.Data, "Loading comment for " + _name + " raise an exception:\n" + e.Message); } return(null); }
public static string BuildHtlmName(CommentsCollection _collection, string _name) { return(_collection.Path + System.IO.Path.DirectorySeparatorChar + _name + ".html"); }
public CommentFileDesc(CommentsCollection _collection, string _name) { Collection = _collection; Name = _name; }
public bool CanMoveDown(CommentsCollection _collection) { int index = AvailableCollections.IndexOf(_collection); return((index != -1) && (index != AvailableCollections.Count - 1)); }
public bool CanMoveUp(CommentsCollection _collection) { int index = AvailableCollections.IndexOf(_collection); return(index > 0); }
public void SaveCollections() { CommentsCollection.SaveInfos(Collections); }
public void UpdateAvailableCollections() { AvailableCollections = CommentsCollection.Available(Collections); }