Пример #1
0
        /**
         * Mark a document for deletion
         */
        private void DeleteDocument(Project p, DocumentStruct d)
        {
            Document doc = Controller.OpenDocument(selectedProject.Id, selectedDocument.Id);

            doc.Deleted = true;
            Controller.SaveDocument(selectedProject, doc, activeUser);
        }
Пример #2
0
        public void GetHierachyTest()
        {
            Project project = new Project("Projekt1", new User("NotKewin2"), new List <User>()
            {
                new User("Karsten")
            });

            Storage.SaveProjectToFile(project);

            Storage.WriteToFile(project, testDoc);
            Storage.WriteToFile(project, testDoc1);
            Storage.WriteToFile(project, testDoc2);

            Folder root        = new Folder("root");
            Folder cuteanimals = new Folder("cuteanimalsxoxo");
            Folder reptiles    = new Folder("reptiles");

            DocumentStruct testStruct0 = new DocumentStruct(testDoc.Title, testDoc.Owner, testDoc.Id, testDoc.Path, true, true);
            DocumentStruct testStruct1 = new DocumentStruct(testDoc1.Title, testDoc1.Owner, testDoc1.Id, testDoc1.Path, true, true);
            DocumentStruct testStruct2 = new DocumentStruct(testDoc2.Title, testDoc2.Owner, testDoc2.Id, testDoc2.Path, true, true);

            reptiles.AddChild(testStruct2);
            cuteanimals.AddChild(testStruct0);
            root.AddChild(testStruct1);

            cuteanimals.AddChild(reptiles);
            root.AddChild(cuteanimals);
            project.AddChild(root);
            Project expected = project;
            Project actual   = Storage.GetHierachy(project.Id);

            Assert.AreEqual(expected, actual);
        }
Пример #3
0
 /**
  * Recursively move the contents of a folder to somewhere new
  */
 private void MoveFolder(Folder folder, string path)
 {
     foreach (IFileSystemComponent component in folder.Children)
     {
         if (component.FileType == DocType.Document)
         {
             DocumentStruct docStruct = (DocumentStruct)component;
             moveDocument(path, docStruct.Id);
         }
         else if (component.FileType == DocType.Folder)
         {
             Folder fold = (Folder)component;
             MoveFolder(fold, path + @"/" + component.Title);
         }
     }
 }
Пример #4
0
 /**
  * Recursively call delete on the contents of a folder
  */
 private void DeleteFolder(Folder folder, Project project)
 {
     foreach (IFileSystemComponent component in folder.Children)
     {
         if (component.FileType == DocType.Document)
         {
             DocumentStruct doc = (DocumentStruct)component;
             DeleteDocument(selectedProject, ((DocumentStruct)component));
         }
         else if (component.FileType == DocType.Folder)
         {
             Folder fold = (Folder)component;
             DeleteFolder(fold, project);
         }
     }
 }
Пример #5
0
        /**
         * Called when something is selected, expanded or collapsed in the treeview
         * Sets the selected folder/document here
         */
        private void treeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            IFileSystemComponent fsc = (IFileSystemComponent)e.Node.Tag;

            if (fsc.FileType == DocType.Document) // If it's a document
            {
                isDocument       = true;
                selectedDocument = (DocumentStruct)fsc;
                selectedFolder   = (Folder)e.Node.Parent.Tag;
            }
            else // else, if it's a folder
            {
                isDocument     = false;
                selectedFolder = (Folder)e.Node.Tag;
            }

            // If a document was not selected, grey out the button
            if (isDocument)
            {
                openButton.Enabled = true;
            }
            else
            {
                openButton.Enabled = false;
            }

            // You can't rename, move or delete projects in the offline client
            if (selectedFolder.FileType == DocType.Project && !isDocument)
            {
                renameButton.Enabled = false;
                moveButton.Enabled   = false;
                deleteButton.Enabled = false;
            }
            else
            {
                renameButton.Enabled = true;
                moveButton.Enabled   = true;
                deleteButton.Enabled = true;
            }


            createDocumentButton.Enabled = true;
        }