, , PictureBox
( Load
):
private void InstallNewImage(Image value,
ImageInstallationType installationType)
{
StopAnimate();
this.image = value;
LayoutTransaction.DoLayoutIf(AutoSize, this, this, PropertyNames.Image);
Animate();
if (installationType != ImageInstallationType.ErrorOrInitial)
{
AdjustSize();
}
this.imageInstallationType = installationType;
Invalidate();
CommonProperties.xClearPreferredSizeCache(this);
}
, , , , - , Invalidate
, .
Visible
( Control
), , p/invoke .
protected virtual void SetVisibleCore(bool value) {
try {
System.Internal.HandleCollector.SuspendCollect();
if (GetVisibleCore() != value) {
if (!value) {
SelectNextIfFocused();
}
bool fireChange = false;
if (GetTopLevel()) {
if (IsHandleCreated || value) {
SafeNativeMethods.ShowWindow(new HandleRef(this, Handle), value ? ShowParams : NativeMethods.SW_HIDE);
}
}
else if (IsHandleCreated || value && parent != null && parent.Created) {
SetState(STATE_VISIBLE, value);
fireChange = true;
try {
if (value) CreateControl();
SafeNativeMethods.SetWindowPos(new HandleRef(window, Handle),
NativeMethods.NullHandleRef,
0, 0, 0, 0,
NativeMethods.SWP_NOSIZE
| NativeMethods.SWP_NOMOVE
| NativeMethods.SWP_NOZORDER
| NativeMethods.SWP_NOACTIVATE
| (value ? NativeMethods.SWP_SHOWWINDOW : NativeMethods.SWP_HIDEWINDOW));
}
catch {
SetState(STATE_VISIBLE, !value);
throw;
}
}
if (GetVisibleCore() != value) {
SetState(STATE_VISIBLE, value);
fireChange = true;
}
if (fireChange) {
using (new LayoutTransaction(parent, this, PropertyNames.Visible)) {
OnVisibleChanged(EventArgs.Empty);
}
}
UpdateRoot();
}
else {
if (!GetState(STATE_VISIBLE) && !value && IsHandleCreated) {
if (!SafeNativeMethods.IsWindowVisible(new HandleRef(this,this.Handle))) {
return;
}
}
SetState(STATE_VISIBLE, value);
if (IsHandleCreated) {
SafeNativeMethods.SetWindowPos(
new HandleRef(window, Handle), NativeMethods.NullHandleRef, 0, 0, 0, 0, NativeMethods.SWP_NOSIZE |
NativeMethods.SWP_NOMOVE | NativeMethods.SWP_NOZORDER | NativeMethods.SWP_NOACTIVATE |
(value ? NativeMethods.SWP_SHOWWINDOW : NativeMethods.SWP_HIDEWINDOW));
}
}
}
finally {
System.Internal.HandleCollector.ResumeCollect();
}
}
, , " ", , ( JetBrains DotPeek, ildasm ).