mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Merge pull request #751 from bluepilledgreat/feature/contextmenu-close-roblox
add close roblox option to context menu
This commit is contained in:
commit
fe36e42997
@ -339,6 +339,8 @@ namespace Bloxstrap
|
||||
return;
|
||||
}
|
||||
|
||||
App.NotifyIcon?.SetProcessId(gameClientPid);
|
||||
|
||||
if (App.Settings.Prop.EnableActivityTracking)
|
||||
{
|
||||
activityWatcher = new();
|
||||
|
@ -60,6 +60,18 @@
|
||||
</Grid>
|
||||
</MenuItem.Header>
|
||||
</MenuItem>
|
||||
<MenuItem x:Name="CloseRobloxMenuItem" Visibility="Collapsed" Click="CloseRobloxMenuItem_Click">
|
||||
<MenuItem.Header>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="24" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ui:SymbolIcon Grid.Column="0" Symbol="WindowHeaderHorizontalOff20"/>
|
||||
<TextBlock Grid.Column="1" VerticalAlignment="Center" Margin="4,0,0,0" Text="Close Roblox" />
|
||||
</Grid>
|
||||
</MenuItem.Header>
|
||||
</MenuItem>
|
||||
<MenuItem x:Name="LogTracerMenuItem" Header="Open log tracer" Visibility="Collapsed" Click="LogTracerMenuItem_Click" />
|
||||
</ContextMenu>
|
||||
</ui:UiWindow.ContextMenu>
|
||||
|
@ -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? This will forcefully end the process.",
|
||||
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