-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHome.cs
144 lines (125 loc) · 3.8 KB
/
Home.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Search_box
{
public partial class Home : Form
{
public Home()
{
InitializeComponent();
}
#region 背景透明
private Color tr_color = Color.Transparent;
private bool b_start = false;
bool[] b_visible = null;
private void SetBackgroundImageTransparent()
{
Point pt = this.PointToScreen(new Point(0, 0));
Bitmap b = new Bitmap(this.Width, this.Height);
using (Graphics g = Graphics.FromImage(b))
{
g.CopyFromScreen(pt, new Point(), new Size(this.Width, this.Height));
}
this.BackgroundImage = b;
}
private void BeginSet()
{
tr_color = this.TransparencyKey;
b_start = true;
}
private void Setting()
{
if (b_start)
{
b_visible = new bool[Controls.Count];
for (int i = 0; i < Controls.Count; i++)
{
b_visible[i] = Controls[i].Visible;
Controls[i].Visible = false;
}
BackgroundImage = null;
BackColor = Color.White;
b_start = false;
this.TransparencyKey = Color.White;
}
}
private void EndSet()
{
SetBackgroundImageTransparent();
this.TransparencyKey = tr_color;
for (int i = 0; i < Controls.Count; i++)
{
Controls[i].Visible = b_visible[i];
}
b_start = false;
}
private void Home_Resize(object sender, EventArgs e)
{
Setting();
}
private void Home_ResizeBegin(object sender, EventArgs e)
{
Setting();
}
private void Home_ResizeEnd(object sender, EventArgs e)
{
Setting();
}
private void Home_Move(object sender, EventArgs e)
{
Setting();
}
#endregion
#region 不让窗体显示在Alt+Tab
protected override CreateParams CreateParams
{
get
{
const int WS_EX_APPWINDOW = 0x40000;
const int WS_EX_TOOLWINDOW = 0x80;
CreateParams cp = base.CreateParams;
cp.ExStyle &= (~WS_EX_APPWINDOW); // 不显示在TaskBar
cp.ExStyle |= WS_EX_TOOLWINDOW; // 不显示在Alt+Tab
return cp;
}
}
#endregion
#region 加载主页
private void Home_Load(object sender, EventArgs e)
{
SetBackgroundImageTransparent();//背景透明
ChuangTiTouMing.Enabled = true;//运行窗体透明插件
this.Opacity = 100;//设置窗体透明度
this.TopMost = true;//设置窗体显示在最上层
background.Dock = DockStyle.Fill;//background在父窗体中停靠
}
#endregion
private void SouSuo_Click(object sender, EventArgs e)
{
}
private void FanKui_Click(object sender, EventArgs e)
{
}
#region 设置
private void SheZhi_Click(object sender, EventArgs e)
{
Set jump1 = new Set();
jump1.ShowDialog();
//this.Dispose();
}
#endregion
#region 窗体透明插件
private void ChuangTiTouMing_Tick(object sender, EventArgs e)
{
SetBackgroundImageTransparent();//背景透明
}
#endregion
}
}