From 3451623523cbf66899a2f7246738d5608b95bf7a Mon Sep 17 00:00:00 2001 From: bluepilledgreat <97983689+bluepilledgreat@users.noreply.github.com> Date: Fri, 6 Oct 2023 20:43:13 +0100 Subject: [PATCH 1/2] add close roblox option to context menu --- Bloxstrap/Bootstrapper.cs | 2 ++ .../Elements/ContextMenu/MenuContainer.xaml | 1 + .../ContextMenu/MenuContainer.xaml.cs | 23 ++++++++++++++++++- Bloxstrap/UI/NotifyIconWrapper.cs | 11 ++++++++- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 5af684d..3a3e45e 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -336,6 +336,8 @@ namespace Bloxstrap return; } + App.NotifyIcon?.SetProcessId(gameClientPid); + if (App.Settings.Prop.EnableActivityTracking) { activityWatcher = new(); diff --git a/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml b/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml index 58d48b3..57365d5 100644 --- a/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml +++ b/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml @@ -61,6 +61,7 @@ + diff --git a/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs b/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs index f2b8df0..00bbb0f 100644 --- a/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs +++ b/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs @@ -26,14 +26,16 @@ namespace Bloxstrap.UI.Elements.ContextMenu private LogTracer? _logTracerWindow; private ServerInformation? _serverInformationWindow; + private int? _processId; - public MenuContainer(ActivityWatcher? activityWatcher, DiscordRichPresence? richPresenceHandler) + public MenuContainer(ActivityWatcher? activityWatcher, DiscordRichPresence? richPresenceHandler, int? processId) { InitializeComponent(); ApplyTheme(); _activityWatcher = activityWatcher; _richPresenceHandler = richPresenceHandler; + _processId = processId; if (_activityWatcher is not null) { @@ -47,6 +49,9 @@ namespace Bloxstrap.UI.Elements.ContextMenu if (_richPresenceHandler is not null) RichPresenceMenuItem.Visibility = Visibility.Visible; + if (_processId is not null) + CloseRobloxMenuItem.Visibility = Visibility.Visible; + VersionTextBlock.Text = $"{App.ProjectName} v{App.Version}"; } @@ -118,5 +123,21 @@ namespace Bloxstrap.UI.Elements.ContextMenu _logTracerWindow.Activate(); } + + private void CloseRobloxMenuItem_Click(object sender, RoutedEventArgs e) + { + MessageBoxResult result = Controls.ShowMessageBox( + "Are you sure you want to close Roblox?", + MessageBoxImage.Warning, + MessageBoxButton.YesNo + ); + + if (result != MessageBoxResult.Yes) + return; + + using Process process = Process.GetProcessById((int)_processId!); + process.CloseMainWindow(); + process.Close(); + } } } diff --git a/Bloxstrap/UI/NotifyIconWrapper.cs b/Bloxstrap/UI/NotifyIconWrapper.cs index 6eb8e06..8ed8fea 100644 --- a/Bloxstrap/UI/NotifyIconWrapper.cs +++ b/Bloxstrap/UI/NotifyIconWrapper.cs @@ -16,6 +16,7 @@ namespace Bloxstrap.UI private ActivityWatcher? _activityWatcher; private DiscordRichPresence? _richPresenceHandler; + private int? _processId; EventHandler? _alertClickHandler; @@ -52,6 +53,14 @@ namespace Bloxstrap.UI if (App.Settings.Prop.ShowServerDetails) _activityWatcher.OnGameJoin += (_, _) => Task.Run(OnGameJoin); } + + public void SetProcessId(int processId) + { + if (_processId is not null) + return; + + _processId = processId; + } #endregion #region Context menu @@ -62,7 +71,7 @@ namespace Bloxstrap.UI App.Logger.WriteLine("NotifyIconWrapper::InitializeContextMenu", "Initializing context menu"); - _menuContainer = new(_activityWatcher, _richPresenceHandler); + _menuContainer = new(_activityWatcher, _richPresenceHandler, _processId); _menuContainer.ShowDialog(); } From 9a10be77bb42bdff51b3734ec33b3309cfa2ff62 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Tue, 10 Oct 2023 22:04:17 +0100 Subject: [PATCH 2/2] Adjust wording and look a little bit --- .../UI/Elements/ContextMenu/MenuContainer.xaml | 13 ++++++++++++- .../UI/Elements/ContextMenu/MenuContainer.xaml.cs | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml b/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml index 57365d5..95bb446 100644 --- a/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml +++ b/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml @@ -60,8 +60,19 @@ + + + + + + + + + + + + - diff --git a/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs b/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs index 00bbb0f..4c4d192 100644 --- a/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs +++ b/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs @@ -127,7 +127,7 @@ namespace Bloxstrap.UI.Elements.ContextMenu private void CloseRobloxMenuItem_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = Controls.ShowMessageBox( - "Are you sure you want to close Roblox?", + "Are you sure you want to close Roblox? This will forcefully end the process.", MessageBoxImage.Warning, MessageBoxButton.YesNo );