/// <summary> /// Gets the path from the root folder to a specific folder. /// </summary> /// <param name="folderId">The id of the folder to retrieve the path from</param> /// <param name="items">The UI components the tree view consists of</param> /// <returns>The relative path from the root folder to the specified folder</returns> public string GetRelativePath(int folderId, ItemCollection items) { StringBuilder relativePath = new StringBuilder(); while (folderId != Session.GetInstance().RootFolderID) { TreeViewItem folderItem = GetFolderTag(folderId, items); relativePath.Insert(0, "\\" + folderItem.Header); folderId = int.Parse(((object[])folderItem.Tag)[1].ToString()); } relativePath.Insert(0, Session.GetInstance().Email); relativePath.Append("\\"); return(relativePath.ToString()); }
/// <summary> /// Inserts a folder into the specified UI components in the tree view. /// </summary> /// <param name="folder">The folder to be inserted</param> /// <param name="items">The items that the tree view consists of</param> public void InsertFolder(string[] folder, ItemCollection items) { TreeViewItem folderItem = new TreeViewItem(); folderItem.Header = folder[1]; folderItem.Tag = new object[] { folder[0], folder[2], true }; InsertFolderHelper(folder, items); //add to root if (int.Parse(((object[])(folderItem.Tag))[1].ToString()) == Session.GetInstance().RootFolderID) { items.Add(folderItem); } }
/// <summary> /// Inserts a document into the specified UI components in the tree view. /// </summary> /// <param name="document">The document to be inserted</param> /// <param name="items">The items that the tree view consists of</param> public void InsertDocument(string[] document, ItemCollection items) { TreeViewItem documentItem = new TreeViewItem(); documentItem.Header = document[2]; documentItem.Tag = new object[] { document[0], document[1], false }; //0:document id, 1:folderid,2false->not a folder documentItem.MouseLeftButtonUp += new MouseButtonEventHandler(documentItem_MouseLeftButtonUp); InsertDocumentHelper(document, items); //add to root if (int.Parse(((object[])(documentItem.Tag))[1].ToString()) == Session.GetInstance().RootFolderID) { items.Add(documentItem); } }
/// <summary> /// Private constructor to insure that Controller is not created outside this class. /// </summary> private Controller() { session = Session.GetInstance(); session.UserID = -1; }
/// <summary> /// Generates a string containing metadata for a newly created file on the local system. /// The data will be default to: /// <para>documentid: 0 </para> /// <para>userid: Currently online user</para> /// <para>timestamp: current time</para> /// <para>folderid: 0</para> /// Example return: [docid 0|userid 42|timestamp 13-12-2012 20:52:04|fid 0] /// </summary> /// <returns>Returns a metadata string for a completely new document in a format ready to be placed into a file</returns> public static String GenerateMetadataStringForNewFile() { return(GenerateMetadataString(0, Session.GetInstance().UserID, DateTime.UtcNow));//, -1); }