// 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 what happens when you press on nodes in the TreeView protected void TreeView1_SelectedNodeChanged1(object sender, EventArgs e) { TreeView tw = (TreeView)sender; using (SliceOfPieClient.Service.SliceOfPieServiceClient serv = new SliceOfPieClient.Service.SliceOfPieServiceClient()) { // Checks if its a document that has been pressed, else do nothing if (tw.SelectedNode.ChildNodes.Count == 0) { // Clears the Text on the Editor ImageBox.Text = ""; // Opens the clicked document and sets the properties Document selectedDoc = serv.OpenDocumentOnServer(activeProject.Id, tw.SelectedNode.Value); DocumentTextBox.Text = selectedDoc.Text; DocumentNameBox.Text = selectedDoc.Title; activeDoc = selectedDoc; // If it has images attached it lists them, else it doesnt show the imagebox if (selectedDoc.Images.Count != 0) { UpdateImagePanel(); ImagesCurrentlyBox.Visible = true; ImageBox.Visible = true; } DocumentTextBox.Visible = true; TextButton.Visible = true; LogButton.Visible = true; } // Keeps track of the path selected if its a folder else { if (tw.SelectedNode.Parent != null) { string path = tw.SelectedNode.ValuePath; currentPath = path.Substring(activeProject.Id.Length + 1); FolderBox.Text = path.Substring(activeProject.Id.Length + 1); } else { string path = tw.SelectedNode.Text; FolderBox.Text = path; // Keeps track of the current path path = tw.SelectedNode.Text; currentPath = path; } } ButtonPanel2.Visible = true; } DocumentTextBox.Enabled = true; }
// The delete was confirmed and a call to the server is made to delete the activeProject protected void ConfirmDeleteProj_Click(object sender, EventArgs e) { using (SliceOfPieClient.Service.SliceOfPieServiceClient serv = new SliceOfPieClient.Service.SliceOfPieServiceClient()) { serv.DeleteProject(activeProject.Id, WelcomeForm.active); UpdateProjects(); UpdateTreeView(""); DynamicPanelInvisible(); DynamicProjectPanelInvisible(); 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); } }
//The Delete was accepted protected void AcceptDeleteButton_Click(object sender, EventArgs e) { using (SliceOfPieClient.Service.SliceOfPieServiceClient serv = new SliceOfPieClient.Service.SliceOfPieServiceClient()) { serv.DeleteDocument(activeProject.Id, activeDoc.Id, WelcomeForm.active); // Turns the panels invisible DynamicPanelInvisible(); DynamicProjectPanelInvisible(); // Updates the view UpdateProjects(); UpdateTreeView(activeProject.Id); // And expands the tree for the user TreeView1.ExpandAll(); } }
// The user submitted a username to share the project with protected void SubmitUserButton_Click(object sender, EventArgs e) { using (SliceOfPieClient.Service.SliceOfPieServiceClient serv = new SliceOfPieClient.Service.SliceOfPieServiceClient()) { if (activeProject != null) { // creates a new user and adds it to the activeProject and calls the UpdateProject method User u = new User(UserNameBox.Text); activeProject.SharedWith.Add(u); serv.SaveProjectOnServer(activeProject, WelcomeForm.active); } DynamicPanelInvisible(); DynamicProjectPanelInvisible(); } }
// 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(); }
// 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(); }
// A method that is run occasionally after we made changes to a project private void UpdateProjects() { // We empty the dropdownlist with project ProjectDropDown.Items.Clear(); // Get all the projects by the current user if (WelcomeForm.active != null) { using (SliceOfPieClient.Service.SliceOfPieServiceClient serv = new SliceOfPieClient.Service.SliceOfPieServiceClient()) { projects = serv.GetAllProjectsOnServer(WelcomeForm.active); ProjectDropDown.Items.Add(""); foreach (Project p in projects) { ListItem li = new ListItem(p.Title, p.Id); ProjectDropDown.Items.Add(li); } AccessTextBox.Text = "Choose one of your projects"; } } }