diff --git a/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml b/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml
index a3c9bad..9454823 100644
--- a/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml
+++ b/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml
@@ -21,7 +21,7 @@
-
+
diff --git a/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs b/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs
index 6154055..adad0a4 100644
--- a/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs
+++ b/Bloxstrap/UI/Elements/ContextMenu/MenuContainer.xaml.cs
@@ -48,11 +48,6 @@ namespace Bloxstrap.UI.Elements.ContextMenu
Controls.ShowMessageBox($"hi how u doing i am {RichPresenceMenuItem.IsChecked}", MessageBoxImage.Warning);
}
- private void ServerDetailsMenuItem_Click(object sender, RoutedEventArgs e)
- {
- Controls.ShowMessageBox($"hi how u doing i am {RichPresenceMenuItem.IsChecked}", MessageBoxImage.Warning);
- }
-
private void TestMenuItem_Click(object sender, RoutedEventArgs e)
{
Controls.ShowMessageBox($"hi how u doing i am {TestMenuItem.IsChecked}", MessageBoxImage.Warning);
diff --git a/Bloxstrap/UI/Elements/ContextMenu/ServerInformation.xaml b/Bloxstrap/UI/Elements/ContextMenu/ServerInformation.xaml
new file mode 100644
index 0000000..4233e52
--- /dev/null
+++ b/Bloxstrap/UI/Elements/ContextMenu/ServerInformation.xaml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Bloxstrap/UI/Elements/ContextMenu/ServerInformation.xaml.cs b/Bloxstrap/UI/Elements/ContextMenu/ServerInformation.xaml.cs
new file mode 100644
index 0000000..1ef8536
--- /dev/null
+++ b/Bloxstrap/UI/Elements/ContextMenu/ServerInformation.xaml.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+using Bloxstrap.UI.ViewModels.ContextMenu;
+
+namespace Bloxstrap.UI.Elements.ContextMenu
+{
+ ///
+ /// Interaction logic for ServerInformation.xaml
+ ///
+ public partial class ServerInformation
+ {
+ public ServerInformation(RobloxActivity activityWatcher)
+ {
+ DataContext = new ServerInformationViewModel(this, activityWatcher);
+ InitializeComponent();
+ }
+ }
+}
diff --git a/Bloxstrap/UI/Elements/FluentMessageBox.xaml b/Bloxstrap/UI/Elements/FluentMessageBox.xaml
index 7169b84..b1a6cf1 100644
--- a/Bloxstrap/UI/Elements/FluentMessageBox.xaml
+++ b/Bloxstrap/UI/Elements/FluentMessageBox.xaml
@@ -36,7 +36,7 @@
-
+
diff --git a/Bloxstrap/UI/NotifyIconWrapper.cs b/Bloxstrap/UI/NotifyIconWrapper.cs
index f98722e..f984648 100644
--- a/Bloxstrap/UI/NotifyIconWrapper.cs
+++ b/Bloxstrap/UI/NotifyIconWrapper.cs
@@ -7,12 +7,16 @@ namespace Bloxstrap.UI
{
public class NotifyIconWrapper : IDisposable
{
+ // lol who needs properly structured mvvm and xaml when you have the absolute catastrophe that this is
+
bool _disposed = false;
private readonly System.Windows.Forms.NotifyIcon _notifyIcon;
private readonly MenuContainer _menuContainer = new();
private RobloxActivity? _activityWatcher;
+ private ServerInformation? _serverInformationWindow;
+
public DiscordRichPresence? RichPresenceIntegration;
EventHandler? _alertClickHandler;
@@ -31,6 +35,9 @@ namespace Bloxstrap.UI
_notifyIcon.MouseClick += MouseClickEventHandler;
_menuContainer.Dispatcher.BeginInvoke(_menuContainer.ShowDialog);
+
+ _menuContainer.ServerDetailsMenuItem.Click += (_, _) => ShowServerInformationWindow();
+
_menuContainer.Closing += (_, _) => App.Logger.WriteLine("[NotifyIconWrapper::NotifyIconWrapper] Context menu container closed");
}
@@ -46,17 +53,22 @@ namespace Bloxstrap.UI
public async void OnGameJoin()
{
- string serverLocation = await _activityWatcher!.GetServerLocation();
-
_menuContainer.Dispatcher.Invoke(() => _menuContainer.ServerDetailsMenuItem.Visibility = Visibility.Visible);
if (App.Settings.Prop.ShowServerDetails)
- ShowAlert("Connnected to server", $"Location: {serverLocation}", 10, (_, _) => Clipboard.SetText(_activityWatcher.ActivityJobId));
+ {
+ string serverLocation = await _activityWatcher!.GetServerLocation();
+ ShowAlert("Connnected to server", $"Location: {serverLocation}\nClick for more information", 10, (_, _) => ShowServerInformationWindow());
+ }
}
public void OnGameLeave(object? sender, EventArgs e)
{
_menuContainer.Dispatcher.Invoke(() => _menuContainer.ServerDetailsMenuItem.Visibility = Visibility.Collapsed);
+
+ if (_serverInformationWindow is not null && _serverInformationWindow.IsVisible)
+ _serverInformationWindow.Dispatcher.Invoke(_serverInformationWindow.Close);
+
}
public void MouseClickEventHandler(object? sender, System.Windows.Forms.MouseEventArgs e)
@@ -68,6 +80,20 @@ namespace Bloxstrap.UI
_menuContainer.ContextMenu.IsOpen = true;
}
+ public void ShowServerInformationWindow()
+ {
+ if (_serverInformationWindow is null)
+ {
+ _serverInformationWindow = new ServerInformation(_activityWatcher!);
+ _serverInformationWindow.Closed += (_, _) => _serverInformationWindow = null;
+ }
+
+ if (!_serverInformationWindow.IsVisible)
+ _serverInformationWindow.Show();
+
+ _serverInformationWindow.Activate();
+ }
+
public void ShowAlert(string caption, string message, int duration, EventHandler? clickHandler)
{
string id = Guid.NewGuid().ToString()[..8];
diff --git a/Bloxstrap/UI/ViewModels/ContextMenu/ServerInformationViewModel.cs b/Bloxstrap/UI/ViewModels/ContextMenu/ServerInformationViewModel.cs
new file mode 100644
index 0000000..22a749d
--- /dev/null
+++ b/Bloxstrap/UI/ViewModels/ContextMenu/ServerInformationViewModel.cs
@@ -0,0 +1,34 @@
+using System.Windows.Input;
+
+using CommunityToolkit.Mvvm.Input;
+
+using Bloxstrap.UI.Elements.ContextMenu;
+
+namespace Bloxstrap.UI.ViewModels.ContextMenu
+{
+ internal class ServerInformationViewModel : NotifyPropertyChangedViewModel
+ {
+ private readonly ServerInformation _window;
+ private readonly RobloxActivity _activityWatcher;
+
+ public string InstanceId => _activityWatcher.ActivityJobId;
+ public string ServerLocation { get; private set; } = "Loading, please wait...";
+
+ public ICommand CopyInstanceIdCommand => new RelayCommand(CopyInstanceId);
+ public ICommand CloseWindowCommand => new RelayCommand(_window.Close);
+
+ public ServerInformationViewModel(ServerInformation window, RobloxActivity activityWatcher)
+ {
+ _window = window;
+ _activityWatcher = activityWatcher;
+
+ Task.Run(async () =>
+ {
+ ServerLocation = await _activityWatcher.GetServerLocation();
+ OnPropertyChanged(nameof(ServerLocation));
+ });
+ }
+
+ private void CopyInstanceId() => Clipboard.SetText(InstanceId);
+ }
+}