110,534
社区成员
发帖
与我相关
我的任务
分享
[SRCategory(SR.CatAppearance), SRDescription(SR.ControlOnPaintDescr)]
public event PaintEventHandler Paint {
add {
Events.AddHandler(EventPaint, value);
}
remove {
Events.RemoveHandler(EventPaint, value);
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnPaint(PaintEventArgs e) {
PaintEventHandler handler = (PaintEventHandler)Events[EventPaint];
if (handler != null) handler(this, e);
}
[ResourceExposure(ResourceScope.None)]
public void Invalidate(bool invalidateChildren) {
if (IsHandleCreated) {
if (invalidateChildren) {
SafeNativeMethods.RedrawWindow(new HandleRef(window, Handle),
null, NativeMethods.NullHandleRef,
NativeMethods.RDW_INVALIDATE |
NativeMethods.RDW_ERASE |
NativeMethods.RDW_ALLCHILDREN);
}
else {
// It's safe to invoke InvalidateRect from a separate thread.
using (new MultithreadSafeCallScope())
{
SafeNativeMethods.InvalidateRect(new HandleRef(window, Handle),
null,
(controlStyle & ControlStyles.Opaque) != ControlStyles.Opaque);
}
}
NotifyInvalidate(this.ClientRectangle);
}
}
public void Update() {
SafeNativeMethods.UpdateWindow(new HandleRef(window, InternalHandle));
}
public virtual void Refresh() {
Invalidate(true);
Update();
}