Example #1
0
        private void save_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(this.errorTitle.Text) || string.IsNullOrEmpty(this.errorText.Text))
            {
                MessageBox.Show(
                    "You must provide a title and exception details.",
                    "Save Error",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
            }
            else
            {
                var entry = new ExceptionEntry
                {
                    Title   = this.errorTitle.Text,
                    Details = this.errorText.Text
                };

                var savePath = this.GenerateSavePath();

                ExceptionSerializer.Serialize(entry, savePath);

                MessageBox.Show(
                    "Exception saved.",
                    "Save Successful",
                    MessageBoxButton.OK,
                    MessageBoxImage.Information);

                this.ResetUI();
                this.LoadExistingEntries();
            }
        }
Example #2
0
        private void load_Click(object sender, RoutedEventArgs e)
        {
            var fileToLoad = this.files.SelectedValue as string;

            if (string.IsNullOrEmpty(fileToLoad))
            {
                MessageBox.Show(
                    "You must select a file.",
                    "Load Error",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
            }
            else if (!File.Exists(fileToLoad))
            {
                MessageBox.Show(
                    "Could not find the file specified.",
                    "Load Error",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
            }
            else
            {
                var entry = ExceptionSerializer.Deserialize(fileToLoad);

                this.errorTitle.Text = entry.Title;
                this.errorText.Text  = entry.Details;
                this._filePath       = fileToLoad;
            }
        }
        private IEnumerable <ExceptionEntry> GetAllExceptions()
        {
            var sourceFiles = Directory.GetFiles(this._exceptionsRootPath, "*.txt");

            foreach (var file in sourceFiles)
            {
                yield return(ExceptionSerializer.Deserialize(file));
            }
        }