mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Rework notification handling, make Job ID copyable
This commit is contained in:
parent
cfd47fffee
commit
8cd6690a33
@ -52,6 +52,8 @@ namespace Bloxstrap
|
||||
public static readonly FastFlagManager FastFlags = new();
|
||||
public static readonly HttpClient HttpClient = new(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.All });
|
||||
|
||||
public static System.Windows.Forms.NotifyIcon Notification { get; private set; } = null!;
|
||||
|
||||
// shorthand
|
||||
public static MessageBoxResult ShowMessageBox(string message, MessageBoxImage icon = MessageBoxImage.None, MessageBoxButton buttons = MessageBoxButton.OK)
|
||||
{
|
||||
@ -155,6 +157,18 @@ namespace Bloxstrap
|
||||
}
|
||||
}
|
||||
|
||||
// so this needs to be here because winforms moment
|
||||
// onclick events will not fire unless this is defined here in the main thread so uhhhhh
|
||||
// we'll show the icon if we're launching roblox since we're likely gonna be showing a
|
||||
// bunch of notifications, and always showing it just makes the most sense i guess since it
|
||||
// indicates that bloxstrap is running, even in the background
|
||||
Notification = new()
|
||||
{
|
||||
Icon = Bloxstrap.Properties.Resources.IconBloxstrap,
|
||||
Text = ProjectName,
|
||||
Visible = !IsMenuLaunch
|
||||
};
|
||||
|
||||
// todo: remove this once 32-bit support is fully gone
|
||||
if (!App.IsQuiet && !Environment.Is64BitOperatingSystem)
|
||||
{
|
||||
|
@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Bloxstrap.Properties;
|
||||
using System.Windows;
|
||||
|
||||
namespace Bloxstrap.Integrations
|
||||
{
|
||||
@ -42,23 +39,19 @@ namespace Bloxstrap.Integrations
|
||||
else
|
||||
message = $"Location: {locationCity}, {locationRegion}, {locationCountry}";
|
||||
|
||||
if (_activityWatcher.ActivityMachineUDMUX)
|
||||
message += "\nServer is UDMUX protected";
|
||||
message += "\nClick to copy Job ID";
|
||||
|
||||
App.Logger.WriteLine($"[ServerNotifier::Notify] {message.ReplaceLineEndings("\\n")}");
|
||||
|
||||
NotifyIcon notification = new()
|
||||
{
|
||||
Icon = Resources.IconBloxstrap,
|
||||
Text = "Bloxstrap",
|
||||
Visible = true,
|
||||
BalloonTipTitle = "Connected to server",
|
||||
BalloonTipText = message
|
||||
};
|
||||
EventHandler JobIDCopier = new((_, _) => Clipboard.SetText(_activityWatcher.ActivityJobId));
|
||||
|
||||
App.Notification.BalloonTipTitle = "Connected to server";
|
||||
App.Notification.BalloonTipText = message;
|
||||
App.Notification.BalloonTipClicked += JobIDCopier;
|
||||
App.Notification.ShowBalloonTip(10);
|
||||
|
||||
notification.ShowBalloonTip(10);
|
||||
await Task.Delay(10000);
|
||||
notification.Dispose();
|
||||
}
|
||||
App.Notification.BalloonTipClicked -= JobIDCopier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -80,22 +80,17 @@ namespace Bloxstrap
|
||||
|
||||
if (isAutoUpgrade)
|
||||
{
|
||||
NotifyIcon notification = new()
|
||||
{
|
||||
Icon = Resources.IconBloxstrap,
|
||||
Text = "Bloxstrap",
|
||||
Visible = true,
|
||||
BalloonTipTitle = $"Bloxstrap has been upgraded to v{currentVersionInfo.ProductVersion}",
|
||||
BalloonTipText = "Click here to see what's new in this version"
|
||||
};
|
||||
EventHandler ReleaseNotesLauncher = new((_, _) => Utilities.OpenWebsite($"https://github.com/{App.ProjectRepository}/releases/tag/v{currentVersionInfo.ProductVersion}"));
|
||||
|
||||
notification.BalloonTipClicked += (_, _) => Utilities.OpenWebsite($"https://github.com/{App.ProjectRepository}/releases/tag/v{currentVersionInfo.ProductVersion}");
|
||||
notification.ShowBalloonTip(30);
|
||||
App.Notification.BalloonTipTitle = "Bloxstrap has been upgraded to v{currentVersionInfo.ProductVersion}";
|
||||
App.Notification.BalloonTipText = "Click here to see what's new in this version";
|
||||
App.Notification.BalloonTipClicked += ReleaseNotesLauncher;
|
||||
App.Notification.ShowBalloonTip(30);
|
||||
|
||||
Task.Run(() =>
|
||||
Task.Run(async () =>
|
||||
{
|
||||
Task.Delay(30000).Wait();
|
||||
notification.Dispose();
|
||||
await Task.Delay(30000);
|
||||
App.Notification.BalloonTipClicked -= ReleaseNotesLauncher;
|
||||
});
|
||||
}
|
||||
else if (!App.IsQuiet)
|
||||
|
Loading…
Reference in New Issue
Block a user