fix LoadEntries window
This commit is contained in:
parent
4df98148fa
commit
c0fd36c8de
@ -1,5 +1,5 @@
|
|||||||
<Window x:Class="EliteBGS.LoadEntriesWindow"
|
<Window x:Class="EliteBGS.LoadEntriesWindow"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
@ -3,6 +3,7 @@ using System.Linq;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
|
using Avalonia.Platform.Storage;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
@ -47,8 +48,12 @@ public partial class LoadEntriesWindow : Window {
|
|||||||
EntriesLoaded?.Invoke(entries);
|
EntriesLoaded?.Invoke(entries);
|
||||||
}
|
}
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
MessageBox.Show(string.Format("There was an error while parsing the JSON: {0}",
|
Helper.MessageBox(
|
||||||
exception.ToString()));
|
this, "Error",
|
||||||
|
string.Format(
|
||||||
|
"There was an error while parsing the JSON: {0}",
|
||||||
|
exception.ToString())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,23 +62,14 @@ public partial class LoadEntriesWindow : Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void LoadFile_Click(object sender, RoutedEventArgs e) {
|
private void LoadFile_Click(object sender, RoutedEventArgs e) {
|
||||||
OpenFileDialog dialog = new OpenFileDialog();
|
string? filename = Helper.OpenFileDialog(this);
|
||||||
|
|
||||||
dialog.DefaultExt = ".log";
|
if (string.IsNullOrEmpty(filename)) {
|
||||||
dialog.Filter = "Log files (*.log)|*.log|All files (*.*)|*";
|
|
||||||
|
|
||||||
var location = AppConfig.DefaultJournalLocation;
|
|
||||||
if (Directory.Exists(location)) {
|
|
||||||
dialog.InitialDirectory = location;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool result = dialog.ShowDialog(this) ?? false;
|
|
||||||
if (!result) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
using (FileStream stream = File.OpenRead(dialog.FileName)) {
|
using (FileStream stream = File.OpenRead(filename)) {
|
||||||
using (StreamReader reader = new StreamReader(stream)) {
|
using (StreamReader reader = new StreamReader(stream)) {
|
||||||
Lines.Text = reader.ReadToEnd();
|
Lines.Text = reader.ReadToEnd();
|
||||||
}
|
}
|
||||||
@ -113,8 +109,11 @@ public partial class LoadEntriesWindow : Window {
|
|||||||
;
|
;
|
||||||
Lines.Text = string.Join("\n", text).Trim();
|
Lines.Text = string.Join("\n", text).Trim();
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
MessageBox.Show(string.Format("There was an error while parsing the JSON: {0}",
|
Helper.MessageBox(
|
||||||
exception.ToString()));
|
"Error",
|
||||||
|
string.Format("There was an error while parsing the JSON: {0}",
|
||||||
|
exception.ToString())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user