private void moveButton_Click(object sender, EventArgs e) { List <string> folders = new List <string>(); TreeNode projectNode = treeView.Nodes[0]; folders.Add(projectNode.FullPath); GetFoldersInFolder(projectNode, folders); // Move diffrently depending on whether it's a folder or document being moved if (isDocument) { DropdownDialog <string> folderDialog = new DropdownDialog <string>("Which folder should the document be moved to?", folders, true); folderDialog.ShowDialog(); if (folderDialog.Canceled) { return; } // Figure out new path string path = folderDialog.Selected; if (selectedProject.ToString() == path) { path = ""; } else { path = path.Substring(selectedProject.ToString().Count() + 1); } path = Regex.Replace(path, @"\\", "/"); moveDocument(path, selectedDocument.Id); } else { DropdownDialog <string> folderDialog = new DropdownDialog <string>("Which folder should the folder be moved to?", folders, true); folderDialog.ShowDialog(); if (folderDialog.Canceled) { return; } // Figure out new path string path = folderDialog.Selected; if (selectedProject.ToString() == path) { path = ""; } else { path = path.Substring(selectedProject.ToString().Count() + 1); } path = Regex.Replace(path, @"\\", "/"); MoveFolder(selectedFolder, path); } RefreshTreeView(); }
/** * Find out what projects that aren't on this storage yet, * ask the user for one to donwload, and then get all the documents * from that project */ private void getProjectButton_Click(object sender, EventArgs e) { try { // Ask server for all available projects List <Project> serverProjects = ServerController.GetAllProjectsAvailable(activeUser); List <Project> newProjects = new List <Project>(); // Check which ones that aren't added yet foreach (Project p in serverProjects) { bool contained = false; foreach (Project q in projects) { if (p.Id == q.Id) { contained = true; } } if (!contained) { newProjects.Add(p); } } // If there's no new projects, tell the user if (newProjects.Count == 0) { MessageBox.Show("There are no new projects on the server"); } else { // Show a dropdowndialog with all the choices DropdownDialog <Project> dialog = new DropdownDialog <Project>( "Choose a project from the server to download", newProjects); dialog.ShowDialog(); if (!dialog.Canceled) { Project newProject = dialog.Selected; // Ask the server for all document for the selected project List <Document> docs = ServerController.GetAllProjectDocuments(newProject); // Save it all Controller.UpdateProject(newProject); foreach (Document d in docs) { Controller.SaveDocument(newProject, d, activeUser, true); } } } RefreshTreeView(); } catch (Exception) { MessageBox.Show("Sorry, something went wrong trying to contact the server."); } }