Code cleanup

This commit is contained in:
2024-11-16 22:22:50 +01:00
parent 711d20bf72
commit 6afee1c570

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Avalonia.Controls; using Avalonia.Controls;
@@ -18,6 +19,8 @@ public partial class MainWindow : Window
} }
private async void BtnLoad_OnClick(object? sender, RoutedEventArgs e) private async void BtnLoad_OnClick(object? sender, RoutedEventArgs e)
{
try
{ {
TopLevel? topLevel = GetTopLevel(this); TopLevel? topLevel = GetTopLevel(this);
if (topLevel == null) { return; } if (topLevel == null) { return; }
@@ -28,8 +31,8 @@ public partial class MainWindow : Window
AllowMultiple = false, AllowMultiple = false,
FileTypeFilter = new List<FilePickerFileType> FileTypeFilter = new List<FilePickerFileType>
{ {
new("CSV Files") { Patterns = new[] { "*.csv", }, }, new("CSV Files") { Patterns = ["*.csv",], },
new("Any File") { Patterns = new[] { "*", }, }, new("Any File") { Patterns = ["*",], },
}, },
}); });
@@ -37,6 +40,11 @@ public partial class MainWindow : Window
LoadFile(files[0].Path.LocalPath); LoadFile(files[0].Path.LocalPath);
} }
catch (Exception)
{
// ignored
}
}
private void BtnSearch_OnClick(object? sender, RoutedEventArgs e) private void BtnSearch_OnClick(object? sender, RoutedEventArgs e)
{ {
@@ -71,7 +79,7 @@ public partial class MainWindow : Window
private string _loadedFile = string.Empty; private string _loadedFile = string.Empty;
private long _currentReg; private long _currentReg;
private int _totalRegs; private int _totalRegs;
private List<long> _index = new(); private List<long> _index = [];
private void LoadFile(string fileName) private void LoadFile(string fileName)
{ {
@@ -118,7 +126,7 @@ public partial class MainWindow : Window
BtnNext.IsEnabled = false; BtnNext.IsEnabled = false;
BtnLast.IsEnabled = false; BtnLast.IsEnabled = false;
DataContext = new MainWindowViewModel { Index = 0, Fields = new(), }; DataContext = new MainWindowViewModel { Index = 0, Fields = [], };
_rendering = false; _rendering = false;
return; return;
} }