c# - 创建一个水印应用程序以覆盖桌面上的所有屏幕
问题描述
所以,我正在尝试创建一个应用程序来在用户的计算机上创建水印,以避免使用手机或类似的东西拍摄的一些照片泄露信息。
此刻,我有一个几乎可以实现目标的 Windows 窗体应用程序,但我需要(确实是强加的)所写的文本必须对角书写。到目前为止,我的应用程序是一个带有半透明表单的 Windows 表单,其中填充了水平方向的标签。
使用 Windows 窗体应用程序,我无法创建它,因为我使用标签来编写水印文本。
我打算动态创建一些 .png 图像,在每个图像上写上文本并将它们沿主窗体放置,或者甚至创建一个图像并将文本写在上面。
有人有什么建议吗?保持这种方式还是改变方法?
无论如何,感谢您的关注阅读它,直到明白这一点!
解决方案
这是一个使用“点击”的无边框表单的简单示例。它不会干扰鼠标:
public partial class Watermark : Form
{
public String value = "Idle_Mind"; // set this somehow
private const int WS_EX_TRANSPARENT = 0x20;
public Watermark()
{
InitializeComponent();
this.Opacity = .25;
this.TopMost = true;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
this.Paint += Watermark_Paint;
}
// this makes the form ignore all clicks, so it is "passthrough"
protected override System.Windows.Forms.CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle = cp.ExStyle | WS_EX_TRANSPARENT;
return cp;
}
}
private void Watermark_Paint(object sender, PaintEventArgs e)
{
if (value != "")
{
// play with this drawing code to change your "watermark"
SizeF szF = e.Graphics.MeasureString(value, this.Font);
e.Graphics.RotateTransform(-45);
int max = Math.Max(this.Width, this.Height);
for(int y=0; y<=max; y=y+(2*(int)szF.Height))
{
e.Graphics.DrawString(value, this.Font, Brushes.Black, 0, y);
}
}
}
}
您需要做更多的工作来防止覆盖出现在 Alt-Tab 列表中,并防止使用键盘快捷键最小化/恢复它。
截屏:
推荐阅读
- apache-storm - 当我将拓扑提交给storm时,我收到“lein”的错误
- node.js - Angular8 和 Node 13 分段错误的玩笑
- ios - 带有背景图像的 UIButton 角半径
- c# - 如果孩子存在C#,树层次结构设置标志为真
- javascript - 设置通配符值
- reporting-services - 新页面 RDLC 报告中缺少行标签
- xamarin.forms - Xamarin Forms Prism DialogService 需要几秒钟才能显示
- python - Flask WTForm 动态创建 WTForm 的 SelectField 元素
- r - 在 R 中使用一个额外的变量创建新公式
- android - OpenGL 阴影贴图移动版不起作用