Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan Bickerstaff committed Jul 9, 2024
1 parent c60e155 commit aefb221
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 377 deletions.
7 changes: 7 additions & 0 deletions CommonProperties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<TargetFramework>net8.0-windows</TargetFramework>
<ApplicationIcon>..\SuperLauncherAssets\logo.ico</ApplicationIcon>
<Product>Super Launcher</Product>
<AssemblyTitle>Super Launcher</AssemblyTitle>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
<FileVersion>2.1.0.0</FileVersion>
<NeutralLanguage>en-US</NeutralLanguage>
Expand All @@ -17,5 +18,11 @@
<PlatformTarget>x64</PlatformTarget>
<Platforms>x64</Platforms>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<NoWarn>CS0108</NoWarn>
</PropertyGroup>
<!--<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyTitleAttribute">
<_Parameter1>Super Launcher</_Parameter1>
</AssemblyAttribute>
</ItemGroup>-->
</Project>
39 changes: 35 additions & 4 deletions SuperLauncher/CredentialExpirationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
{
Expand Down
3 changes: 1 addition & 2 deletions SuperLauncher/ModernLauncher.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ private void SetElevateLabels()
{
ElevateIcon.Content = "";
}

}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion SuperLauncher/ModernLauncherBadge.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<Grid>
<Grid Margin="10,10,10,10">
<Rectangle RadiusX="14" RadiusY="14" Fill="#FF121212" />
Expand Down
8 changes: 7 additions & 1 deletion SuperLauncher/ModernLauncherBadge.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Windows;
using static System.Net.Mime.MediaTypeNames;

namespace SuperLauncher
{
Expand All @@ -8,12 +9,17 @@ namespace SuperLauncher
/// </summary>
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);
Expand Down
2 changes: 1 addition & 1 deletion SuperLauncher/ModernLauncherIcon.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions SuperLauncher/ModernLauncherNotifyIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public static void Initialize()
{
Icon = new()
{
Text = "Super Launcher",
Icon = Resources.logo,
Visible = true
};
Expand Down
6 changes: 0 additions & 6 deletions SuperLauncher/Program.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
using System;
using System.Diagnostics;
using System.Timers;


namespace SuperLauncher
{
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;
/// <summary>
/// The main entry point for the application.
Expand Down Expand Up @@ -43,10 +40,7 @@ public static void Main(string[] arguments)
public static void ModernApplicationShutdown()
{
ModernApplicationShuttingDown = true;
accountMonitorTimer.Stop();
accountMonitorTimer.Dispose();
ModernApplication.Shutdown();
}

}
}
73 changes: 73 additions & 0 deletions SuperLauncher/Properties/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="0.0.0.0" name="SuperLauncher"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->

<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->

<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />

<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />

<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />

<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />

</application>
</compatibility>
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config.
Makes the application long-path aware. See https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
10 changes: 1 addition & 9 deletions SuperLauncher/SuperLauncher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,8 @@
<OutputType>WinExe</OutputType>
<UseWindowsForms>true</UseWindowsForms>
<UseWPF>true</UseWPF>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<NoWarn>1701;1702;WFAC010</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<NoWarn>1701;1702;WFAC010</NoWarn>
</PropertyGroup>
<ItemGroup>
<AdditionalFiles Remove="app.manifest" />
</ItemGroup>
<ItemGroup>
<None Remove="48.png" />
<None Remove="Resources\banner.png" />
Expand Down
Loading

0 comments on commit aefb221

Please sign in to comment.