Skip to content

Commit 194e8ac

Browse files
authored
Merge pull request #72 from Jack251970/dev
Improve code quality
2 parents c0193af + 6fa3752 commit 194e8ac

File tree

11 files changed

+52
-56
lines changed

11 files changed

+52
-56
lines changed

Editor/Constants.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ public static class Constants
77
public const string MathEditor = "MathEditor";
88
public const string MathEditorFullName = "Math Editor";
99

10-
public static string Version
11-
{
12-
get => field ??= Design.IsDesignMode ?
10+
public static string Version =>
11+
field ??= Design.IsDesignMode ?
1312
"1.0.0" :
1413
App.UpdateManager.CurrentVersion?.ToString() ?? "1.0.0";
15-
}
1614
public static readonly string Dev = "Dev";
1715

1816
public const string Settings = "Settings";

Editor/Equations/Common/UndoRedo/UndoManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ public partial class UndoManager : ObservableObject
1111
private readonly Stack<EquationAction> redoStack = new();
1212

1313
[ObservableProperty]
14-
private bool _canUndo;
14+
public partial bool CanUndo { get; set; }
1515

1616
[ObservableProperty]
17-
private bool _canRedo;
17+
public partial bool CanRedo { get; set; }
1818

1919
public void AddUndoAction(EquationAction equationAction)
2020
{

Editor/Helper/ClipboardHelper.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,11 @@ public class ClipboardHelper : ObservableObject, IDisposable
2323
private static readonly string ClipboardXmlFormatType =
2424
$"{typeof(MathEditorData).FullName}.{nameof(MathEditorData.XmlString)}";
2525

26-
private static ClipboardFormat<string> ClipboardXmlFormat
27-
{
28-
get => field ??= ClipboardFormat.CreateCustomFormat(ClipboardXmlFormatType, new TextUtf8Converter());
29-
}
26+
private static ClipboardFormat<string> ClipboardXmlFormat =>
27+
field ??= ClipboardFormat.CreateCustomFormat(ClipboardXmlFormatType, new TextUtf8Converter());
3028

31-
private static DataFormat<string> ClipboardXmlFormatA
32-
{
33-
get => field ??= DataFormat.CreateStringPlatformFormat(ClipboardXmlFormatType);
34-
}
29+
private static DataFormat<string> ClipboardXmlFormatA =>
30+
field ??= DataFormat.CreateStringPlatformFormat(ClipboardXmlFormatType);
3531

3632
private readonly Timer _timer = new(1000);
3733

Editor/Helper/ExceptionFormatter.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -556,13 +556,13 @@ private static string GetMacOsMarketingName(string version)
556556
12 => "Sierra",
557557
11 => "El Capitan",
558558
10 => "Yosemite",
559-
9 => "Mavericks",
560-
8 => "Mountain Lion",
561-
7 => "Lion",
562-
6 => "Snow Leopard",
563-
5 => "Leopard",
564-
4 => "Tiger",
565-
_ => "macOS"
559+
9 => "Mavericks",
560+
8 => "Mountain Lion",
561+
7 => "Lion",
562+
6 => "Snow Leopard",
563+
5 => "Leopard",
564+
4 => "Tiger",
565+
_ => "macOS"
566566
};
567567
}
568568

Editor/Languages/en.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@
232232
<x:String x:Key="MainWindow_NewVersionAvailable">New version {0} is available. Do you want to update it now?</x:String>
233233
<x:String x:Key="MainWindow_FailToDownloadUpdates">Failed to download updates</x:String>
234234
<x:String x:Key="MainWindow_UpdateDownloaded">The update has been downloaded. Do you want to restart the app now to apply the update?</x:String>
235+
<x:String x:Key="MainWindow_Unknown">Unknown</x:String>
235236

236237
<!-- Report Window -->
237238
<x:String x:Key="ReportWindow_AppGotError">App got an error</x:String>

Editor/Models/VelopackLogger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void Log(VelopackLogLevel logLevel, string? message, Exception? exception
3434
{
3535
if (_logEntries.Count > 0)
3636
{
37-
foreach (LogEntry logEntry in _logEntries)
37+
foreach (var logEntry in _logEntries)
3838
{
3939
LogToEditorLogger(logEntry.LogLevel, logEntry.Message, logEntry.Exception);
4040
}

Editor/ViewModels/CodepointWindowViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ public partial class CodepointWindowViewModel : ObservableObject, ICultureInfoCh
1515
public List<UnicodeFormatLocalized> AllUnicodeFormats { get; } = UnicodeFormatLocalized.GetValues();
1616

1717
[ObservableProperty]
18-
private UnicodeFormat _unicodeFormat = UnicodeFormat.Decimal;
18+
public partial UnicodeFormat UnicodeFormat { get; set; } = UnicodeFormat.Decimal;
1919

2020
[ObservableProperty]
21-
private string? _numberText = null;
21+
public partial string? NumberText { get; set; } = null;
2222

2323
public uint? Number { get; private set; } = null;
2424

Editor/ViewModels/CustomZoomWindowViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ public partial class CustomZoomWindowViewModel : ObservableObject
77
public int MaxPercentage { get; } = 9999;
88

99
[ObservableProperty]
10-
private int? _number = null;
10+
public partial int? Number { get; set; } = null;
1111
}

Editor/ViewModels/MainWindowViewModel.cs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ public partial class MainWindowViewModel : ObservableObject, ICultureInfoChanged
3131
private readonly Lock _fullScreenModeLock = new();
3232

3333
[ObservableProperty]
34-
private string _mainWindowTitle = null!;
34+
public partial string MainWindowTitle { get; set; } = null!;
3535

3636
[ObservableProperty]
37-
private string _currentLocalFile = null!;
37+
public partial string CurrentLocalFile { get; set; } = null!;
3838

3939
[ObservableProperty]
40-
private string _showNestingMenuItemHeader = null!;
40+
public partial string ShowNestingMenuItemHeader { get; set; } = null!;
4141

4242
public MainWindowViewModel(Settings settings, UndoManager undoManager, ClipboardHelper clipboardHelper,
4343
UpdateManager updateManager)
@@ -58,60 +58,60 @@ public MainWindowViewModel(Settings settings, UndoManager undoManager, Clipboard
5858
public List<EditorModeLocalized> AllEditModes { get; } = EditorModeLocalized.GetValues();
5959

6060
[ObservableProperty]
61-
private EditorMode _textEditorMode;
61+
public partial EditorMode TextEditorMode { get; set; }
6262

6363
public List<FontTypeLocalized> AllFontTypes { get; } = FontTypeLocalized.GetValues();
6464

6565
[ObservableProperty]
66-
private FontType _textFontType;
66+
public partial FontType TextFontType { get; set; }
6767

6868
[ObservableProperty]
69-
private bool _inputBold;
69+
public partial bool InputBold { get; set; }
7070

7171
[ObservableProperty]
72-
private bool _inputItalic;
72+
public partial bool InputItalic { get; set; }
7373

7474
[ObservableProperty]
75-
private bool _inputUnderline;
75+
public partial bool InputUnderline { get; set; }
7676

7777
[ObservableProperty]
78-
private bool _isSelecting;
78+
public partial bool IsSelecting { get; set; }
7979

8080
[ObservableProperty]
81-
private bool _useItalicIntergalOnNew;
81+
public partial bool UseItalicIntergalOnNew { get; set; }
8282

8383
[ObservableProperty]
84-
private bool _showUnderbar = true;
84+
public partial bool ShowUnderbar { get; set; } = true;
8585

8686
[ObservableProperty]
87-
private string _statusBarLeftMessage = string.Empty;
87+
public partial string StatusBarLeftMessage { get; set; } = string.Empty;
8888

8989
[ObservableProperty]
90-
private string _statusBarRightMessage = string.Empty;
90+
public partial string StatusBarRightMessage { get; set; } = string.Empty;
9191

9292
[ObservableProperty]
93-
private int _activeChildSelectionStartIndex = 0;
93+
public partial int ActiveChildSelectionStartIndex { get; set; } = 0;
9494

9595
[ObservableProperty]
96-
private int _activeChildSelectedItems = 0;
96+
public partial int ActiveChildSelectedItems { get; set; } = 0;
9797

9898
[ObservableProperty]
99-
private bool _fullScreenMode = false;
99+
public partial bool FullScreenMode { get; set; } = false;
100100

101101
[ObservableProperty]
102-
private string _fullScreenMenuItemHeader = null!;
102+
public partial string FullScreenMenuItemHeader { get; set; } = null!;
103103

104104
[ObservableProperty]
105-
private bool _fullScreenButtonVisible = false;
105+
public partial bool FullScreenButtonVisible { get; set; } = false;
106106

107107
[ObservableProperty]
108-
private int _customZoomPercentage = 0;
108+
public partial int CustomZoomPercentage { get; set; } = 0;
109109

110110
[ObservableProperty]
111-
private bool _customZoomMenuChecked = false;
111+
public partial bool CustomZoomMenuChecked { get; set; } = false;
112112

113113
[ObservableProperty]
114-
private string _customZoomMenuHeader = null!;
114+
public partial string CustomZoomMenuHeader { get; set; } = null!;
115115

116116
public bool IgnoreTextEditorModeChange { get; set; } = false;
117117
public bool IgnoreTextFontTypeChange { get; set; } = false;
@@ -450,7 +450,8 @@ await MessageBox.ShowAsync(Localize.MainWindow_UpToDate(), Localize.MainWindow_C
450450
return;
451451
}
452452

453-
var updateResult = await MessageBox.ShowAsync(Localize.MainWindow_NewVersionAvailable(newVersion.BaseRelease?.Version),
453+
var updateResult = await MessageBox.ShowAsync(
454+
Localize.MainWindow_NewVersionAvailable(newVersion.BaseRelease?.Version.ToString() ?? Localize.MainWindow_Unknown()),
454455
Localize.MainWindow_CheckForUpdates(), MessageBoxButton.YesNo, MessageBoxImage.Question);
455456
if (updateResult == MessageBoxResult.Yes)
456457
{

Editor/ViewModels/MatrixInputWindowViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ namespace Editor;
55
public partial class MatrixInputWindowViewModel : ObservableObject
66
{
77
[ObservableProperty]
8-
private int? _rows = 1;
8+
public partial int? Rows { get; set; } = 1;
99

1010
[ObservableProperty]
11-
private int? _columns = 1;
11+
public partial int? Columns { get; set; } = 1;
1212
}

0 commit comments

Comments
 (0)