@@ -12,7 +12,7 @@ namespace CuoreUI.Components
12
12
public partial class cuiFormRounderV2 : Component
13
13
{
14
14
private Form RoundedForm ;
15
- private Form FakeForm = new cuiFormRounderV2Resources . FakeForm ( ) ;
15
+ private readonly Form FakeForm = new FakeForm ( ) ;
16
16
17
17
private Form privateTargetForm ;
18
18
public Form TargetForm
@@ -26,16 +26,36 @@ public Form TargetForm
26
26
privateTargetForm = value ;
27
27
if ( privateTargetForm != null )
28
28
{
29
+ //TargetForm.HandleCreated += TargetForm_HandleCreated;
29
30
TargetForm . Load += TargetForm_Load ;
30
31
TargetForm . Resize += TargetForm_Resize ;
31
32
TargetForm . LocationChanged += TargetForm_LocationChanged ;
32
33
TargetForm . TextChanged += TargetForm_TextChanged ;
34
+ TargetForm . FormClosing += TargetForm_FormClosing ;
33
35
34
36
FakeForm . Activated += FakeForm_Activated ;
37
+ FakeForm . FormClosing += TargetForm_FormClosing ;
35
38
}
36
39
}
37
40
}
38
41
42
+ private void TargetForm_HandleCreated ( object sender , EventArgs e )
43
+ {
44
+ FakeForm . ShowInTaskbar = true ;
45
+ FakeForm . Opacity = 0 ;
46
+ }
47
+
48
+ private void TargetForm_FormClosing ( object sender , FormClosingEventArgs e )
49
+ {
50
+ if ( e . Cancel == false )
51
+ {
52
+ RoundedForm . Dispose ( ) ;
53
+ FakeForm . Dispose ( ) ;
54
+ TargetForm . Dispose ( ) ;
55
+ Environment . Exit ( 0 ) ;
56
+ }
57
+ }
58
+
39
59
private void FakeForm_Activated ( object sender , EventArgs e )
40
60
{
41
61
if ( TargetForm != null && RoundedForm != null )
@@ -67,10 +87,7 @@ public int Rounding
67
87
set
68
88
{
69
89
privateRounding = value ;
70
- if ( RoundedForm != null )
71
- {
72
- RoundedForm . Invalidate ( ) ;
73
- }
90
+ RoundedForm ? . Invalidate ( ) ;
74
91
}
75
92
}
76
93
@@ -83,7 +100,7 @@ private void TargetForm_LocationChanged(object sender, EventArgs e)
83
100
}
84
101
}
85
102
86
- private Color privateOutlineColor = Color . White ;
103
+ private Color privateOutlineColor = Color . FromArgb ( 30 , 0 , 0 , 0 ) ;
87
104
public Color OutlineColor
88
105
{
89
106
get
@@ -93,22 +110,38 @@ public Color OutlineColor
93
110
set
94
111
{
95
112
privateOutlineColor = value ;
113
+ RoundedForm ? . Invalidate ( ) ;
114
+ }
115
+ }
116
+
117
+ private Color privateBackColor = Color . FromArgb ( 10 , 10 , 10 ) ;
118
+ public Color BackColor
119
+ {
120
+ get
121
+ {
122
+ return privateBackColor ;
123
+ }
124
+ set
125
+ {
126
+ privateBackColor = value ;
127
+ RoundedForm ? . Invalidate ( ) ;
96
128
}
97
129
}
98
130
99
131
private async void TargetForm_Load ( object sender , EventArgs e )
100
132
{
101
- RoundedForm = new cuiFormRounderV2Resources . RoundedForm ( TargetForm . BackColor , OutlineColor ) ;
102
- RoundedForm . Activated += FakeForm_Activated ;
103
- RoundedForm . Show ( ) ;
133
+ TargetForm . Opacity = 0 ;
134
+ TargetForm . ShowInTaskbar = false ;
135
+ TargetForm . FormBorderStyle = FormBorderStyle . None ;
104
136
105
- FakeForm . ShowInTaskbar = true ;
106
- FakeForm . Opacity = 0 ;
137
+ RoundedForm = new RoundedForm ( BackColor , OutlineColor ) ;
138
+
139
+ RoundedForm . Show ( ) ;
107
140
FakeForm . Show ( ) ;
108
141
109
- TargetForm . ShowInTaskbar = false ;
110
- TargetForm . FormBorderStyle = FormBorderStyle . None ;
142
+ TargetForm . Opacity = 1 ;
111
143
144
+ RoundedForm . Activated += FakeForm_Activated ;
112
145
TargetForm_LocationChanged ( this , EventArgs . Empty ) ;
113
146
TargetForm_Resize ( this , EventArgs . Empty ) ;
114
147
@@ -122,13 +155,14 @@ private async void TargetForm_Load(object sender, EventArgs e)
122
155
TargetForm_Resize ( this , EventArgs . Empty ) ;
123
156
} ) ;
124
157
tempTimer . Start ( ) ;
158
+
125
159
await Task . Delay ( 1000 ) ;
126
160
tempTimer . Stop ( ) ;
127
161
tempTimer . Dispose ( ) ;
128
162
129
163
Timer bitmapTimer = new Timer
130
164
{
131
- Interval = 32
165
+ Interval = 100
132
166
} ;
133
167
Bitmap tempBitmap = new Bitmap ( TargetForm . Width , TargetForm . Height ) ;
134
168
bitmapTimer . Tick += ( ( a1 , a2 ) =>
@@ -141,15 +175,15 @@ private async void TargetForm_Load(object sender, EventArgs e)
141
175
}
142
176
143
177
SharedVariables . FakeBitmap = ( Bitmap ) tempBitmap . Clone ( ) ;
144
- FakeForm . Invoke ( ( MethodInvoker ) delegate {
178
+ FakeForm . Invoke ( ( MethodInvoker ) delegate
179
+ {
145
180
FakeForm . Refresh ( ) ;
146
181
} ) ;
147
182
148
183
// 30 mb
149
184
GC . AddMemoryPressure ( 30000000 ) ;
150
185
} ) ;
151
186
bitmapTimer . Start ( ) ;
152
-
153
187
}
154
188
155
189
Size addsize ( Size s1 , Size s2 )
0 commit comments