mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-03-06 06:56:06 +00:00
Cleanup GUI
This commit is contained in:
@@ -7,20 +7,41 @@ public class MessageBoxViewModel : DialogScreen
|
||||
public string? Title { get; set; }
|
||||
|
||||
public string? Message { get; set; }
|
||||
|
||||
public bool IsOkButtonVisible { get; set; } = true;
|
||||
|
||||
public string? OkButtonText { get; set; }
|
||||
|
||||
public bool IsCancelButtonVisible { get; set; }
|
||||
|
||||
public string? CancelButtonText { get; set; }
|
||||
|
||||
public int ButtonsCount =>
|
||||
(IsOkButtonVisible ? 1 : 0) +
|
||||
(IsCancelButtonVisible ? 1 : 0);
|
||||
}
|
||||
|
||||
public static class MessageBoxViewModelExtensions
|
||||
{
|
||||
public static MessageBoxViewModel CreateMessageBoxViewModel(
|
||||
this IViewModelFactory factory,
|
||||
string title,
|
||||
string message)
|
||||
string title, string message,
|
||||
string? okButtonText, string? cancelButtonText)
|
||||
{
|
||||
var viewModel = factory.CreateMessageBoxViewModel();
|
||||
|
||||
viewModel.Title = title;
|
||||
viewModel.Message = message;
|
||||
|
||||
viewModel.IsOkButtonVisible = !string.IsNullOrWhiteSpace(okButtonText);
|
||||
viewModel.OkButtonText = okButtonText;
|
||||
viewModel.IsCancelButtonVisible = !string.IsNullOrWhiteSpace(cancelButtonText);
|
||||
viewModel.CancelButtonText = cancelButtonText;
|
||||
|
||||
return viewModel;
|
||||
}
|
||||
|
||||
public static MessageBoxViewModel CreateMessageBoxViewModel(
|
||||
this IViewModelFactory factory,
|
||||
string title, string message) =>
|
||||
factory.CreateMessageBoxViewModel(title, message, "CLOSE", null);
|
||||
}
|
||||
@@ -71,6 +71,23 @@ public class RootViewModel : Screen
|
||||
Progress.Bind(o => o.Current, (_, _) => NotifyOfPropertyChange(() => IsProgressIndeterminate));
|
||||
}
|
||||
|
||||
private async Task ShowWarInUkraineMessageAsync()
|
||||
{
|
||||
var dialog = _viewModelFactory.CreateMessageBoxViewModel(
|
||||
"Ukraine is at war!", @"
|
||||
My country, Ukraine, has been invaded by Russian military forces in an act of aggression that can only be described as genocide.
|
||||
Be on the right side of history! Consider supporting Ukraine in its fight for freedom.
|
||||
|
||||
Press LEARN MORE to find ways that you can help.".Trim(),
|
||||
"LEARN MORE", "CLOSE"
|
||||
);
|
||||
|
||||
if (await _dialogManager.ShowDialogAsync(dialog) == true)
|
||||
{
|
||||
ProcessEx.StartShellExecute("https://tyrrrz.me");
|
||||
}
|
||||
}
|
||||
|
||||
private async ValueTask CheckForUpdatesAsync()
|
||||
{
|
||||
try
|
||||
@@ -97,6 +114,12 @@ public class RootViewModel : Screen
|
||||
Notifications.Enqueue("Failed to perform application update");
|
||||
}
|
||||
}
|
||||
|
||||
// This is a custom event that fires when the dialog host is loaded
|
||||
public async void OnViewFullyLoaded()
|
||||
{
|
||||
await ShowWarInUkraineMessageAsync();
|
||||
}
|
||||
|
||||
protected override async void OnViewLoaded()
|
||||
{
|
||||
@@ -118,19 +141,6 @@ public class RootViewModel : Screen
|
||||
App.SetLightTheme();
|
||||
}
|
||||
|
||||
// War in Ukraine message
|
||||
Notifications.Enqueue(
|
||||
"⚠ Ukraine is at war! Support my country in its fight for freedom",
|
||||
"LEARN MORE", _ =>
|
||||
{
|
||||
ProcessEx.StartShellExecute("https://tyrrrz.me");
|
||||
},
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
TimeSpan.FromMinutes(1)
|
||||
);
|
||||
|
||||
await CheckForUpdatesAsync();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user