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