添加窗体居中显示功能并优化资源释放
This commit is contained in:
parent
7e26695000
commit
7cfab47216
Binary file not shown.
@ -112,6 +112,12 @@ namespace AIProofread.Controls
|
||||
this.FormBorderStyle = FormBorderStyle.None;
|
||||
}
|
||||
|
||||
public void SetHeight(int height)
|
||||
{
|
||||
this.Height = height;
|
||||
CenterToScreen();
|
||||
}
|
||||
|
||||
protected async void InitWebView(WebView2 webView,String url,string name,Action callaback = null)
|
||||
{
|
||||
//Bridge.InitWebEnvAsync(name, webView);
|
||||
|
@ -14,6 +14,19 @@ namespace AIProofread.Controls
|
||||
public FormLogin()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.FormClosed += (s, e) =>
|
||||
{
|
||||
// 关闭时释放资源
|
||||
try
|
||||
{
|
||||
if (web != null)
|
||||
{
|
||||
web.Dispose();
|
||||
web = null;
|
||||
}
|
||||
}
|
||||
catch { };
|
||||
};
|
||||
//Bridge.InitWebEnvAsync("login", web);
|
||||
//Bridge.AddEventHandler(BridgeEvent.LoginSuccess, OnLoginSuccess);
|
||||
}
|
||||
@ -21,6 +34,19 @@ namespace AIProofread.Controls
|
||||
{
|
||||
this.action = action;
|
||||
InitializeComponent();
|
||||
this.FormClosed += (s, e) =>
|
||||
{
|
||||
// 关闭时释放资源
|
||||
try
|
||||
{
|
||||
if (web != null)
|
||||
{
|
||||
web.Dispose();
|
||||
web = null;
|
||||
}
|
||||
}
|
||||
catch { };
|
||||
};
|
||||
}
|
||||
|
||||
private void OnLoginSuccess(object sender, EventArgs e)
|
||||
|
@ -39,6 +39,7 @@ namespace AIProofread.Controls
|
||||
{
|
||||
this.Width = (int)(width * dpiScaleFactor);
|
||||
this.Height = (int)(height * dpiScaleFactor);
|
||||
CenterToScreen();
|
||||
}
|
||||
|
||||
private void FormWebView_Load(object sender, EventArgs e)
|
||||
|
Loading…
x
Reference in New Issue
Block a user