// The upload picture buttonw as pressed protected void UploadButton_Click(object sender, EventArgs e) { using (SliceOfPieClient.Service.SliceOfPieServiceClient serv = new SliceOfPieClient.Service.SliceOfPieServiceClient()) { //First it check if a file was selected if (FileUploadControl.HasFile) { // gets the file name string ImgName = System.IO.Path.GetFileName(FileUploadControl.FileName); // It saves the picture on the filesystem string ThisImg = Server.MapPath("~/images/" + ImgName); FileUploadControl.SaveAs(ThisImg); // It creates a new bitmap, and then a new object of our own Picture class Bitmap bm = new Bitmap(ThisImg); Picture pic = new Picture(bm); // Finally adds the image to the documents imagelist if (activeDoc != null) { activeDoc.Images.Add(pic); } } // It also saves the document to the server, after the picture is added serv.SaveDocumentOnServer(activeProject, activeDoc, WelcomeForm.active); // Updates the panel in which you can see which pictures are added, so you can see it as soon as you click upload UpdateImagePanel(); ImagesCurrentlyBox.Visible = true; ImageBox.Visible = true; } }
// This is the Submit button for creating new documents or folders protected void SubmitTitle_Click(object sender, EventArgs e) { //Checks if there is a folder and a document name if (FolderBox.Text.CompareTo("") != 0 || TitleBox.Text.CompareTo("") != 0 || activeProject != null) { using (SliceOfPieClient.Service.SliceOfPieServiceClient serv = new SliceOfPieClient.Service.SliceOfPieServiceClient()) { // Text value is Submit then its the new document if (SubmitTitle.Text.CompareTo("Submit") == 0) { string title = TitleBox.Text; DynamicPanelInvisible(); DynamicProjectPanelInvisible(); Document doc = new Document("Insert your text here", TitleBox.Text, currentPath, WelcomeForm.active); serv.SaveDocumentOnServer(activeProject, doc, WelcomeForm.active); // Updates the projects and treeview so it refreshes as it is done UpdateProjects(); UpdateTreeView(activeProject.Id); } // Text value is enter so it has to create a folder. else if (SubmitTitle.Text.CompareTo("Enter") == 0) { // Create Document actually creates a folder if given a nonexisting path if (FolderBox.Text.CompareTo(activeProject.Title) == 0) { Document doc = new Document("Insert your text here", "New Document", TitleBox.Text, WelcomeForm.active); serv.SaveDocumentOnServer(activeProject, doc, WelcomeForm.active); } else { Document doc = new Document("Insert your text here", "New Document", currentPath + "/" + TitleBox.Text, WelcomeForm.active); serv.SaveDocumentOnServer(activeProject, doc, WelcomeForm.active); } } UpdateProjects(); UpdateTreeView(activeProject.Id); } } DynamicPanelInvisible(); DynamicProjectPanelInvisible(); // Expands the treeview TreeView1.ExpandAll(); }
// Save Document Button was pressed it calls the savedocument so it is saved on the system protected void SaveDocumentButton_Click(object sender, EventArgs e) { if (activeDoc != null) { using (SliceOfPieClient.Service.SliceOfPieServiceClient serv = new SliceOfPieClient.Service.SliceOfPieServiceClient()) { activeDoc.Text = DocumentTextBox.Text; serv.SaveDocumentOnServer(activeProject, activeDoc, WelcomeForm.active); } UpdateProjects(); UpdateTreeView(activeProject.Id); } }
// Submit Button was pressed for either a new project or rename a project protected void SubmitProjectButton_Click(object sender, EventArgs e) { using (SliceOfPieClient.Service.SliceOfPieServiceClient serv = new SliceOfPieClient.Service.SliceOfPieServiceClient()) { if (activeProject != null) { //rename project if (SubmitProjectButton.Text.CompareTo("Submit") == 0) { activeProject.Title = NewProjectNameBox.Text; serv.SaveProjectOnServer(activeProject, WelcomeForm.active); UpdateProjects(); UpdateTreeView(activeProject.Id); DynamicPanelInvisible(); DynamicProjectPanelInvisible(); } //Create new Project else if (SubmitProjectButton.Text.CompareTo("Enter") == 0) { // Empty list for the users the document is shared with List <User> l = new List <User>(); Project p = new Project(NewProjectNameBox.Text, WelcomeForm.active, l); serv.SaveProjectOnServer(p, WelcomeForm.active); } // Rename a single document else if (SubmitProjectButton.Text.CompareTo("Rename") == 0) { activeDoc.Title = NewProjectNameBox.Text; serv.SaveDocumentOnServer(activeProject, activeDoc, WelcomeForm.active); UpdateProjects(); UpdateTreeView(activeProject.Id); DynamicPanelInvisible(); DynamicProjectPanelInvisible(); } // Everything turns invisble again and the view is updated UpdateProjects(); TreeView1.ExpandAll(); } } DynamicPanelInvisible(); DynamicProjectPanelInvisible(); }