mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
add close roblox option to context menu
This commit is contained in:
parent
5649b464e9
commit
3451623523
@ -336,6 +336,8 @@ namespace Bloxstrap
|
||||
return;
|
||||
}
|
||||
|
||||
App.NotifyIcon?.SetProcessId(gameClientPid);
|
||||
|
||||
if (App.Settings.Prop.EnableActivityTracking)
|
||||
{
|
||||
activityWatcher = new();
|
||||
|
@ -61,6 +61,7 @@
|
||||
</MenuItem.Header>
|
||||
</MenuItem>
|
||||
<MenuItem x:Name="LogTracerMenuItem" Header="Open log tracer" Visibility="Collapsed" Click="LogTracerMenuItem_Click" />
|
||||
<MenuItem x:Name="CloseRobloxMenuItem" Header="Close Roblox" Visibility="Collapsed" Click="CloseRobloxMenuItem_Click" />
|
||||
</ContextMenu>
|
||||
</ui:UiWindow.ContextMenu>
|
||||
</base:WpfUiWindow>
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user