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 int TintOpacity = 128; // 0–255
|
||||
public int TintOpacity = 32; // 0–255
|
||||
public Color TintColor = Color.Black; // tint over the blur
|
||||
private bool _enabled = false;
|
||||
private bool enableClickThrough = false;
|
||||
|
||||
public BlurOverlay(Rectangle bounds)
|
||||
{
|
||||
|
|
@ -22,7 +23,7 @@ namespace PrivacyGlass
|
|||
// Important: background color = transparency key
|
||||
// so GDI background is not drawn, blur shows through.
|
||||
BackColor = Color.Black;
|
||||
TransparencyKey = Color.Black;
|
||||
//TransparencyKey = Color.Black;
|
||||
}
|
||||
|
||||
protected override CreateParams CreateParams
|
||||
|
|
@ -39,14 +40,17 @@ namespace PrivacyGlass
|
|||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
const int WM_NCHITTEST = 0x84;
|
||||
const int HTTRANSPARENT = -1;
|
||||
|
||||
if (m.Msg == WM_NCHITTEST)
|
||||
if (enableClickThrough)
|
||||
{
|
||||
// Click-through
|
||||
m.Result = (IntPtr)HTTRANSPARENT;
|
||||
return;
|
||||
const int WM_NCHITTEST = 0x84;
|
||||
const int HTTRANSPARENT = -1;
|
||||
|
||||
if (m.Msg == WM_NCHITTEST)
|
||||
{
|
||||
// Click-through
|
||||
m.Result = (IntPtr)HTTRANSPARENT;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
base.WndProc(ref m);
|
||||
|
|
@ -72,9 +76,9 @@ namespace PrivacyGlass
|
|||
// ACCENT_ENABLE_BLURBEHIND on Win10/11
|
||||
AccentPolicy accent = new AccentPolicy();
|
||||
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 =
|
||||
(a << 24) |
|
||||
(TintColor.B << 16) |
|
||||
|
|
@ -82,7 +86,6 @@ namespace PrivacyGlass
|
|||
TintColor.R;
|
||||
|
||||
accent.GradientColor = color;
|
||||
|
||||
int size = Marshal.SizeOf(accent);
|
||||
IntPtr ptr = Marshal.AllocHGlobal(size);
|
||||
try
|
||||
|
|
@ -101,6 +104,12 @@ namespace PrivacyGlass
|
|||
Marshal.FreeHGlobal(ptr);
|
||||
}
|
||||
}
|
||||
protected override void OnShown(EventArgs e)
|
||||
{
|
||||
base.OnShown(e);
|
||||
this.Focus();
|
||||
}
|
||||
|
||||
|
||||
// -------- interop stuff below --------
|
||||
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@
|
|||
<PlatformTarget>x64</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
|
|
|
|||
|
|
@ -68,7 +68,6 @@ namespace PrivacyGlass
|
|||
var menu = new ContextMenuStrip();
|
||||
|
||||
menu.Items.Add("Toggle Now", null, (_, __) => Toggle());
|
||||
menu.Items.Add("Settings...", null, ShowSettings);
|
||||
menu.Items.Add("Exit", null, Exit);
|
||||
|
||||
return menu;
|
||||
|
|
@ -80,7 +79,7 @@ namespace PrivacyGlass
|
|||
{
|
||||
BlurOverlay ov = new BlurOverlay(screen.Bounds);
|
||||
ov.TintColor = Color.Black;
|
||||
ov.TintOpacity = 12; // 0–255, higher = darker
|
||||
ov.TintOpacity = 0; // 0–255, higher = darker
|
||||
|
||||
overlays.Add(ov);
|
||||
}
|
||||
|
|
@ -96,10 +95,6 @@ namespace PrivacyGlass
|
|||
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