mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-05-19 03:42:37 +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.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
@ -256,6 +257,7 @@ namespace SystemTrayMenu.Controls
|
|||
bool disposed = false;
|
||||
Logger log = new Logger(nameof(RowData));
|
||||
internal string TargetFilePathOrig;
|
||||
internal bool HiddenEntry;
|
||||
|
||||
public RowData()
|
||||
{
|
||||
|
@ -462,7 +464,15 @@ namespace SystemTrayMenu.Controls
|
|||
}
|
||||
DataGridViewImageCell cellIcon =
|
||||
(DataGridViewImageCell)row.Cells[0];
|
||||
cellIcon.Value = data.Icon;
|
||||
|
||||
if (HiddenEntry)
|
||||
{
|
||||
cellIcon.Value = AddIconOverlay(data.Icon, Properties.Resources.WhiteTransparency);
|
||||
}
|
||||
else
|
||||
{
|
||||
cellIcon.Value = data.Icon;
|
||||
}
|
||||
|
||||
DataGridViewTextBoxCell cellName =
|
||||
(DataGridViewTextBoxCell)row.Cells[1];
|
||||
|
@ -471,6 +481,16 @@ namespace SystemTrayMenu.Controls
|
|||
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()
|
||||
{
|
||||
if (!disposed)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using Clearcove.Logging;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
@ -160,10 +161,19 @@ namespace SystemTrayMenu
|
|||
|
||||
static void ShowInactiveTopmost(Form frm)
|
||||
{
|
||||
ShowWindow(frm.Handle, SW_SHOWNOACTIVATE);
|
||||
SetWindowPos(frm.Handle.ToInt32(), HWND_TOPMOST,
|
||||
frm.Left, frm.Top, frm.Width, frm.Height,
|
||||
SWP_NOACTIVATE);
|
||||
try
|
||||
{
|
||||
ShowWindow(frm.Handle, SW_SHOWNOACTIVATE);
|
||||
SetWindowPos(frm.Handle.ToInt32(), HWND_TOPMOST,
|
||||
frm.Left, frm.Top, frm.Width, frm.Height,
|
||||
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;
|
||||
if (Directory.Exists(filePath))
|
||||
{
|
||||
FileAttributes attr = File.GetAttributes(filePath);
|
||||
if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
|
||||
FileAttributes attributes = File.GetAttributes(filePath);
|
||||
if ((attributes & FileAttributes.Directory) == FileAttributes.Directory)
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
/// <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">
|
||||
<value>..\Resources\NotSelected.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</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>
|
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>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\White50Percentage.ico" />
|
||||
<None Include="Resources\STM.ico" />
|
||||
<None Include="Resources\STM_black.ico" />
|
||||
<None Include="Resources\Selected.png" />
|
||||
|
|
|
@ -451,23 +451,19 @@ namespace SystemTrayMenu
|
|||
break;
|
||||
}
|
||||
|
||||
if (HideHiddenEntries || HideSystemEntries) // filter entries..
|
||||
FileAttributes attributes = File.GetAttributes(directory);
|
||||
bool hiddenEntry = attributes.HasFlag(FileAttributes.Hidden);
|
||||
bool systemEntry = attributes.HasFlag(
|
||||
FileAttributes.Hidden | FileAttributes.System);
|
||||
if ((HideHiddenEntries && hiddenEntry) ||
|
||||
(HideSystemEntries && systemEntry))
|
||||
{
|
||||
FileAttributes attributes = File.GetAttributes(directory);
|
||||
if (HideHiddenEntries) // filter hidden files..
|
||||
{
|
||||
if (attributes.HasFlag(FileAttributes.Hidden))
|
||||
continue;
|
||||
}
|
||||
if (HideSystemEntries) // filter system files..
|
||||
{
|
||||
if (attributes.HasFlag(FileAttributes.Hidden | FileAttributes.System)) // both must be set to be hidden!
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
RowData menuButtonData = ReadMenuButtonData(directory, false);
|
||||
menuButtonData.ContainsMenu = true;
|
||||
menuButtonData.HiddenEntry = hiddenEntry;
|
||||
string resolvedLnkPath = string.Empty;
|
||||
menuButtonData.ReadIcon(true, ref resolvedLnkPath);
|
||||
menuData.RowDatas.Add(menuButtonData);
|
||||
|
@ -500,21 +496,18 @@ namespace SystemTrayMenu
|
|||
foreach (string file in files)
|
||||
{
|
||||
if (worker != null && worker.CancellationPending)
|
||||
break;
|
||||
|
||||
if (HideHiddenEntries || HideSystemEntries) // filter entries..
|
||||
{
|
||||
FileAttributes attributes = File.GetAttributes(file);
|
||||
if (HideHiddenEntries) // filter hidden files..
|
||||
{
|
||||
if (attributes.HasFlag(FileAttributes.Hidden))
|
||||
continue;
|
||||
}
|
||||
if (HideSystemEntries) // filter system files..
|
||||
{
|
||||
if (attributes.HasFlag(FileAttributes.Hidden | FileAttributes.System)) // both must be set to be hidden!
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
FileAttributes attributes = File.GetAttributes(file);
|
||||
bool hiddenEntry = attributes.HasFlag(FileAttributes.Hidden);
|
||||
bool systemEntry = attributes.HasFlag(
|
||||
FileAttributes.Hidden | FileAttributes.System);
|
||||
if ((HideHiddenEntries && hiddenEntry) ||
|
||||
(HideSystemEntries && systemEntry))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
RowData menuButtonData = ReadMenuButtonData(file, false);
|
||||
|
@ -524,6 +517,7 @@ namespace SystemTrayMenu
|
|||
// file is pointing to a directory, so prepare submenu
|
||||
menuButtonData = ReadMenuButtonData(resolvedLnkPath, true, menuButtonData);
|
||||
menuButtonData.ContainsMenu = true;
|
||||
menuButtonData.HiddenEntry = hiddenEntry;
|
||||
}
|
||||
|
||||
menuData.RowDatas.Add(menuButtonData);
|
||||
|
|
Loading…
Reference in a new issue