mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Fix threading stuff (?)
This commit is contained in:
parent
8a7696734f
commit
4233d5e904
@ -314,6 +314,8 @@ namespace Bloxstrap
|
|||||||
FinalizeExceptionHandling(exception);
|
FinalizeExceptionHandling(exception);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
NotifyIcon?.InitializeContextMenu();
|
||||||
|
|
||||||
dialog?.ShowBootstrapper();
|
dialog?.ShowBootstrapper();
|
||||||
|
|
||||||
bootstrapperTask.Wait();
|
bootstrapperTask.Wait();
|
||||||
|
@ -12,7 +12,7 @@ namespace Bloxstrap.UI
|
|||||||
bool _disposed = false;
|
bool _disposed = false;
|
||||||
|
|
||||||
private readonly System.Windows.Forms.NotifyIcon _notifyIcon;
|
private readonly System.Windows.Forms.NotifyIcon _notifyIcon;
|
||||||
private readonly MenuContainer _menuContainer = new();
|
private MenuContainer? _menuContainer;
|
||||||
private RobloxActivity? _activityWatcher;
|
private RobloxActivity? _activityWatcher;
|
||||||
|
|
||||||
private ServerInformation? _serverInformationWindow;
|
private ServerInformation? _serverInformationWindow;
|
||||||
@ -33,11 +33,16 @@ namespace Bloxstrap.UI
|
|||||||
};
|
};
|
||||||
|
|
||||||
_notifyIcon.MouseClick += MouseClickEventHandler;
|
_notifyIcon.MouseClick += MouseClickEventHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InitializeContextMenu()
|
||||||
|
{
|
||||||
|
if (_menuContainer is not null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_menuContainer = new();
|
||||||
_menuContainer.Dispatcher.BeginInvoke(_menuContainer.ShowDialog);
|
_menuContainer.Dispatcher.BeginInvoke(_menuContainer.ShowDialog);
|
||||||
|
|
||||||
_menuContainer.ServerDetailsMenuItem.Click += (_, _) => ShowServerInformationWindow();
|
_menuContainer.ServerDetailsMenuItem.Click += (_, _) => ShowServerInformationWindow();
|
||||||
|
|
||||||
_menuContainer.Closing += (_, _) => App.Logger.WriteLine("[NotifyIconWrapper::NotifyIconWrapper] Context menu container closed");
|
_menuContainer.Closing += (_, _) => App.Logger.WriteLine("[NotifyIconWrapper::NotifyIconWrapper] Context menu container closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,6 +58,7 @@ namespace Bloxstrap.UI
|
|||||||
|
|
||||||
public async void OnGameJoin()
|
public async void OnGameJoin()
|
||||||
{
|
{
|
||||||
|
if (_menuContainer is not null)
|
||||||
_menuContainer.Dispatcher.Invoke(() => _menuContainer.ServerDetailsMenuItem.Visibility = Visibility.Visible);
|
_menuContainer.Dispatcher.Invoke(() => _menuContainer.ServerDetailsMenuItem.Visibility = Visibility.Visible);
|
||||||
|
|
||||||
if (App.Settings.Prop.ShowServerDetails)
|
if (App.Settings.Prop.ShowServerDetails)
|
||||||
@ -64,6 +70,7 @@ namespace Bloxstrap.UI
|
|||||||
|
|
||||||
public void OnGameLeave(object? sender, EventArgs e)
|
public void OnGameLeave(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (_menuContainer is not null)
|
||||||
_menuContainer.Dispatcher.Invoke(() => _menuContainer.ServerDetailsMenuItem.Visibility = Visibility.Collapsed);
|
_menuContainer.Dispatcher.Invoke(() => _menuContainer.ServerDetailsMenuItem.Visibility = Visibility.Collapsed);
|
||||||
|
|
||||||
if (_serverInformationWindow is not null && _serverInformationWindow.IsVisible)
|
if (_serverInformationWindow is not null && _serverInformationWindow.IsVisible)
|
||||||
@ -73,7 +80,7 @@ namespace Bloxstrap.UI
|
|||||||
|
|
||||||
public void MouseClickEventHandler(object? sender, System.Windows.Forms.MouseEventArgs e)
|
public void MouseClickEventHandler(object? sender, System.Windows.Forms.MouseEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Button != System.Windows.Forms.MouseButtons.Right)
|
if (e.Button != System.Windows.Forms.MouseButtons.Right || _menuContainer is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_menuContainer.Activate();
|
_menuContainer.Activate();
|
||||||
@ -137,7 +144,9 @@ namespace Bloxstrap.UI
|
|||||||
|
|
||||||
App.Logger.WriteLine($"[NotifyIconWrapper::Dispose] Disposing NotifyIcon");
|
App.Logger.WriteLine($"[NotifyIconWrapper::Dispose] Disposing NotifyIcon");
|
||||||
|
|
||||||
|
if (_menuContainer is not null)
|
||||||
_menuContainer.Dispatcher.Invoke(_menuContainer.Close);
|
_menuContainer.Dispatcher.Invoke(_menuContainer.Close);
|
||||||
|
|
||||||
_notifyIcon.Dispose();
|
_notifyIcon.Dispose();
|
||||||
|
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user