Compare commits
3 Commits
1693d8882d
...
c0fd36c8de
Author | SHA1 | Date | |
---|---|---|---|
c0fd36c8de | |||
4df98148fa | |||
93d9dc7860 |
31
Avalonia.EliteBGS/Helper.cs
Normal file
31
Avalonia.EliteBGS/Helper.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using MsBox.Avalonia;
|
||||||
|
|
||||||
|
namespace EliteBGS;
|
||||||
|
|
||||||
|
public class Helper {
|
||||||
|
public static void MessageBox(Window owner, string caption, string text) {
|
||||||
|
var box = MessageBoxManager
|
||||||
|
.GetMessageBoxStandard(caption, text)
|
||||||
|
;
|
||||||
|
var result = box.ShowAsPopupAsync(owner);
|
||||||
|
result.Wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string? OpenFileDialog(Window owner) {
|
||||||
|
OpenFileDialog dlg = new OpenFileDialog();
|
||||||
|
|
||||||
|
dlg.AllowMultiple = false;
|
||||||
|
|
||||||
|
var result = dlg.ShowAsync(owner);
|
||||||
|
result.Wait();
|
||||||
|
var filename = result.Result;
|
||||||
|
|
||||||
|
if (filename == null || filename.Length <= 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return filename[0];
|
||||||
|
}
|
||||||
|
}
|
@ -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())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,9 +150,6 @@ public partial class MainWindow : Window {
|
|||||||
DateTime today = DateTime.Today;
|
DateTime today = DateTime.Today;
|
||||||
DateTime tomorrow = today.AddDays(1);
|
DateTime tomorrow = today.AddDays(1);
|
||||||
|
|
||||||
// HOCHKULTUR
|
|
||||||
startdate.Culture = enddate.Culture = CultureInfo.GetCultureInfo("de-AT");
|
|
||||||
|
|
||||||
startdate.SelectedDate = today;
|
startdate.SelectedDate = today;
|
||||||
enddate.SelectedDate = tomorrow;
|
enddate.SelectedDate = tomorrow;
|
||||||
}
|
}
|
||||||
@ -169,7 +166,7 @@ public partial class MainWindow : Window {
|
|||||||
builder.Append(message);
|
builder.Append(message);
|
||||||
builder.Append("\n");
|
builder.Append("\n");
|
||||||
|
|
||||||
log.AppendText(builder.ToString());
|
log.Text = log.Text + builder.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Log(string message) {
|
private void Log(string message) {
|
||||||
@ -364,7 +361,7 @@ public partial class MainWindow : Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshView() {
|
private void RefreshView() {
|
||||||
entries.Items.Refresh();
|
//entries.Items.Refresh();
|
||||||
GenerateLog();
|
GenerateLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,7 +521,7 @@ public partial class MainWindow : Window {
|
|||||||
startdate.SelectedDate = ResetTimeToZero(d.Value);
|
startdate.SelectedDate = ResetTimeToZero(d.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
d = enddate.SelectedDate;
|
d = enddate.SelectedDate?.Date;
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
enddate.SelectedDate = ResetTimeToZero(d.Value);
|
enddate.SelectedDate = ResetTimeToZero(d.Value);
|
||||||
}
|
}
|
||||||
@ -608,7 +605,7 @@ public partial class MainWindow : Window {
|
|||||||
Name = "Discord Server Name",
|
Name = "Discord Server Name",
|
||||||
Webhook = "..."
|
Webhook = "..."
|
||||||
});
|
});
|
||||||
Webhooks.Items.Refresh();
|
//Webhooks.Items.Refresh();
|
||||||
RefreshPostMenu();
|
RefreshPostMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -624,17 +621,17 @@ public partial class MainWindow : Window {
|
|||||||
foreach (var item in selection) {
|
foreach (var item in selection) {
|
||||||
Config.Global.Webhooks.Remove(item);
|
Config.Global.Webhooks.Remove(item);
|
||||||
}
|
}
|
||||||
Webhooks.Items.Refresh();
|
//Webhooks.Items.Refresh();
|
||||||
RefreshPostMenu();
|
RefreshPostMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Webhooks_KeyUp(object sender, KeyEventArgs e) {
|
private void Webhooks_KeyUp(object sender, KeyEventArgs e) {
|
||||||
DataGridCell cell = e.OriginalSource as DataGridCell;
|
DataGridCell cell = e.Source as DataGridCell;
|
||||||
/* We also get keypresses from DataGridCells that are currently
|
/* We also get keypresses from DataGridCells that are currently
|
||||||
* editing their content. Filter those out. We don't want to delete
|
* editing their content. Filter those out. We don't want to delete
|
||||||
* the row when the user presses DEL while editing the cells content
|
* the row when the user presses DEL while editing the cells content
|
||||||
*/
|
*/
|
||||||
if (cell == null || cell.IsEditing) {
|
if (cell == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (e.Key == Key.Delete) {
|
if (e.Key == Key.Delete) {
|
||||||
|
Loading…
Reference in New Issue
Block a user