mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-06-02 10:34:42 +12:00
[Feature] Show Hidden Folders Transparent #31 https://github.com/Hofknecht/SystemTrayMenu/issues/31
+Log exception in ShowInactiveTopmost
This commit is contained in:
parent
35f219b528
commit
ae919586aa
|
@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
@ -256,6 +257,7 @@ namespace SystemTrayMenu.Controls
|
||||||
bool disposed = false;
|
bool disposed = false;
|
||||||
Logger log = new Logger(nameof(RowData));
|
Logger log = new Logger(nameof(RowData));
|
||||||
internal string TargetFilePathOrig;
|
internal string TargetFilePathOrig;
|
||||||
|
internal bool HiddenEntry;
|
||||||
|
|
||||||
public RowData()
|
public RowData()
|
||||||
{
|
{
|
||||||
|
@ -462,7 +464,15 @@ namespace SystemTrayMenu.Controls
|
||||||
}
|
}
|
||||||
DataGridViewImageCell cellIcon =
|
DataGridViewImageCell cellIcon =
|
||||||
(DataGridViewImageCell)row.Cells[0];
|
(DataGridViewImageCell)row.Cells[0];
|
||||||
|
|
||||||
|
if (HiddenEntry)
|
||||||
|
{
|
||||||
|
cellIcon.Value = AddIconOverlay(data.Icon, Properties.Resources.WhiteTransparency);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
cellIcon.Value = data.Icon;
|
cellIcon.Value = data.Icon;
|
||||||
|
}
|
||||||
|
|
||||||
DataGridViewTextBoxCell cellName =
|
DataGridViewTextBoxCell cellName =
|
||||||
(DataGridViewTextBoxCell)row.Cells[1];
|
(DataGridViewTextBoxCell)row.Cells[1];
|
||||||
|
@ -471,6 +481,16 @@ namespace SystemTrayMenu.Controls
|
||||||
row.Tag = data;
|
row.Tag = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Icon AddIconOverlay(Icon originalIcon, Icon overlay)
|
||||||
|
{
|
||||||
|
var target = new Bitmap(originalIcon.Width, originalIcon.Height, PixelFormat.Format32bppArgb);
|
||||||
|
var graphics = Graphics.FromImage(target);
|
||||||
|
graphics.DrawIcon(originalIcon, 0, 0);
|
||||||
|
graphics.DrawIcon(overlay, 0, 0);
|
||||||
|
target.MakeTransparent(target.GetPixel(1,1));
|
||||||
|
return Icon.FromHandle(target.GetHicon());
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
if (!disposed)
|
if (!disposed)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using Clearcove.Logging;
|
||||||
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
@ -159,11 +160,20 @@ namespace SystemTrayMenu
|
||||||
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
|
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
|
||||||
|
|
||||||
static void ShowInactiveTopmost(Form frm)
|
static void ShowInactiveTopmost(Form frm)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
ShowWindow(frm.Handle, SW_SHOWNOACTIVATE);
|
ShowWindow(frm.Handle, SW_SHOWNOACTIVATE);
|
||||||
SetWindowPos(frm.Handle.ToInt32(), HWND_TOPMOST,
|
SetWindowPos(frm.Handle.ToInt32(), HWND_TOPMOST,
|
||||||
frm.Left, frm.Top, frm.Width, frm.Height,
|
frm.Left, frm.Top, frm.Width, frm.Height,
|
||||||
SWP_NOACTIVATE);
|
SWP_NOACTIVATE);
|
||||||
}
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
Logger log = new Logger(nameof(FadeForm));
|
||||||
|
log.Error($"{exception.ToString()}");
|
||||||
|
//MessageBox.Show(exception.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -194,8 +194,8 @@ namespace SystemTrayMenu
|
||||||
bool isDirectory = false;
|
bool isDirectory = false;
|
||||||
if (Directory.Exists(filePath))
|
if (Directory.Exists(filePath))
|
||||||
{
|
{
|
||||||
FileAttributes attr = File.GetAttributes(filePath);
|
FileAttributes attributes = File.GetAttributes(filePath);
|
||||||
if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
|
if ((attributes & FileAttributes.Directory) == FileAttributes.Directory)
|
||||||
{
|
{
|
||||||
isDirectory = true;
|
isDirectory = true;
|
||||||
}
|
}
|
||||||
|
|
10
Properties/Resources.Designer.cs
generated
10
Properties/Resources.Designer.cs
generated
|
@ -289,5 +289,15 @@ namespace SystemTrayMenu.Properties {
|
||||||
return ((System.Drawing.Icon)(obj));
|
return ((System.Drawing.Icon)(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol).
|
||||||
|
/// </summary>
|
||||||
|
public static System.Drawing.Icon WhiteTransparency {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("WhiteTransparency", resourceCulture);
|
||||||
|
return ((System.Drawing.Icon)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,4 +187,7 @@
|
||||||
<data name="NotSelected" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="NotSelected" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\NotSelected.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\NotSelected.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="WhiteTransparency" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\White50Percentage.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
BIN
Resources/White50Percentage.ico
Normal file
BIN
Resources/White50Percentage.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
|
@ -180,6 +180,7 @@
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="Resources\White50Percentage.ico" />
|
||||||
<None Include="Resources\STM.ico" />
|
<None Include="Resources\STM.ico" />
|
||||||
<None Include="Resources\STM_black.ico" />
|
<None Include="Resources\STM_black.ico" />
|
||||||
<None Include="Resources\Selected.png" />
|
<None Include="Resources\Selected.png" />
|
||||||
|
|
|
@ -451,23 +451,19 @@ namespace SystemTrayMenu
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HideHiddenEntries || HideSystemEntries) // filter entries..
|
|
||||||
{
|
|
||||||
FileAttributes attributes = File.GetAttributes(directory);
|
FileAttributes attributes = File.GetAttributes(directory);
|
||||||
if (HideHiddenEntries) // filter hidden files..
|
bool hiddenEntry = attributes.HasFlag(FileAttributes.Hidden);
|
||||||
|
bool systemEntry = attributes.HasFlag(
|
||||||
|
FileAttributes.Hidden | FileAttributes.System);
|
||||||
|
if ((HideHiddenEntries && hiddenEntry) ||
|
||||||
|
(HideSystemEntries && systemEntry))
|
||||||
{
|
{
|
||||||
if (attributes.HasFlag(FileAttributes.Hidden))
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (HideSystemEntries) // filter system files..
|
|
||||||
{
|
|
||||||
if (attributes.HasFlag(FileAttributes.Hidden | FileAttributes.System)) // both must be set to be hidden!
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RowData menuButtonData = ReadMenuButtonData(directory, false);
|
RowData menuButtonData = ReadMenuButtonData(directory, false);
|
||||||
menuButtonData.ContainsMenu = true;
|
menuButtonData.ContainsMenu = true;
|
||||||
|
menuButtonData.HiddenEntry = hiddenEntry;
|
||||||
string resolvedLnkPath = string.Empty;
|
string resolvedLnkPath = string.Empty;
|
||||||
menuButtonData.ReadIcon(true, ref resolvedLnkPath);
|
menuButtonData.ReadIcon(true, ref resolvedLnkPath);
|
||||||
menuData.RowDatas.Add(menuButtonData);
|
menuData.RowDatas.Add(menuButtonData);
|
||||||
|
@ -500,22 +496,19 @@ namespace SystemTrayMenu
|
||||||
foreach (string file in files)
|
foreach (string file in files)
|
||||||
{
|
{
|
||||||
if (worker != null && worker.CancellationPending)
|
if (worker != null && worker.CancellationPending)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (HideHiddenEntries || HideSystemEntries) // filter entries..
|
|
||||||
{
|
|
||||||
FileAttributes attributes = File.GetAttributes(file);
|
FileAttributes attributes = File.GetAttributes(file);
|
||||||
if (HideHiddenEntries) // filter hidden files..
|
bool hiddenEntry = attributes.HasFlag(FileAttributes.Hidden);
|
||||||
|
bool systemEntry = attributes.HasFlag(
|
||||||
|
FileAttributes.Hidden | FileAttributes.System);
|
||||||
|
if ((HideHiddenEntries && hiddenEntry) ||
|
||||||
|
(HideSystemEntries && systemEntry))
|
||||||
{
|
{
|
||||||
if (attributes.HasFlag(FileAttributes.Hidden))
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (HideSystemEntries) // filter system files..
|
|
||||||
{
|
|
||||||
if (attributes.HasFlag(FileAttributes.Hidden | FileAttributes.System)) // both must be set to be hidden!
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RowData menuButtonData = ReadMenuButtonData(file, false);
|
RowData menuButtonData = ReadMenuButtonData(file, false);
|
||||||
string resolvedLnkPath = string.Empty;
|
string resolvedLnkPath = string.Empty;
|
||||||
|
@ -524,6 +517,7 @@ namespace SystemTrayMenu
|
||||||
// file is pointing to a directory, so prepare submenu
|
// file is pointing to a directory, so prepare submenu
|
||||||
menuButtonData = ReadMenuButtonData(resolvedLnkPath, true, menuButtonData);
|
menuButtonData = ReadMenuButtonData(resolvedLnkPath, true, menuButtonData);
|
||||||
menuButtonData.ContainsMenu = true;
|
menuButtonData.ContainsMenu = true;
|
||||||
|
menuButtonData.HiddenEntry = hiddenEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
menuData.RowDatas.Add(menuButtonData);
|
menuData.RowDatas.Add(menuButtonData);
|
||||||
|
|
Loading…
Reference in a new issue