示例#1
0
        public override bool Equals(object obj)
        {
            if (!(obj is DocumentStruct))
            {
                return(false);
            }
            DocumentStruct d = (DocumentStruct)obj;

            if (this.Id == d.Id && this.Path == d.Path && this.Title == d.Title && this.FileType == d.FileType)
            {
                return(true);
            }
            return(false);
        }
示例#2
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;
        }
示例#3
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);
        }
示例#4
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);
 }