Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan Bickerstaff committed Mar 25, 2024
1 parent 1b4c1f1 commit c7460fe
Show file tree
Hide file tree
Showing 23 changed files with 162 additions and 102 deletions.
43 changes: 43 additions & 0 deletions SuperLauncher/ComInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ public interface IShellView
public uint SelectItem([In] IntPtr pidlItem, [In] uint uFlags);
public uint GetItemObject([In] uint uItem, [In] Guid riid, [Out] out IntPtr ppv);
}
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("cde725b0-ccc9-4519-917e-325d72fab4ce")]
public interface IFolderView
{
public uint GetCurrentViewMode([Out] out IntPtr pViewMode);
public uint SetCurrentViewMode([In] FOLDERVIEWMODE ViewMode);
public uint GetFolder([In] Guid riid, [Out] out IntPtr ppv);
public uint Item([In] int iItemIndex, [Out] out IntPtr ppidl);
public uint ItemCount([In] SVGIO uFlags, [Out] out IntPtr pcItems);
public uint Items([In] SVGIO uFlags, [In] Guid riid, [Out] out IntPtr ppv);
public uint GetSelectionMarkedItem([Out] out IntPtr piItem);
public uint GetFocusedItem([Out] out IntPtr piItem);
public uint GetItemPosition([In] IntPtr pidl, [Out] IntPtr ppt);
public uint GetSpacing([Out][In] IntPtr ppt);
public uint GetDefaultSpacing([Out] out IntPtr ppt);
public uint GetAutoArrange();
public uint SelectItem([In] int iItem, [In] SVSIF dwFlags);
public uint SelectAndPositionItems([In] uint cidl, [In] IntPtr apidl, [In] IntPtr apt, [In] SVSIF dwFlags);
}
[ComImport, Guid("361bbdc7-e6ee-4e13-be58-58e2240c810f"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IExplorerBrowserEvents
{
Expand Down Expand Up @@ -142,5 +160,30 @@ public enum EXPLORER_BROWSER_FILL_FLAGS : uint
EBF_SELECTFROMDATAOBJECT = 0x100,
EBF_NODROPTARGET = 0x200
}
public enum SVGIO : uint
{
SVGIO_BACKGROUND = 0,
SVGIO_SELECTION = 0x1,
SVGIO_ALLVIEW = 0x2,
SVGIO_CHECKED = 0x3,
SVGIO_TYPE_MASK = 0xf,
SVGIO_FLAG_VIEWORDER = 0x80000000
}
public enum SVSIF : uint
{
SVSI_DESELECT = 0,
SVSI_SELECT = 0x1,
SVSI_EDIT = 0x3,
SVSI_DESELECTOTHERS = 0x4,
SVSI_ENSUREVISIBLE = 0x8,
SVSI_FOCUSED = 0x10,
SVSI_TRANSLATEPT = 0x20,
SVSI_SELECTIONMARK = 0x40,
SVSI_POSITIONITEM = 0x80,
SVSI_CHECK = 0x100,
SVSI_CHECK2 = 0x200,
SVSI_KEYBOARDSELECT = 0x401,
SVSI_NOTAKEFOCUS = 0x40000000
}
}
}
2 changes: 1 addition & 1 deletion SuperLauncher/ConfigHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Text;
using System.Security.Cryptography;
using System.Text;

namespace SuperLauncher
{
Expand Down
7 changes: 4 additions & 3 deletions SuperLauncher/CredentialManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static class CredentialManager
public static extern bool CredDeleteA(string TargetName, CredType Type, CredDeleteFlags Flags);
public static bool CredReadA(string TargetName, CredType Type, CredReadFlags Flags, out CREDENTIAL Credential)
{
bool success = CredReadA(TargetName, Type, Flags, out IntPtr credPtr);
bool success = CredReadA(TargetName, Type, Flags, out IntPtr credPtr);
Credential = new();
try { Marshal.PtrToStructure(credPtr, Credential); } catch { }
return success;
Expand All @@ -34,8 +34,9 @@ public class CREDENTIAL
public uint Attributes;
public string TargetAlias;
public string UserName;
public string Password {
get
public string Password
{
get
{
byte[] bytes = new byte[CredentialBlobSize];
for (int i = 0; i < CredentialBlobSize; i++)
Expand Down
16 changes: 9 additions & 7 deletions SuperLauncher/Launcher.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using System.Windows.Forms;
using System.IO;
using System.Drawing;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SuperLauncher
{
Expand Down Expand Up @@ -195,7 +195,7 @@ private void Launcher_FormClosing(object sender, FormClosingEventArgs e)
e.Cancel = true;
FadeOut();
}
else if(saving)
else if (saving)
{
e.Cancel = true;
Settings.Default.Save();
Expand Down Expand Up @@ -334,7 +334,8 @@ private void TcMiRunAs_Click(object sender, EventArgs e)
}
private void TcMiElevate_Click(object sender, EventArgs e)
{
Task.Run(() => {
Task.Run(() =>
{
ProcessStartInfo elevatedProcStartInfo = new()
{
FileName = System.Reflection.Assembly.GetExecutingAssembly().Location.Replace(".dll", ".exe"),
Expand All @@ -349,7 +350,8 @@ private void TcMiElevate_Click(object sender, EventArgs e)
{
elevatedProcess.Start();
fakeClose = false;
Invoke(new Action(() => {
Invoke(new Action(() =>
{
Close();
}));
}
Expand Down
11 changes: 6 additions & 5 deletions SuperLauncher/ModernLauncher.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media.Animation;
using System.Runtime.InteropServices;
using System.Windows.Input;
using System.Windows.Controls;

namespace SuperLauncher
{
Expand Down Expand Up @@ -190,7 +190,8 @@ private void SaveSettingsIfSizeChanged()
if (
Settings.Default.Width == (int)Width &&
Settings.Default.Height == (int)Height
) {
)
{
return;
}
Settings.Default.Width = (int)Width;
Expand Down Expand Up @@ -283,4 +284,4 @@ private void BtnAdd_Click(object sender, RoutedEventArgs e)
((ModernLauncher)Program.ModernApplication.MainWindow).OpenWindow();
}
}
}
}
1 change: 0 additions & 1 deletion SuperLauncher/ModernLauncherBadge.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Runtime.InteropServices;
using System.Windows;

namespace SuperLauncher
Expand Down
6 changes: 3 additions & 3 deletions SuperLauncher/ModernLauncherContextMenuButton.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ public string Text
public string Icon
{
get { return (string)IconLabel.Content; }
set
{
set
{
IconLabel.Content = value;
SLIconLabel.Content = value;
}
}
public bool UserSLIcons
{
get { return useSLIcons; }
set
set
{
useSLIcons = value;
if (useSLIcons)
Expand Down
4 changes: 2 additions & 2 deletions SuperLauncher/ModernLauncherContextMenuIcon.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private void BtnRunAsAdmin_MouseUp(object sender, System.Windows.Input.MouseButt
catch (Exception) { }
}
private void BtnOpenLocation_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
{
new ShellHost(Icon.FilePath.Replace(Icon.FileName, "")).Show();
}
private void BtnUnpin_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
Expand All @@ -42,7 +42,7 @@ private void BtnUnpin_MouseUp(object sender, System.Windows.Input.MouseButtonEve
}
private void Page_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
if (RunAsHelper.IsElevated())
if (RunAsHelper.IsElevated())
{
BtnRunAsAdmin.IsEnabled = false;
BtnRunAsAdmin.Opacity = 0.5;
Expand Down
15 changes: 8 additions & 7 deletions SuperLauncher/ModernLauncherCredentialUI.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Windows;
using System;
using System.Windows;
using System.Windows.Input;
using System;

namespace SuperLauncher
{
Expand All @@ -24,12 +24,13 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
TBUserName.Focus();
CBRememberMe.IsChecked = Settings.Default.RememberMe;
CBElevate.IsChecked = Settings.Default.AutoElevate;
if(CredentialManager.CredReadA(
"Super Launcher",
CredentialManager.CredType.CRED_TYPE_GENERIC,
CredentialManager.CredReadFlags.NONE,
if (CredentialManager.CredReadA(
"Super Launcher",
CredentialManager.CredType.CRED_TYPE_GENERIC,
CredentialManager.CredReadFlags.NONE,
out CredentialManager.CREDENTIAL cred
)) {
))
{
TBUserName.Text = cred.UserName;
TBPassword.Password = cred.Password;
}
Expand Down
15 changes: 1 addition & 14 deletions SuperLauncher/ModernLauncherExplorerButtons.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
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.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls;

namespace SuperLauncher
{
Expand Down
32 changes: 9 additions & 23 deletions SuperLauncher/ModernLauncherIcon.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
using System;
using System.Diagnostics;
using System.Drawing;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.IO;
using System.Drawing;
using System.Windows.Interop;
using System.Windows.Media.Imaging;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Windows.Input;
using System.Timers;
using System.Runtime.InteropServices;

namespace SuperLauncher
{
Expand All @@ -38,10 +36,8 @@ public string FilePath
set
{
rFilePath = value;
FileInfo fi = new(rFilePath);
Icon icon = Icon.ExtractAssociatedIcon(rFilePath);
FileName = fi.Name;
NameText.Text = ExtRemover(FileName);
NameText.Text = Shared.ExtRemover(rFilePath);
LIcon.Source = Imaging.CreateBitmapSourceFromHIcon(icon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
}
}
Expand Down Expand Up @@ -150,25 +146,15 @@ private void Menu_MouseUp(object sender, MouseButtonEventArgs e)
PWindow.CloseWindow();
}
}
private static string ExtRemover(string FileName)
{
string[] parts = FileName.Split('.');
if (parts.Length > 1)
{
string[] newParts = new string[parts.Length - 1];
for (int i = 0; i < newParts.Length; i++) newParts[i] = parts[i];
return string.Join('.', newParts);
}
return FileName;
}
public void StartBadgeTimer()
{
BadgeTimer.Stop();
BadgeTimer.Start();
}
private void BadgeTimer_Elapsed(object sender, ElapsedEventArgs e)
{
Dispatcher.Invoke(() => {
Dispatcher.Invoke(() =>
{
if (!IsMouseOver) return;
if (Badge != null) Badge.Close();
Badge = new(FileName);
Expand Down
8 changes: 4 additions & 4 deletions SuperLauncher/ModernLauncherIconDragFloat.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Windows;
using System.Windows.Media;
using System.Timers;
using System.Windows;
using System.Windows.Interop;
using System.Timers;
using System.Windows.Media;

namespace SuperLauncher
{
Expand All @@ -21,7 +21,7 @@ public ModernLauncherIconDragFloat(ImageSource ImageSource)
private void SetPos()
{
Win32Interop.GetCursorPos(out Win32Interop.POINT point);
Left = ModernLauncher.DPI.ScalePixelsDown(point.x) - (Width / 2);
Left = ModernLauncher.DPI.ScalePixelsDown(point.x) - (Width / 2);
Top = ModernLauncher.DPI.ScalePixelsDown(point.y) - (Height / 2);
}
private void Window_Loaded(object sender, RoutedEventArgs e)
Expand Down
6 changes: 6 additions & 0 deletions SuperLauncher/ModernLauncherShared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,11 @@ public static void EnableAcrylic(Window Window)
Win32Interop.DwmSetWindowAttribute(handle, Win32Interop.DWMWINDOWATTRIBUTE.DWMWA_CAPTION_COLOR, dwmTbVal, 4);
Marshal.FreeHGlobal(dwmTbVal);
}
public static string ExtRemover(string FilePath)
{
FilePath = FilePath.Substring(FilePath.LastIndexOf('\\') + 1);
FilePath = FilePath.Remove(FilePath.LastIndexOf('.'));
return FilePath;
}
}
}
2 changes: 1 addition & 1 deletion SuperLauncher/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"SuperLauncher": {
"commandName": "Project",
"hotReloadEnabled": false,
"nativeDebugging": false
"nativeDebugging": true
}
}
}
Loading

0 comments on commit c7460fe

Please sign in to comment.