|
|
@ -660,6 +660,49 @@ namespace Apewer.Surface |
|
|
|
if (form != null) SetTopMost(form.Handle, value); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>释放系统资源。</summary>
|
|
|
|
public static void Dispose(Control control) |
|
|
|
{ |
|
|
|
if (control == null) return; |
|
|
|
|
|
|
|
if (control.InvokeRequired) |
|
|
|
{ |
|
|
|
control.Invoke(() => Dispose(control)); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
Dispose(control.Controls); |
|
|
|
|
|
|
|
if (control is Form form) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
if (form.Visible) form.Close(); |
|
|
|
} |
|
|
|
catch { } |
|
|
|
} |
|
|
|
|
|
|
|
RuntimeUtility.Dispose(control); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>释放系统资源。</summary>
|
|
|
|
public static void Dispose(Control.ControlCollection controls) |
|
|
|
{ |
|
|
|
if (controls == null) return; |
|
|
|
|
|
|
|
var count = controls.Count; |
|
|
|
if (count < 1) return; |
|
|
|
|
|
|
|
var children = new Control[count]; |
|
|
|
controls.CopyTo(children, 0); |
|
|
|
|
|
|
|
foreach (var child in children) |
|
|
|
{ |
|
|
|
controls.Remove(child); |
|
|
|
Dispose(child); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endregion
|
|
|
|