From aefb2214ae4c4f37427fa8dd41783004ceaf2e55 Mon Sep 17 00:00:00 2001 From: Dylan Bickerstaff Date: Tue, 9 Jul 2024 15:03:45 -0400 Subject: [PATCH] . --- CommonProperties.xml | 7 + SuperLauncher/CredentialExpirationService.cs | 39 +- SuperLauncher/ModernLauncher.xaml.cs | 3 +- SuperLauncher/ModernLauncherBadge.xaml | 2 +- SuperLauncher/ModernLauncherBadge.xaml.cs | 8 +- SuperLauncher/ModernLauncherIcon.xaml.cs | 2 +- SuperLauncher/ModernLauncherNotifyIcon.cs | 1 + SuperLauncher/Program.cs | 6 - SuperLauncher/Properties/app.manifest | 73 ++++ SuperLauncher/SuperLauncher.csproj | 10 +- .../SuperLauncher_2bhx2bm4_wpftmp.csproj | 353 ------------------ 11 files changed, 127 insertions(+), 377 deletions(-) create mode 100644 SuperLauncher/Properties/app.manifest delete mode 100644 SuperLauncher/SuperLauncher_2bhx2bm4_wpftmp.csproj diff --git a/CommonProperties.xml b/CommonProperties.xml index 4a45ddd..9aa4e6b 100644 --- a/CommonProperties.xml +++ b/CommonProperties.xml @@ -3,6 +3,7 @@ net8.0-windows ..\SuperLauncherAssets\logo.ico Super Launcher + Super Launcher 2.1.0.0 2.1.0.0 en-US @@ -17,5 +18,11 @@ x64 x64 win-x64 + CS0108 + \ No newline at end of file diff --git a/SuperLauncher/CredentialExpirationService.cs b/SuperLauncher/CredentialExpirationService.cs index 9231afd..a2a905f 100644 --- a/SuperLauncher/CredentialExpirationService.cs +++ b/SuperLauncher/CredentialExpirationService.cs @@ -9,7 +9,36 @@ namespace SuperLauncher public static class CredentialExpirationService { private static Timer Timer = new(); - public static DateTime ExpirationDate = DateTime.MaxValue; + public static DateTime PasswordLastSet = DateTime.MaxValue; + public static TimeSpan MaxPasswordAge = TimeSpan.MaxValue; + public static string PasswordExpirationMessage + { + get + { + return + "Password expires in " + + ExpirationTimeSpan.Days + + " day(s), " + + ExpirationTimeSpan.Hours + + " hour(s) and " + + ExpirationTimeSpan.Seconds + + " second(s)."; + } + } + public static DateTime PasswordExpirationDate + { + get + { + return PasswordLastSet.Add(MaxPasswordAge); + } + } + public static TimeSpan ExpirationTimeSpan + { + get + { + return PasswordExpirationDate.Subtract(DateTime.Now); + } + } public static void Initialize() { Timer.Elapsed += CheckExpiration; @@ -36,9 +65,11 @@ public static void CheckExpiration(object s = null, object e = null) ds.Filter = "(objectSid=" + WindowsIdentity.GetCurrent().User.Value + ")"; SearchResult user = ds.FindOne(); bool pwdNeverExpires = (((int)user.Properties["userAccountControl"][0]) & 0x00010000) == 0x00010000; //https://learn.microsoft.com/en-us/windows/win32/api/iads/ne-iads-ads_user_flag_enum - DateTime ExpirationDate = DateTime.FromFileTime((long)user.Properties["pwdLastSet"][0]); - TimeSpan maxPwdAge = TimeSpan.FromMicroseconds((long)root.Properties["maxPwdAge"][0] / 10 * -1); - + PasswordLastSet = DateTime.FromFileTime((long)user.Properties["pwdLastSet"][0]); + MaxPasswordAge = TimeSpan.FromMicroseconds((long)root.Properties["maxPwdAge"][0] / 10 * -1); + ModernLauncherNotifyIcon.Icon.BalloonTipTitle = RunAsHelper.GetCurrentDomainWithUserName(); + ModernLauncherNotifyIcon.Icon.BalloonTipText = PasswordExpirationMessage; + ModernLauncherNotifyIcon.Icon.ShowBalloonTip(0); } catch { diff --git a/SuperLauncher/ModernLauncher.xaml.cs b/SuperLauncher/ModernLauncher.xaml.cs index f56e57b..a1b62b2 100644 --- a/SuperLauncher/ModernLauncher.xaml.cs +++ b/SuperLauncher/ModernLauncher.xaml.cs @@ -137,7 +137,6 @@ private void SetElevateLabels() { ElevateIcon.Content = ""; } - } private void Window_Loaded(object sender, RoutedEventArgs e) { @@ -287,7 +286,7 @@ private void BtnAdd_Click(object sender, RoutedEventArgs e) } private void ElevateUser_MouseEnter(object sender, MouseEventArgs e) { - ExpirationBadge = new("Test"); + ExpirationBadge = new(CredentialExpirationService.PasswordExpirationMessage); ExpirationBadge.Show(); } private void ElevateUser_MouseLeave(object sender, MouseEventArgs e) diff --git a/SuperLauncher/ModernLauncherBadge.xaml b/SuperLauncher/ModernLauncherBadge.xaml index f5bbb4b..e97ba95 100644 --- a/SuperLauncher/ModernLauncherBadge.xaml +++ b/SuperLauncher/ModernLauncherBadge.xaml @@ -5,7 +5,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:SuperLauncher" mc:Ignorable="d" - Title="ModernLauncherBadge" Height="48" Width="125" ResizeMode="NoResize" ShowInTaskbar="False" SizeToContent="WidthAndHeight" Topmost="True" AllowsTransparency="True" WindowStyle="None" Background="Transparent" ShowActivated="False"> + Title="ModernLauncherBadge" SizeChanged="Window_SizeChanged" Height="48" Width="125" ResizeMode="NoResize" ShowInTaskbar="False" SizeToContent="WidthAndHeight" Topmost="True" AllowsTransparency="True" WindowStyle="None" Background="Transparent" ShowActivated="False"> diff --git a/SuperLauncher/ModernLauncherBadge.xaml.cs b/SuperLauncher/ModernLauncherBadge.xaml.cs index c9d7a6a..9c7f5f6 100644 --- a/SuperLauncher/ModernLauncherBadge.xaml.cs +++ b/SuperLauncher/ModernLauncherBadge.xaml.cs @@ -1,5 +1,6 @@ using System; using System.Windows; +using static System.Net.Mime.MediaTypeNames; namespace SuperLauncher { @@ -8,12 +9,17 @@ namespace SuperLauncher /// public partial class ModernLauncherBadge : Window { + private string Text = "Super Launcher"; public ModernLauncherBadge(string Text) { + this.Text = Text; InitializeComponent(); - LabelText.Content = Text; } private void Label_Initialized(object sender, EventArgs e) + { + LabelText.Content = Text; + } + private void Window_SizeChanged(object sender, SizeChangedEventArgs e) { Win32Interop.GetCursorPos(out Win32Interop.POINT point); Top = ModernLauncher.DPI.ScalePixelsDown(point.y); diff --git a/SuperLauncher/ModernLauncherIcon.xaml.cs b/SuperLauncher/ModernLauncherIcon.xaml.cs index 03ac7ed..c412cc6 100644 --- a/SuperLauncher/ModernLauncherIcon.xaml.cs +++ b/SuperLauncher/ModernLauncherIcon.xaml.cs @@ -124,7 +124,7 @@ private void UserControl_MouseUp(object sender, MouseButtonEventArgs e) ModernLauncherContextMenuIcon menuItems = new(this); menu.Frame.Content = menuItems; Win32Interop.GetCursorPos(out Win32Interop.POINT point); - menu.Left = ModernLauncher.DPI.ScalePixelsDown(point.x); + menu.Left = ModernLauncher.DPI.ScalePixelsDown(point.x) - 200; menu.Top = ModernLauncher.DPI.ScalePixelsDown(point.y) - 100; menuItems.MouseUp += Menu_MouseUp; menu.Show(); diff --git a/SuperLauncher/ModernLauncherNotifyIcon.cs b/SuperLauncher/ModernLauncherNotifyIcon.cs index 7fe8c04..ed6b2c4 100644 --- a/SuperLauncher/ModernLauncherNotifyIcon.cs +++ b/SuperLauncher/ModernLauncherNotifyIcon.cs @@ -9,6 +9,7 @@ public static void Initialize() { Icon = new() { + Text = "Super Launcher", Icon = Resources.logo, Visible = true }; diff --git a/SuperLauncher/Program.cs b/SuperLauncher/Program.cs index b3aa1a7..6c72a29 100644 --- a/SuperLauncher/Program.cs +++ b/SuperLauncher/Program.cs @@ -1,7 +1,5 @@ using System; using System.Diagnostics; -using System.Timers; - namespace SuperLauncher { @@ -9,7 +7,6 @@ static class Program { public static bool ModernApplicationShuttingDown = false; public static System.Windows.Application ModernApplication; - public static Timer accountMonitorTimer = new Timer(TimeSpan.FromMinutes(30)); public static string[] Arguments; /// /// The main entry point for the application. @@ -43,10 +40,7 @@ public static void Main(string[] arguments) public static void ModernApplicationShutdown() { ModernApplicationShuttingDown = true; - accountMonitorTimer.Stop(); - accountMonitorTimer.Dispose(); ModernApplication.Shutdown(); } - } } \ No newline at end of file diff --git a/SuperLauncher/Properties/app.manifest b/SuperLauncher/Properties/app.manifest new file mode 100644 index 0000000..e816a10 --- /dev/null +++ b/SuperLauncher/Properties/app.manifest @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PerMonitorV2 + true + true + + + + + + + + + \ No newline at end of file diff --git a/SuperLauncher/SuperLauncher.csproj b/SuperLauncher/SuperLauncher.csproj index c5f9b2f..668f0a6 100644 --- a/SuperLauncher/SuperLauncher.csproj +++ b/SuperLauncher/SuperLauncher.csproj @@ -4,16 +4,8 @@ WinExe true true + Properties\app.manifest - - 1701;1702;WFAC010 - - - 1701;1702;WFAC010 - - - - diff --git a/SuperLauncher/SuperLauncher_2bhx2bm4_wpftmp.csproj b/SuperLauncher/SuperLauncher_2bhx2bm4_wpftmp.csproj deleted file mode 100644 index 3c93dd1..0000000 --- a/SuperLauncher/SuperLauncher_2bhx2bm4_wpftmp.csproj +++ /dev/null @@ -1,353 +0,0 @@ - - - SuperLauncher - obj\x64\Debug\ - obj\ - C:\Users\dylan\Source\Repos\belowaverage-org\SuperLauncher\SuperLauncher\obj\ - <_TargetAssemblyProjectName>SuperLauncher - - - - - WinExe - true - true - app.manifest - - - 1701;1702;WFAC010 - - - 1701;1702;WFAC010 - - - - - - - - - - - - - - - - - tlbimp - 0 - 1 - f935dc20-1cf0-11d0-adb9-00c04fd58a0b - 0 - false - true - - - - - NU1701 - - - - - NU1701 - - - NU1701 - - - NU1701 - - - - - - - - - - Form - - - Launcher.cs - - - Resources.resx - True - True - - - Form - - - SettingsForm.cs - - - Form - - - ShellHost.cs - - - Form - - - ShellView.cs - - - - - Launcher.cs - - - Designer - Resources.Designer.cs - ResXFileCodeGenerator - - - SettingsForm.cs - - - ShellHost.cs - - - ShellView.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - \ No newline at end of file