-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from DigitalPlatform/master
同步源
- Loading branch information
Showing
29 changed files
with
183 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Windows.Forms; | ||
|
||
namespace DigitalPlatform | ||
{ | ||
/// <summary> | ||
/// Control 的扩展方法 | ||
/// </summary> | ||
public static class ControlExtention | ||
{ | ||
#region 不会被自动 Dispose 的 子 Control,放在这里托管,避免内存泄漏 | ||
|
||
public static void AddFreeControl(List<Control> controls, | ||
Control control) | ||
{ | ||
if (controls.IndexOf(control) == -1) | ||
controls.Add(control); | ||
} | ||
|
||
public static void RemoveFreeControl(List<Control> controls, | ||
Control control) | ||
{ | ||
controls.Remove(control); | ||
} | ||
|
||
public static void DisposeFreeControls(List<Control> controls) | ||
{ | ||
foreach (Control control in controls) | ||
{ | ||
control.Dispose(); | ||
} | ||
controls.Clear(); | ||
} | ||
|
||
#endregion | ||
|
||
// 清除控件集合。使用这个函数便于 Dispose() 所清除的控件对象 | ||
public static void ClearControls(this Control parent, | ||
bool bDispose = false) | ||
{ | ||
if (parent.Controls.Count == 0) | ||
return; | ||
|
||
List<Control> controls = new List<Control>(); | ||
foreach (Control control in parent.Controls) | ||
{ | ||
controls.Add(control); | ||
} | ||
|
||
parent.Controls.Clear(); | ||
if (bDispose) | ||
{ | ||
foreach (Control control in controls) | ||
{ | ||
control.Dispose(); | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
/// <summary> | ||
/// ScrollableControl 的扩展方法 | ||
/// </summary> | ||
public static class ScrollableControlExtention | ||
{ | ||
public static void SetAutoScrollPosition(this ScrollableControl control, Point p) | ||
{ | ||
if (p.Y + control.ClientSize.Height > control.DisplayRectangle.Height) | ||
p.Y = control.DisplayRectangle.Height - control.ClientSize.Height; | ||
if (p.X + control.ClientSize.Width > control.DisplayRectangle.Width) | ||
p.X = control.DisplayRectangle.Width - control.ClientSize.Width; | ||
control.AutoScrollPosition = new Point(p.X, p.Y); | ||
} | ||
} | ||
|
||
public static class WebBrowserExtension | ||
{ | ||
public static void ScrollToEnd(this WebBrowser webBrowser1) | ||
{ | ||
if (webBrowser1.Document != null | ||
&& webBrowser1.Document.Window != null | ||
&& webBrowser1.Document.Body != null) | ||
webBrowser1.Document.Window.ScrollTo( | ||
0, | ||
webBrowser1.Document.Body.ScrollRectangle.Height); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.