66 [ Serializable ]
77 public class Form : ContainerControl , IResizableControl
88 {
9+ internal readonly Pen borderPen = new Pen ( Color . White ) ;
10+ internal readonly Pen innerBorderPen = new Pen ( Color . FromArgb ( 214 , 214 , 214 ) ) ;
911 internal bool dialog ;
12+ internal Color uwfHeaderColor = Color . FromArgb ( 251 , 251 , 251 ) ;
13+ internal Font uwfHeaderFont ;
14+ internal int uwfHeaderHeight = 24 ;
15+ internal Padding uwfHeaderPadding = new Padding ( 32 , 0 , 32 , 0 ) ;
16+ internal ContentAlignment uwfHeaderTextAlign ;
17+ internal Color uwfHeaderTextColor = Color . FromArgb ( 64 , 64 , 64 ) ;
18+ internal bool uwfMovable = true ;
1019
11- protected Button uwfSizeGripRenderer ;
20+ protected internal Button uwfSizeGripRenderer ;
1221
1322 private const int RESIZE_OFFSET = 8 ;
1423 private static Point nextLocation = new Point ( 128 , 64 ) ;
15- private readonly Pen borderPen ;
1624
25+ private Color backColor = SystemColors . Control ;
1726 private Button closeButton ;
1827 private Action < Form , DialogResult > dialogCallback ;
1928 private MenuStrip mainMenuStrip ;
@@ -28,26 +37,18 @@ public class Form : ContainerControl, IResizableControl
2837
2938 public Form ( )
3039 {
31- borderPen = new Pen ( Color . White ) ;
32-
33- BackColor = Color . FromArgb ( 238 , 238 , 242 ) ;
3440 ControlBox = true ;
3541 Font = SystemFonts . uwfArial_14 ;
3642 FormBorderStyle = FormBorderStyle . Sizable ;
3743 Location = nextLocation ;
3844 MinimumSize = new Size ( 128 , 48 ) ;
39- Size = new Size ( 334 , 260 ) ;
4045 Visible = false ;
4146
42- uwfBorderColor = Color . FromArgb ( 204 , 206 , 219 ) ;
43- uwfHeaderColor = Color . FromArgb ( 238 , 238 , 242 ) ;
47+ uwfBorderColor = Color . FromArgb ( 192 , 192 , 192 ) ;
4448 uwfHeaderFont = Font ;
45- uwfHeaderHeight = 24 ;
46- uwfHeaderPadding = new Padding ( 32 , 0 , 32 , 0 ) ;
47- uwfHeaderTextColor = Color . FromArgb ( 64 , 64 , 64 ) ;
4849 uwfHeaderTextAlign = ContentAlignment . MiddleLeft ;
49- uwfMovable = true ;
5050 uwfShadowBox = true ;
51+ uwfShadowHandler = DrawShadow ;
5152 uwfAppOwner . UpClick += _Application_UpClick ;
5253 uwfAppOwner . UpdateEvent += Owner_UpdateEvent ;
5354
@@ -63,6 +64,11 @@ public Form()
6364 public event EventHandler Shown = delegate { } ;
6465
6566 public IButtonControl AcceptButton { get ; set ; }
67+ public override Color BackColor
68+ {
69+ get { return backColor ; }
70+ set { backColor = value ; }
71+ }
6672 public Button CloseButton { get { return closeButton ; } }
6773 public bool ControlBox
6874 {
@@ -125,18 +131,16 @@ public bool TopMost
125131 }
126132 }
127133
128- public Color uwfBorderColor
134+ internal Color uwfBorderColor
129135 {
130136 get { return borderPen . Color ; }
131137 set { borderPen . Color = value ; }
132138 }
133- public Color uwfHeaderColor { get ; set ; }
134- public Font uwfHeaderFont { get ; set ; }
135- public int uwfHeaderHeight { get ; set ; }
136- public Padding uwfHeaderPadding { get ; set ; }
137- public ContentAlignment uwfHeaderTextAlign { get ; set ; }
138- public Color uwfHeaderTextColor { get ; set ; }
139- public bool uwfMovable { get ; set ; }
139+
140+ protected override Size DefaultSize
141+ {
142+ get { return new Size ( 300 , 300 ) ; }
143+ }
140144
141145 public void Close ( )
142146 {
@@ -308,6 +312,7 @@ protected override void uwfOnLatePaint(PaintEventArgs e)
308312 {
309313 base . uwfOnLatePaint ( e ) ;
310314
315+ e . Graphics . DrawLine ( innerBorderPen , 0 , uwfHeaderHeight - 1 , Width , uwfHeaderHeight - 1 ) ;
311316 e . Graphics . DrawRectangle ( borderPen , 0 , 0 , Width , Height ) ;
312317 }
313318 protected override void SetBoundsCore ( int x , int y , int width , int height , BoundsSpecified specified )
@@ -322,6 +327,16 @@ private void _Application_UpClick(object sender, MouseEventArgs e)
322327 if ( Application . activeResizeControl == this )
323328 Application . activeResizeControl = null ;
324329 }
330+ private void DrawShadow ( PaintEventArgs e )
331+ {
332+ var loc = PointToScreen ( Point . Empty ) ;
333+ var shadowAlpha = 12 ;
334+ var shadowColor = Color . FromArgb ( shadowAlpha , 64 , 64 , 64 ) ;
335+
336+ e . Graphics . uwfFillRectangle ( shadowColor , loc . X - 3 , loc . Y , Width + 6 , Height + 3 ) ;
337+ e . Graphics . uwfFillRectangle ( shadowColor , loc . X - 2 , loc . Y , Width + 4 , Height + 2 ) ;
338+ e . Graphics . uwfFillRectangle ( shadowColor , loc . X - 1 , loc . Y - 1 , Width + 2 , Height + 2 ) ;
339+ }
325340 private void _MakeButtonClose ( )
326341 {
327342 closeButton = new formSystemButton ( ) ;
0 commit comments