/// <summary> /// MenuItem New click event /// Calls createAlbum and and enables menu items if successfull. Updates album tree list. Displays errors if can't access files /// Cavan /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void newToolStripMenuItem_Click(object sender, EventArgs e) { string albumName; Form_NewFileDialog namePrompt = new Form_NewFileDialog(_albumData.getAlbumList(), _constantFileType); namePrompt.ShowDialog(); albumName = namePrompt.albumNameValue; //Retrieve name entered by user namePrompt.Dispose(); if (albumName != "") //Create File if user pressed create { //Attmpe to close file if (albumClose()) { //Create new album if (_albumData.createAlbum(albumName)) { enableItems(); //enables menu items _albumData.filePath = _directoryCurrentUser + "\\" + albumName + _constantFileType; //sets current file path populateTree(); updateStatusBar();//"Current User: "******" || "+ _constantAppName + " : " + Utilities.getNameFromPath(_albumData.filePath)); saveAlbum(); // save the album right away so we save the data structure properly } else { handleError("Failed to create album"); } } else { handleError("Unable to access file to save"); } } }
/// <summary> /// Closes current album. creates name prompt. Retrieves user entered value. Calls loadAlbum passing album name. /// Calls deleteAlbum, to delete the album file. Calls saveAlbum, to write file with the new name. /// Calls error handler if any files cannot be accessed /// </summary> private void renameAlbum() { string newAlbumName; Form_NewFileDialog namePrompt = new Form_NewFileDialog(_albumData.getAlbumList(), _constantFileType); namePrompt.Text = "Rename Album"; namePrompt.setValueOfCreate = "Rename"; namePrompt.ShowDialog(); newAlbumName = namePrompt.albumNameValue; namePrompt.Dispose(); if (_albumData.currentAlbum != "" && newAlbumName != "") //make sure we have an open album { if (albumClose()) { _albumData.loadAlbum(_treeNode.Name); if (_albumData.deleteAlbum(_treeNode.Name)) { _albumData.filePath = _directoryCurrentUser + "\\" + newAlbumName + _constantFileType; saveAlbum(); populateTree(); _pictureList.Clear(); openAlbum(_albumData.filePath); populateScreen(); populateList(); updateStatusBar(); } else { handleError( "Unable to access file to delete"); } } else { handleError("Unable to access file to save"); } } }