<!--<br/ /><br/ />Code highlighting produced by Actipro CodeHighlighter (freeware)<br/ />http://www.CodeHighlighter.com/<br/ /><br/ />-->
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Text;
using
System.Drawing;
using
System.Windows.Forms;
using
System.Runtime.InteropServices;
using
System.Windows.Forms.VisualStyles;
using
System.Security.Permissions;
using
CRD.Common;
namespace
CRD.WinUI.Misc
{
//
publicclassGroupBox:System.Windows.Forms.GroupBox
//
{
//
publicGroupBox()
//
:base()
//
{
//
this.BackColor=Color.Transparent;
//
}
//
[DefaultValue(typeof(Color),"Transparent")]
//
publicoverrideSystem.Drawing.ColorBackColor
//
{
//
get
//
{
//
returnbase.BackColor;
//
}
//
set
//
{
//
base.BackColor=value;
//
}
//
}
//
protectedoverridevoidOnPaint(System.Windows.Forms.PaintEventArgse)
//
{
//
base.OnPaint(e);
//
//
e.Graphics.DrawString(this.Text,this.Font,Brushes.Red,10,1);
//
e.Graphics.DrawLine(newPen(Shared.ControlBorderBackColor),1,7,8,7);
//
e.Graphics.DrawLine(newPen(Shared.ControlBorderBackColor),90,7,this.Width-2,7);
//
e.Graphics.DrawLine(newPen(Shared.ControlBorderBackColor),1,7,1,this.Height-2);
//
e.Graphics.DrawLine(newPen(Shared.ControlBorderBackColor),1,this.Height-2,this.Width-2,this.Height-2);
//
e.Graphics.DrawLine(newPen(Shared.ControlBorderBackColor),this.Width-2,7,this.Width-2,this.Height-2);
//
}
//
}
[Flags]
public
enum
IntTextFormatFlags
{
Bottom
=
8
,
CalculateRectangle
=
0x400
,
Default
=
0
,
EndEllipsis
=
0x8000
,
ExpandTabs
=
0x40
,
ExternalLeading
=
0x200
,
HidePrefix
=
0x100000
,
HorizontalCenter
=
1
,
Internal
=
0x1000
,
Left
=
0
,
ModifyString
=
0x10000
,
NoClipping
=
0x100
,
NoFullWidthCharacterBreak
=
0x80000
,
NoPrefix
=
0x800
,
PathEllipsis
=
0x4000
,
PrefixOnly
=
0x200000
,
Right
=
2
,
RightToLeft
=
0x20000
,
SingleLine
=
0x20
,
TabStop
=
0x80
,
TextBoxControl
=
0x2000
,
Top
=
0
,
VerticalCenter
=
4
,
WordBreak
=
0x10
,
WordEllipsis
=
0x40000
}
//
[Designer("System.Windows.Forms.Design.GroupBoxDesigner,System.Design,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a"),Description("DescriptionGroupBox"),ComVisible(true),ClassInterface(ClassInterfaceType.AutoDispatch),DefaultEvent("Enter"),DefaultProperty("Text")]
public
class
GroupBox:Control
{
//
Fields
private
FontcachedFont;
private
FlatStyleflatStyle
=
FlatStyle.Standard;
private
int
fontHeight
=
-
1
;
//
Events
[Category(
"
CatPropertyChanged
"
),EditorBrowsable(EditorBrowsableState.Always),Description(
"
ControlOnAutoSizeChangedDescr
"
),Browsable(
true
)]
public
event
EventHandlerAutoSizeChanged
{
add
{
base
.AutoSizeChanged
+=
value;
}
remove
{
base
.AutoSizeChanged
-=
value;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced),Browsable(
false
)]
public
event
EventHandlerClick
{
add
{
base
.Click
+=
value;
}
remove
{
base
.Click
-=
value;
}
}
[Browsable(
false
),EditorBrowsable(EditorBrowsableState.Advanced)]
public
event
EventHandlerDoubleClick
{
add
{
base
.DoubleClick
+=
value;
}
remove
{
base
.DoubleClick
-=
value;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced),Browsable(
false
)]
public
event
KeyEventHandlerKeyDown
{
add
{
base
.KeyDown
+=
value;
}
remove
{
base
.KeyDown
-=
value;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced),Browsable(
false
)]
public
event
KeyPressEventHandlerKeyPress
{
add
{
base
.KeyPress
+=
value;
}
remove
{
base
.KeyPress
-=
value;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced),Browsable(
false
)]
public
event
KeyEventHandlerKeyUp
{
add
{
base
.KeyUp
+=
value;
}
remove
{
base
.KeyUp
-=
value;
}
}
[Browsable(
false
),EditorBrowsable(EditorBrowsableState.Advanced)]
public
event
MouseEventHandlerMouseClick
{
add
{
base
.MouseClick
+=
value;
}
remove
{
base
.MouseClick
-=
value;
}
}
[Browsable(
false
),EditorBrowsable(EditorBrowsableState.Advanced)]
public
event
MouseEventHandlerMouseDoubleClick
{
add
{
base
.MouseDoubleClick
+=
value;
}
remove
{
base
.MouseDoubleClick
-=
value;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced),Browsable(
false
)]
public
event
MouseEventHandlerMouseDown
{
add
{
base
.MouseDown
+=
value;
}
remove
{
base
.MouseDown
-=
value;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced),Browsable(
false
)]
public
event
EventHandlerMouseEnter
{
add
{
base
.MouseEnter
+=
value;
}
remove
{
base
.MouseEnter
-=
value;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced),Browsable(
false
)]
public
event
EventHandlerMouseLeave
{
add
{
base
.MouseLeave
+=
value;
}
remove
{
base
.MouseLeave
-=
value;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced),Browsable(
false
)]
public
event
MouseEventHandlerMouseMove
{
add
{
base
.MouseMove
+=
value;
}
remove
{
base
.MouseMove
-=
value;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced),Browsable(
false
)]
public
event
MouseEventHandlerMouseUp
{
add
{
base
.MouseUp
+=
value;
}
remove
{
base
.MouseUp
-=
value;
}
}
[Browsable(
false
),EditorBrowsable(EditorBrowsableState.Advanced)]
public
event
EventHandlerTabStopChanged
{
add
{
base
.TabStopChanged
+=
value;
}
remove
{
base
.TabStopChanged
-=
value;
}
}
//
Methods
public
GroupBox()
{
//
base.SetState2(0x800,true);
base
.SetStyle(ControlStyles.ContainerControl,
true
);
base
.SetStyle(ControlStyles.SupportsTransparentBackColor
|
ControlStyles.ResizeRedraw
|
ControlStyles.UserPaint,
this
.OwnerDraw);
base
.SetStyle(ControlStyles.Selectable,
false
);
this
.TabStop
=
false
;
}
protected
override
void
OnCreateControl()
{
base
.OnCreateControl();
this
.BackColor
=
Color.Transparent;
}
protected
override
AccessibleObjectCreateAccessibilityInstance()
{
return
new
GroupBoxAccessibleObject(
this
);
}
private
void
DrawGroupBox(PaintEventArgse)
{
Graphicsgraphics
=
e.Graphics;
RectangleclientRectangle
=
base
.ClientRectangle;
int
num
=
8
;
ColordisabledColor
=
SystemColors.Control;
//
base.DisabledColor;
//
Penpen=newPen(ControlPaint.Light(disabledColor,1f));
Penpen
=
new
Pen(Shared.ControlBorderBackColor
==
SystemColors.Control
?
Color.Black:Shared.ControlBorderBackColor,
0.3f
);
//
Penpen2=newPen(ControlPaint.Dark(disabledColor,0f));
Penpen2
=
new
Pen(Shared.ControlBorderBackColor
==
SystemColors.Control
?
Color.Black:Shared.ControlBorderBackColor,0f);
clientRectangle.X
+=
num;
clientRectangle.Width
-=
2
*
num;
try
{
Sizesize;
int
num2;
IntTextFormatFlagsflags
=
IntTextFormatFlags.TextBoxControl
|
IntTextFormatFlags.WordBreak;
if
(
!
this
.ShowKeyboardCues)
{
flags
|=
IntTextFormatFlags.HidePrefix;
}
if
(
this
.RightToLeft
==
RightToLeft.Yes)
{
flags
|=
IntTextFormatFlags.RightToLeft;
flags
|=
IntTextFormatFlags.Right;
}
Graphicsgraphics2
=
e.Graphics;
size
=
graphics2.MeasureString(
this
.Text,
this
.Font).ToSize();
if
(
base
.Enabled)
{
//
graphics2.DrawString(this.Text,this.Font,newSolidBrush(Shared.ControlBorderBackColor==SystemColors.Control?Color.Black:Shared.ControlBorderBackColor),8,0);
graphics2.DrawString(
this
.Text,
this
.Font,
new
SolidBrush(Shared.FontColor),
8
,
0
);
}
else
{
ControlPaint.DrawStringDisabled(graphics2,
this
.Text,
this
.Font,disabledColor,clientRectangle,(TextFormatFlags)flags);
}
Label_01E7:
num2
=
num;
if
(
this
.RightToLeft
==
RightToLeft.Yes)
{
num2
+=
size.Width;
}
int
num3
=
Math.Min((
int
)(num2
+
size.Width),(
int
)(
base
.Width
-
6
));
int
num4
=
base
.FontHeight
/
2
;
graphics.DrawLine(pen,
1
,num4,
1
,
base
.Height
-
1
);
//
graphics.DrawLine(pen2,0,num4,0,base.Height-2);
graphics.DrawLine(pen,
1
,
base
.Height
-
1
,
base
.Width
-
1
,
base
.Height
-
1
);
//
graphics.DrawLine(pen2,0,base.Height-2,base.Width-1,base.Height-2);
graphics.DrawLine(pen2,
1
,num4
-
1
,num2
-
1
,num4
-
1
);
///
/graphics.DrawLine(pen,1,num4,num2,num4);
graphics.DrawLine(pen2,num3,num4
-
1
,
base
.Width
-
2
,num4
-
1
);
///
/graphics.DrawLine(pen,num3,num4,base.Width-1,num4);
graphics.DrawLine(pen,(
int
)(
base
.Width
-
1
),(
int
)(num4
-
1
),(
int
)(
base
.Width
-
1
),(
int
)(
base
.Height
-
1
));
///
/graphics.DrawLine(pen2,base.Width-2,num4,base.Width-2,base.Height-2);
}
finally
{
pen.Dispose();
pen2.Dispose();
}
}
protected
override
void
OnFontChanged(EventArgse)
{
this
.fontHeight
=
-
1
;
this
.cachedFont
=
null
;
base
.Invalidate();
base
.OnFontChanged(e);
}
protected
override
void
OnPaint(PaintEventArgse)
{
if
((Application.RenderWithVisualStyles
&&
(
base
.Width
>=
10
))
&&
(
base
.Height
>=
10
))
{
GroupBoxStatestate
=
base
.Enabled
?
GroupBoxState.Normal:GroupBoxState.Disabled;
TextFormatFlagsflags
=
TextFormatFlags.PreserveGraphicsTranslateTransform
|
TextFormatFlags.PreserveGraphicsClipping
|
TextFormatFlags.TextBoxControl
|
TextFormatFlags.WordBreak;
if
(
!
this
.ShowKeyboardCues)
{
flags
|=
TextFormatFlags.HidePrefix;
}
if
(
this
.RightToLeft
==
RightToLeft.Yes)
{
flags
|=
TextFormatFlags.RightToLeft
|
TextFormatFlags.Right;
}
}
else
{
this
.DrawGroupBox(e);
}
base
.OnPaint(e);
}
protected
override
void
ScaleControl(SizeFfactor,BoundsSpecifiedspecified)
{
if
((factor.Width
!=
1f)
&&
(factor.Height
!=
1f))
{
this
.fontHeight
=
-
1
;
this
.cachedFont
=
null
;
}
base
.ScaleControl(factor,specified);
}
public
override
string
ToString()
{
return
(
base
.ToString()
+
"
,Text:
"
+
this
.Text);
}
private
void
WmEraseBkgnd(
ref
Messagem)
{
Win32.RECTrect
=
new
Win32.RECT();
Win32.GetClientRect(
new
HandleRef(
this
,
base
.Handle),
ref
rect);
using
(Graphicsgraphics
=
Graphics.FromHdcInternal(m.WParam))
{
using
(Brushbrush
=
new
SolidBrush(
this
.BackColor))
{
graphics.FillRectangle(brush,rect.Left,rect.Top,rect.Right
-
rect.Left,rect.Bottom
-
rect.Top);
}
}
m.Result
=
(IntPtr)
1
;
}
[SecurityPermission(SecurityAction.LinkDemand,Flags
=
SecurityPermissionFlag.UnmanagedCode)]
protected
override
void
WndProc(
ref
Messagem)
{
if
(
this
.OwnerDraw)
{
base
.WndProc(
ref
m);
}
else
{
int
msg
=
m.Msg;
if
(msg
!=
20
)
{
if
(msg
==
0x3d
)
{
base
.WndProc(
ref
m);
if
(((
int
)((
long
)m.LParam))
==
-
12
)
{
m.Result
=
IntPtr.Zero;
}
return
;
}
if
(msg
!=
0x318
)
{
base
.WndProc(
ref
m);
return
;
}
}
this
.WmEraseBkgnd(
ref
m);
}
}
//
Properties
[EditorBrowsable(EditorBrowsableState.Advanced),Browsable(
false
)]
public
override
bool
AllowDrop
{
get
{
return
base
.AllowDrop;
}
set
{
base
.AllowDrop
=
value;
}
}
[EditorBrowsable(EditorBrowsableState.Always),DesignerSerializationVisibility(DesignerSerializationVisibility.Visible),Browsable(
true
)]
public
override
bool
AutoSize
{
get
{
return
base
.AutoSize;
}
set
{
base
.AutoSize
=
value;
}
}
[Category(
"
CatLayout
"
),Localizable(
true
),Browsable(
true
),DefaultValue(
1
),Description(
"
ControlAutoSizeModeDescr
"
)]
public
AutoSizeModeAutoSizeMode
{
get
{
return
base
.GetAutoSizeMode();
}
set
{
if
(
!
ClientUtils.IsEnumValid(value,(
int
)value,
0
,
1
))
{
throw
new
InvalidEnumArgumentException(
"
value
"
,(
int
)value,
typeof
(AutoSizeMode));
}
}
}
internal
virtual
ControlParentInternal
{
get
{
return
this
.Parent;
}
set
{
if
(
this
.Parent
!=
value)
{
if
(value
!=
null
)
{
value.Controls.Add(
this
);
}
else
{
this
.Parent.Controls.Remove(
this
);
}
}
}
}
protected
override
CreateParamsCreateParams
{
[SecurityPermission(SecurityAction.LinkDemand,Flags
=
SecurityPermissionFlag.UnmanagedCode)]
get
{
CreateParamscreateParams
=
base
.CreateParams;
if
(
!
this
.OwnerDraw)
{
createParams.ClassName
=
"
BUTTON
"
;
createParams.Style
|=
7
;
}
else
{
createParams.ClassName
=
null
;
createParams.Style
&=
-
8
;
}
createParams.ExStyle
|=
0x10000
;
return
createParams;
}
}
protected
override
PaddingDefaultPadding
{
get
{
return
new
Padding(
3
);
}
}
protected
override
SizeDefaultSize
{
get
{
return
new
Size(
200
,
100
);
}
}
public
override
RectangleDisplayRectangle
{
get
{
SizeclientSize
=
base
.ClientSize;
if
(
this
.fontHeight
==
-
1
)
{
this
.fontHeight
=
this
.Font.Height;
this
.cachedFont
=
this
.Font;
}
else
if
(
!
object
.ReferenceEquals(
this
.cachedFont,
this
.Font))
{
this
.fontHeight
=
this
.Font.Height;
this
.cachedFont
=
this
.Font;
}
Paddingpadding
=
base
.Padding;
return
new
Rectangle(padding.Left,
this
.fontHeight
+
padding.Top,Math.Max(clientSize.Width
-
padding.Horizontal,
0
),Math.Max((clientSize.Height
-
this
.fontHeight)
-
padding.Vertical,
0
));
}
}
//
[Description("ButtonFlatStyleDescr"),Category("CatAppearance"),DefaultValue(2)]
public
FlatStyleFlatStyle
{
get
{
return
this
.flatStyle;
}
set
{
if
(
!
ClientUtils.IsEnumValid(value,(
int
)value,
0
,
3
))
{
throw
new
InvalidEnumArgumentException(
"
value
"
,(
int
)value,
typeof
(FlatStyle));
}
if
(
this
.flatStyle
!=
value)
{
bool
ownerDraw
=
this
.OwnerDraw;
this
.flatStyle
=
value;
bool
flag2
=
this
.OwnerDraw
!=
ownerDraw;
base
.SetStyle(ControlStyles.ContainerControl,
true
);
base
.SetStyle(ControlStyles.SupportsTransparentBackColor
|
ControlStyles.UserMouse
|
ControlStyles.ResizeRedraw
|
ControlStyles.UserPaint,
this
.OwnerDraw);
if
(flag2)
{
base
.RecreateHandle();
}
else
{
this
.Refresh();
}
}
}
}
private
bool
OwnerDraw
{
get
{
return
(
this
.FlatStyle
!=
FlatStyle.System);
}
}
public
bool
SupportsUseCompatibleTextRendering
{
get
{
return
true
;
}
}
[Browsable(
false
),EditorBrowsable(EditorBrowsableState.Advanced)]
public
bool
TabStop
{
get
{
return
base
.TabStop;
}
set
{
base
.TabStop
=
value;
}
}
[Localizable(
true
)]
public
override
string
Text
{
get
{
return
base
.Text;
}
set
{
bool
visible
=
base
.Visible;
try
{
if
(visible
&&
base
.IsHandleCreated)
{
this
.SendMessage(
11
,
0
,
0
);
}
base
.Text
=
value;
}
finally
{
if
(visible
&&
base
.IsHandleCreated)
{
this
.SendMessage(
11
,
1
,
0
);
}
}
base
.Invalidate(
true
);
}
}
//
NestedTypes
[ComVisible(
true
)]
internal
class
GroupBoxAccessibleObject:Control.ControlAccessibleObject
{
//
Methods
internal
GroupBoxAccessibleObject(GroupBoxowner)
:
base
(owner)
{
}
//
Properties
public
override
AccessibleRoleRole
{
get
{
AccessibleRoleaccessibleRole
=
base
.Owner.AccessibleRole;
if
(accessibleRole
!=
AccessibleRole.Default)
{
return
accessibleRole;
}
return
AccessibleRole.Grouping;
}
}
}
internal
IntPtrSendMessage(
int
msg,
int
wparam,
int
lparam)
{
return
new
IntPtr(Win32.SendMessage(
this
.Handle,msg,wparam,lparam));
}
}
}