finished
This commit is contained in:
parent
ce6d776257
commit
4ff988deaf
3 changed files with 24 additions and 20 deletions
|
|
@ -7,9 +7,10 @@ namespace PrivacyGlass
|
||||||
{
|
{
|
||||||
public class BlurOverlay : Form
|
public class BlurOverlay : Form
|
||||||
{
|
{
|
||||||
public int TintOpacity = 128; // 0–255
|
public int TintOpacity = 32; // 0–255
|
||||||
public Color TintColor = Color.Black; // tint over the blur
|
public Color TintColor = Color.Black; // tint over the blur
|
||||||
private bool _enabled = false;
|
private bool _enabled = false;
|
||||||
|
private bool enableClickThrough = false;
|
||||||
|
|
||||||
public BlurOverlay(Rectangle bounds)
|
public BlurOverlay(Rectangle bounds)
|
||||||
{
|
{
|
||||||
|
|
@ -22,7 +23,7 @@ namespace PrivacyGlass
|
||||||
// Important: background color = transparency key
|
// Important: background color = transparency key
|
||||||
// so GDI background is not drawn, blur shows through.
|
// so GDI background is not drawn, blur shows through.
|
||||||
BackColor = Color.Black;
|
BackColor = Color.Black;
|
||||||
TransparencyKey = Color.Black;
|
//TransparencyKey = Color.Black;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override CreateParams CreateParams
|
protected override CreateParams CreateParams
|
||||||
|
|
@ -39,14 +40,17 @@ namespace PrivacyGlass
|
||||||
|
|
||||||
protected override void WndProc(ref Message m)
|
protected override void WndProc(ref Message m)
|
||||||
{
|
{
|
||||||
const int WM_NCHITTEST = 0x84;
|
if (enableClickThrough)
|
||||||
const int HTTRANSPARENT = -1;
|
|
||||||
|
|
||||||
if (m.Msg == WM_NCHITTEST)
|
|
||||||
{
|
{
|
||||||
// Click-through
|
const int WM_NCHITTEST = 0x84;
|
||||||
m.Result = (IntPtr)HTTRANSPARENT;
|
const int HTTRANSPARENT = -1;
|
||||||
return;
|
|
||||||
|
if (m.Msg == WM_NCHITTEST)
|
||||||
|
{
|
||||||
|
// Click-through
|
||||||
|
m.Result = (IntPtr)HTTRANSPARENT;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
base.WndProc(ref m);
|
base.WndProc(ref m);
|
||||||
|
|
@ -72,9 +76,9 @@ namespace PrivacyGlass
|
||||||
// ACCENT_ENABLE_BLURBEHIND on Win10/11
|
// ACCENT_ENABLE_BLURBEHIND on Win10/11
|
||||||
AccentPolicy accent = new AccentPolicy();
|
AccentPolicy accent = new AccentPolicy();
|
||||||
accent.AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND;
|
accent.AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND;
|
||||||
|
//accent.AccentState = AccentState.ACCENT_ENABLE_ACRYLICBLURBEHIND;
|
||||||
|
|
||||||
// Optional tint over blur (ARGB, but note it's BGR in low 24 bits)
|
int a = TintOpacity & 0xFF;
|
||||||
int a = TintOpacity & 0xFF;
|
|
||||||
int color =
|
int color =
|
||||||
(a << 24) |
|
(a << 24) |
|
||||||
(TintColor.B << 16) |
|
(TintColor.B << 16) |
|
||||||
|
|
@ -82,7 +86,6 @@ namespace PrivacyGlass
|
||||||
TintColor.R;
|
TintColor.R;
|
||||||
|
|
||||||
accent.GradientColor = color;
|
accent.GradientColor = color;
|
||||||
|
|
||||||
int size = Marshal.SizeOf(accent);
|
int size = Marshal.SizeOf(accent);
|
||||||
IntPtr ptr = Marshal.AllocHGlobal(size);
|
IntPtr ptr = Marshal.AllocHGlobal(size);
|
||||||
try
|
try
|
||||||
|
|
@ -101,6 +104,12 @@ namespace PrivacyGlass
|
||||||
Marshal.FreeHGlobal(ptr);
|
Marshal.FreeHGlobal(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
protected override void OnShown(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnShown(e);
|
||||||
|
this.Focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// -------- interop stuff below --------
|
// -------- interop stuff below --------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,12 @@
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>false</Optimize>
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,6 @@ namespace PrivacyGlass
|
||||||
var menu = new ContextMenuStrip();
|
var menu = new ContextMenuStrip();
|
||||||
|
|
||||||
menu.Items.Add("Toggle Now", null, (_, __) => Toggle());
|
menu.Items.Add("Toggle Now", null, (_, __) => Toggle());
|
||||||
menu.Items.Add("Settings...", null, ShowSettings);
|
|
||||||
menu.Items.Add("Exit", null, Exit);
|
menu.Items.Add("Exit", null, Exit);
|
||||||
|
|
||||||
return menu;
|
return menu;
|
||||||
|
|
@ -80,7 +79,7 @@ namespace PrivacyGlass
|
||||||
{
|
{
|
||||||
BlurOverlay ov = new BlurOverlay(screen.Bounds);
|
BlurOverlay ov = new BlurOverlay(screen.Bounds);
|
||||||
ov.TintColor = Color.Black;
|
ov.TintColor = Color.Black;
|
||||||
ov.TintOpacity = 12; // 0–255, higher = darker
|
ov.TintOpacity = 0; // 0–255, higher = darker
|
||||||
|
|
||||||
overlays.Add(ov);
|
overlays.Add(ov);
|
||||||
}
|
}
|
||||||
|
|
@ -96,10 +95,6 @@ namespace PrivacyGlass
|
||||||
Application.Exit();
|
Application.Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowSettings(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Settings window goes here");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue