|
1 | 1 | using System; |
| 2 | +using System.ComponentModel; |
2 | 3 | using System.Diagnostics; |
3 | 4 | using System.Drawing; |
4 | 5 | using System.Globalization; |
5 | 6 | using System.Reflection; |
| 7 | +using System.Runtime.CompilerServices; |
6 | 8 | using System.Windows; |
7 | 9 | using System.Windows.Data; |
8 | 10 | using System.Windows.Interop; |
9 | 11 | using System.Windows.Media.Imaging; |
| 12 | +using D_OS_Save_Editor.Annotations; |
10 | 13 |
|
11 | 14 | namespace D_OS_Save_Editor |
12 | 15 | { |
13 | 16 | /// <summary> |
14 | 17 | /// Interaction logic for ErrorReporting.xaml |
15 | 18 | /// </summary> |
16 | | - public partial class ErrorReporting |
| 19 | + public partial class ErrorReporting : INotifyPropertyChanged |
17 | 20 | { |
18 | | - public ErrorModel ErrorModel; |
| 21 | + private string _errorMessage; |
| 22 | + private object _errorData; |
| 23 | + private string _message = "An error has occurred."; |
| 24 | + |
| 25 | + public string ErrorMessage |
| 26 | + { |
| 27 | + get => _errorMessage; |
| 28 | + set |
| 29 | + { |
| 30 | + _errorMessage = value; |
| 31 | + OnPropertyChanged(); |
| 32 | + } |
| 33 | + } |
| 34 | + |
| 35 | + public object ErrorData |
| 36 | + { |
| 37 | + get => _errorData; |
| 38 | + set |
| 39 | + { |
| 40 | + _errorData = value; |
| 41 | + OnPropertyChanged(); |
| 42 | + } |
| 43 | + } |
| 44 | + |
| 45 | + public string Message |
| 46 | + { |
| 47 | + get => _message; |
| 48 | + set |
| 49 | + { |
| 50 | + if (value == _message) return; |
| 51 | + _message = value; |
| 52 | + OnPropertyChanged(); |
| 53 | + } |
| 54 | + } |
| 55 | + |
19 | 56 | public ErrorReporting() |
20 | 57 | { |
21 | 58 | InitializeComponent(); |
22 | | - ErrorModel = new ErrorModel(); |
23 | | - DataContext = ErrorModel; |
| 59 | + DataContext = this; |
24 | 60 | } |
25 | 61 |
|
26 | | - public ErrorReporting(string message, object data) |
| 62 | + public ErrorReporting(string message, string exceptionMessage, object data) |
27 | 63 | { |
28 | 64 | InitializeComponent(); |
29 | | - ErrorModel = new ErrorModel(message, data); |
30 | | - DataContext = ErrorModel; |
| 65 | + |
| 66 | + Message = message; |
| 67 | + ErrorMessage = exceptionMessage; |
| 68 | + _errorData = data; |
| 69 | + DataContext = this; |
| 70 | + } |
| 71 | + |
| 72 | + public ErrorReporting(string exceptionMessage, object data) |
| 73 | + { |
| 74 | + InitializeComponent(); |
| 75 | + |
| 76 | + _errorMessage = exceptionMessage; |
| 77 | + _errorData = data; |
| 78 | + DataContext = this; |
31 | 79 | } |
32 | 80 |
|
33 | 81 | private void ReportButtonClicked(object sender, RoutedEventArgs e) |
34 | 82 | { |
35 | | - Clipboard.SetText($"{ErrorModel.ErrorMessage}\n\n{MainWindow.Version}"); |
| 83 | + Clipboard.SetText($"{ErrorMessage}\n\n{MainWindow.Version}"); |
36 | 84 | Process.Start( |
37 | 85 | @"https://docs.google.com/forms/d/e/1FAIpQLSeUeKYdV8InQslbvCvA1rmffJ5t1ieond4W6hpUHkHTH7I7dg/viewform?usp=pp_url&entry.1687355392=Error+report"); |
38 | 86 | Close(); |
39 | 87 | } |
40 | | - } |
41 | | - |
42 | | - public class ErrorModel |
43 | | - { |
44 | | - public string ErrorMessage { get; set; } |
45 | | - public object ErrorData { get; set; } |
46 | 88 |
|
47 | | - public ErrorModel() |
48 | | - { |
49 | | - } |
| 89 | + public event PropertyChangedEventHandler PropertyChanged; |
50 | 90 |
|
51 | | - public ErrorModel(string message, object data) |
| 91 | + [NotifyPropertyChangedInvocator] |
| 92 | + protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) |
52 | 93 | { |
53 | | - ErrorMessage = message; |
54 | | - ErrorData = data; |
| 94 | + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); |
55 | 95 | } |
56 | 96 | } |
57 | 97 |
|
|
0 commit comments