private void b_Delete_Click(object sender, RoutedEventArgs e)
 {
     ConfirmationDialog window = new ConfirmationDialog("Are you sure you wish to delete this log?");
     if (window.ShowDialog() == true)
     {
         // Delete the log and return
         Log.ParentProject.RemoveLogEntry(Log);
         DialogResult = true;
     }
 }
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // If we quit from the 'More Options' screen, apply the UI settings
            if (Content is MoreOptions)
            {
                ((MoreOptions)Content).ApplySettingsToUserSettings();
            }

            // Write the settings
            ProjectFileInterface.WriteSettingsToFile();

            // Check if any projects have incomplete logs
            if (UserSettings.DisplayIncompleteLogWarning)
            {
                foreach (var project in ProjectOrganizer.Projects)
                {
                    // If the project has an incomplete log, ask the user if they want to complete it
                    if (project.IncompleteLog != null)
                    {
                        ConfirmationDialog incLogDialog = new ConfirmationDialog(string.Format(
                            "Project '{0}' has an incomplete log. Do you wish to complete it?", project.Name));

                        // If they do, finish it
                        if (incLogDialog.ShowDialog() == true)
                        {
                            project.FinishIncompleteLog();
                        }
                    }
                }
            }

            // Write the projects
            ProjectFileInterface.WriteAllProjectData();

            // If errors occured, tell the user
            if (ErrorLogger.ErrorsOccured)
            {
                NotificationDialog window = new NotificationDialog("Errors Occured",
                    string.Format("Errors occured during this session. Please view the log file at\n\n{0}\n\nto see which errors occurred.", ErrorLogger.ErrorLogFilename));
                window.Show();
            }
        }
 private void b_Delete_Click(object sender, RoutedEventArgs e)
 {
     ConfirmationDialog window = new ConfirmationDialog("Are you sure you wish to delete this file?");
     if (window.ShowDialog() == true)
     {
         // Delete the file and return
         CurrentFile.ParentProject.RemoveFileEntry(CurrentFile);
         DialogResult = true;
     }
 }
        /// <summary>
        /// Clears the current project's data based on the checkboxes on the UI.
        /// </summary>
        private bool ClearData()
        {
            // Get the items to clear from the UI
            bool clearNotes = cb_ClearNotes.IsChecked == true;
            bool clearLogs = cb_ClearLogs.IsChecked == true;
            bool clearFiles = cb_ClearFiles.IsChecked == true;

            // Make sure we're clearing something
            if (!clearNotes && !clearLogs && !clearFiles)
            {
                // This is still counted as a success; we "successfully didn't" clear data, and the user should have
                // the result that he or she wants.
                return true;
            }

            // Confirm action with the user
            StringBuilder itemsToClearText = new StringBuilder();
            if (clearNotes)
            {
                itemsToClearText.Append(" - Project Notes\n");
            }
            if (clearLogs)
            {
                itemsToClearText.Append(" - Project Logs\n");
            }
            if (clearFiles)
            {
                itemsToClearText.Append(" - Project Files\n");
            }
            string confirmationText = string.Format("Are you sure you wish to clear the following items?\n{0}", itemsToClearText.ToString().TrimEnd());

            ConfirmationDialog window = new ConfirmationDialog(confirmationText);

            // Clear the data
            if (window.ShowDialog() == true)
            {
                RefreshProjectDataOnUI = true;

                // Notes
                if (clearNotes)
                {
                    ProjectFileInterface.ResetNotesFile(CurrentProject);
                }

                // Logs
                if (clearLogs)
                {
                    CurrentProject.IncompleteLog = null;
                    CurrentProject.CompletedLogs = new List<ProjectLog>();
                }

                // Files
                if (clearFiles)
                {
                    CurrentProject.Files = new List<ProjectFile>();
                }

                return true;
            }

            // Don't clear the data
            else
            {
                // The user may want to select a different set of data to clear
                return false;
            }
        }
 private void b_Delete_Click(object sender, RoutedEventArgs e)
 {
     ConfirmationDialog window = new ConfirmationDialog("Are you sure you wish to delete this project?");
     if (window.ShowDialog() == true)
     {
         // Caller is responsible for deleting the project
         DeleteProject = true;
         DialogResult = true;
     }
 }
        /// <summary>
        /// Change's the directory for the project data.
        /// </summary>
        /// <param name="newDir">The new directory for the data.</param>
        private void ChangeDataDirectory(string newDir)
        {
            string oldDir = DataDirectory;

            // Check to see if new dir is empty
            if (Directory.EnumerateFiles(newDir).Any())
            {
                // If it's not empty, warn the user that overwrites may occur
                ConfirmationDialog dialog = new ConfirmationDialog(string.Format(
                    "{0} is not empty. Any files it contains may be overwritten. Proceed?", newDir));
                if (dialog.ShowDialog() != true)
                {
                    // If the user opted not to proceed, abort the operation
                    return;
                }
            }

            // Make sure all the project notes are saved before we copy
            NotificationDialog notifDialog = new NotificationDialog("Save Data", "Please save all project notes files. Press OK when all files are saved.");
            notifDialog.ShowDialog();

            // Write all project data to make sure that it's current
            ProjectFileInterface.WriteAllProjectData();

            // Copy the data to the new directory
            CopyDirectoryRecursively(oldDir, newDir, true);

            // At the end, set the new directory and rename the files in PFI
            DataDirectory = newDir;
            UserSettings.DataDirectory = newDir;
            ProjectFileInterface.RenameFullFilenamesForDataDirectoryChange();

            // Let the user know that the operation was successful
            notifDialog = new NotificationDialog("Success", "Data directory successfully changed.");
            notifDialog.ShowDialog();
        }
 private void b_Defaults_Click(object sender, RoutedEventArgs e)
 {
     ConfirmationDialog window = new ConfirmationDialog("Are you sure you wish to reset all settings to their default values?");
     if (window.ShowDialog() == true)
     {
         UserSettings.ResetToDefaults();
         SetUpUIFromUserSettings();
     }
 }
 private void b_ClearProjects_Click(object sender, RoutedEventArgs e)
 {
     ConfirmationDialog window = new ConfirmationDialog("Are you absolutely sure you want to delete all projects?");
     if (window.ShowDialog() == true)
     {
         ProjectOrganizer.RemoveAllProjects();
     }
 }