mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-05-19 11:53:02 +12:00
parent
69e8cf4e6b
commit
c647cfef86
|
@ -443,7 +443,7 @@ namespace SystemTrayMenu.Business
|
||||||
rowData.ContainsMenu = true;
|
rowData.ContainsMenu = true;
|
||||||
rowData.HiddenEntry = hiddenEntry;
|
rowData.HiddenEntry = hiddenEntry;
|
||||||
string resolvedLnkPath = string.Empty;
|
string resolvedLnkPath = string.Empty;
|
||||||
rowData.ReadIcon(true, ref resolvedLnkPath);
|
rowData.ReadIcon(true, ref resolvedLnkPath, level);
|
||||||
rowData.MenuLevel = level;
|
rowData.MenuLevel = level;
|
||||||
menuData.RowDatas.Add(rowData);
|
menuData.RowDatas.Add(rowData);
|
||||||
}
|
}
|
||||||
|
@ -495,7 +495,7 @@ namespace SystemTrayMenu.Business
|
||||||
|
|
||||||
RowData rowData = ReadRowData(file, false);
|
RowData rowData = ReadRowData(file, false);
|
||||||
string resolvedLnkPath = string.Empty;
|
string resolvedLnkPath = string.Empty;
|
||||||
if (rowData.ReadIcon(false, ref resolvedLnkPath))
|
if (rowData.ReadIcon(false, ref resolvedLnkPath, level))
|
||||||
{
|
{
|
||||||
rowData = ReadRowData(resolvedLnkPath, true, rowData);
|
rowData = ReadRowData(resolvedLnkPath, true, rowData);
|
||||||
rowData.ContainsMenu = true;
|
rowData.ContainsMenu = true;
|
||||||
|
@ -918,7 +918,11 @@ namespace SystemTrayMenu.Business
|
||||||
if (IconReader.ClearIfCacheTooBig())
|
if (IconReader.ClearIfCacheTooBig())
|
||||||
{
|
{
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
MainPreload();
|
|
||||||
|
if (!Properties.Settings.Default.CacheMainMenu)
|
||||||
|
{
|
||||||
|
MainPreload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
openCloseState = OpenCloseState.Default;
|
openCloseState = OpenCloseState.Default;
|
||||||
|
|
|
@ -86,7 +86,7 @@ namespace SystemTrayMenu.DataClasses
|
||||||
row[2] = data;
|
row[2] = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool ReadIcon(bool isDirectory, ref string resolvedLnkPath)
|
internal bool ReadIcon(bool isDirectory, ref string resolvedLnkPath, int level)
|
||||||
{
|
{
|
||||||
bool isLnkDirectory = false;
|
bool isLnkDirectory = false;
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ namespace SystemTrayMenu.DataClasses
|
||||||
}
|
}
|
||||||
else if (isDirectory)
|
else if (isDirectory)
|
||||||
{
|
{
|
||||||
icon = IconReader.GetFolderIconWithCache(TargetFilePathOrig, IconReader.FolderType.Closed, false, true, MenuLevel == 0, out bool loading);
|
icon = IconReader.GetFolderIconWithCache(TargetFilePathOrig, IconReader.FolderType.Closed, false, true, level == 0, out bool loading);
|
||||||
IconLoading = loading;
|
IconLoading = loading;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -107,19 +107,17 @@ namespace SystemTrayMenu.DataClasses
|
||||||
|
|
||||||
if (fileExtension == ".lnk")
|
if (fileExtension == ".lnk")
|
||||||
{
|
{
|
||||||
handled = SetLnk(
|
handled = SetLnk(level, ref isLnkDirectory, ref resolvedLnkPath);
|
||||||
ref isLnkDirectory,
|
|
||||||
ref resolvedLnkPath);
|
|
||||||
showOverlay = true;
|
showOverlay = true;
|
||||||
}
|
}
|
||||||
else if (fileExtension == ".url")
|
else if (fileExtension == ".url")
|
||||||
{
|
{
|
||||||
handled = SetUrl();
|
handled = SetUrl(level);
|
||||||
showOverlay = true;
|
showOverlay = true;
|
||||||
}
|
}
|
||||||
else if (fileExtension == ".sln")
|
else if (fileExtension == ".sln")
|
||||||
{
|
{
|
||||||
handled = SetSln();
|
handled = SetSln(level);
|
||||||
}
|
}
|
||||||
else if (fileExtension == ".appref-ms")
|
else if (fileExtension == ".appref-ms")
|
||||||
{
|
{
|
||||||
|
@ -131,7 +129,7 @@ namespace SystemTrayMenu.DataClasses
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FilePathIcon = TargetFilePathOrig;
|
FilePathIcon = TargetFilePathOrig;
|
||||||
icon = IconReader.GetFileIconWithCache(FilePathIcon, showOverlay, true, MenuLevel == 0, out bool loading);
|
icon = IconReader.GetFileIconWithCache(FilePathIcon, showOverlay, true, level == 0, out bool loading);
|
||||||
IconLoading = loading;
|
IconLoading = loading;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -256,7 +254,7 @@ namespace SystemTrayMenu.DataClasses
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool SetLnk(ref bool isLnkDirectory, ref string resolvedLnkPath)
|
private bool SetLnk(int level, ref bool isLnkDirectory, ref string resolvedLnkPath)
|
||||||
{
|
{
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
resolvedLnkPath = FileLnk.GetResolvedFileName(TargetFilePath);
|
resolvedLnkPath = FileLnk.GetResolvedFileName(TargetFilePath);
|
||||||
|
@ -267,7 +265,7 @@ namespace SystemTrayMenu.DataClasses
|
||||||
}
|
}
|
||||||
else if (string.IsNullOrEmpty(Path.GetExtension(resolvedLnkPath)))
|
else if (string.IsNullOrEmpty(Path.GetExtension(resolvedLnkPath)))
|
||||||
{
|
{
|
||||||
icon = IconReader.GetFolderIconWithCache(TargetFilePathOrig, IconReader.FolderType.Open, true, true, MenuLevel == 0, out bool loading);
|
icon = IconReader.GetFolderIconWithCache(TargetFilePathOrig, IconReader.FolderType.Open, true, true, level == 0, out bool loading);
|
||||||
IconLoading = loading;
|
IconLoading = loading;
|
||||||
handled = true;
|
handled = true;
|
||||||
isLnkDirectory = true;
|
isLnkDirectory = true;
|
||||||
|
@ -290,7 +288,7 @@ namespace SystemTrayMenu.DataClasses
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool SetUrl()
|
private bool SetUrl(int level)
|
||||||
{
|
{
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
string iconFile = string.Empty;
|
string iconFile = string.Empty;
|
||||||
|
@ -303,7 +301,7 @@ namespace SystemTrayMenu.DataClasses
|
||||||
if (FileUrl.GetDefaultBrowserPath(out string browserPath))
|
if (FileUrl.GetDefaultBrowserPath(out string browserPath))
|
||||||
{
|
{
|
||||||
FilePathIcon = browserPath;
|
FilePathIcon = browserPath;
|
||||||
icon = IconReader.GetFileIconWithCache(FilePathIcon, true, true, MenuLevel == 0, out bool loading);
|
icon = IconReader.GetFileIconWithCache(FilePathIcon, true, true, level == 0, out bool loading);
|
||||||
IconLoading = loading;
|
IconLoading = loading;
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
|
@ -311,7 +309,7 @@ namespace SystemTrayMenu.DataClasses
|
||||||
else if (File.Exists(iconFile))
|
else if (File.Exists(iconFile))
|
||||||
{
|
{
|
||||||
FilePathIcon = iconFile;
|
FilePathIcon = iconFile;
|
||||||
icon = IconReader.GetFileIconWithCache(FilePathIcon, true, true, MenuLevel == 0, out bool loading);
|
icon = IconReader.GetFileIconWithCache(FilePathIcon, true, true, level == 0, out bool loading);
|
||||||
IconLoading = loading;
|
IconLoading = loading;
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
|
@ -330,12 +328,12 @@ namespace SystemTrayMenu.DataClasses
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool SetSln()
|
private bool SetSln(int level)
|
||||||
{
|
{
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
icon = IconReader.GetExtractAllIconsLastWithCache(TargetFilePathOrig, true, MenuLevel == 0, out bool loading);
|
icon = IconReader.GetExtractAllIconsLastWithCache(TargetFilePathOrig, true, level == 0, out bool loading);
|
||||||
IconLoading = loading;
|
IconLoading = loading;
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,20 @@ namespace SystemTrayMenu.DllImports
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static partial class NativeMethods
|
public static partial class NativeMethods
|
||||||
{
|
{
|
||||||
public static IntPtr CreateRoundCorners(int width, int height, int widthEllipse, int heightEllipse)
|
public static bool GetRegionRoundCorners(int width, int height, int widthEllipse, int heightEllipse, out System.Drawing.Region region)
|
||||||
{
|
{
|
||||||
return CreateRoundRectRgn(0, 0, width, height, widthEllipse, heightEllipse);
|
bool success = false;
|
||||||
|
region = null;
|
||||||
|
|
||||||
|
IntPtr handle = CreateRoundRectRgn(0, 0, width, height, widthEllipse, heightEllipse);
|
||||||
|
if (handle != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
region = System.Drawing.Region.FromHrgn(handle);
|
||||||
|
DeleteObject(handle);
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn", SetLastError = true, CharSet = CharSet.Unicode)]
|
[DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||||
|
|
19
NativeDllImport/DeleteObject.cs
Normal file
19
NativeDllImport/DeleteObject.cs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
// <copyright file="DeleteObject.cs" company="PlaceholderCompany">
|
||||||
|
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||||
|
// </copyright>
|
||||||
|
|
||||||
|
namespace SystemTrayMenu.DllImports
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// wraps the methodcalls to native windows dll's.
|
||||||
|
/// </summary>
|
||||||
|
public static partial class NativeMethods
|
||||||
|
{
|
||||||
|
[DllImport("gdi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||||
|
[DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)]
|
||||||
|
private static extern int DeleteObject(IntPtr hIcon);
|
||||||
|
}
|
||||||
|
}
|
|
@ -39,5 +39,5 @@ using System.Runtime.InteropServices;
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.27.3")]
|
[assembly: AssemblyVersion("1.0.27.5")]
|
||||||
[assembly: AssemblyFileVersion("1.0.27.3")]
|
[assembly: AssemblyFileVersion("1.0.27.5")]
|
||||||
|
|
|
@ -482,8 +482,15 @@ namespace SystemTrayMenu.UserInterface
|
||||||
|
|
||||||
if (Properties.Settings.Default.RoundCorners)
|
if (Properties.Settings.Default.RoundCorners)
|
||||||
{
|
{
|
||||||
Region = Region.FromHrgn(NativeMethods.CreateRoundCorners(Width + 1, Height + 1, 15, 15));
|
if (NativeMethods.GetRegionRoundCorners(Width + 1, Height + 1, 15, 15, out Region regionOutline))
|
||||||
tableLayoutPanelMenu.Region = Region.FromHrgn(NativeMethods.CreateRoundCorners(Width - 1, Height - 1, 15, 15));
|
{
|
||||||
|
Region = regionOutline;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NativeMethods.GetRegionRoundCorners(Width - 1, Height - 1, 15, 15, out Region region))
|
||||||
|
{
|
||||||
|
tableLayoutPanelMenu.Region = region;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue