52 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AIProofread.Controls
{
[ClassInterface(ClassInterfaceType.AutoDual)]
[ComVisible(true)]
public partial class FormWebView : BaseWinForm
{
public string WebUrl { get; set; }
private double dpiScaleFactor;
public FormWebView(string url,int width,int height)
{
InitializeComponent();
this.WebUrl = url;
this.dpiScaleFactor = this.label1.Width / 42.0; // 设置的宽度为42实际渲染宽度 / 42 即为缩放比例
Screen screen = Screen.FromControl(this);
this.SetSize(width, height);
this.StartPosition = FormStartPosition.CenterScreen;
}
public void SetTitle(string title)
{
this.Text = title;
}
public void SetSize(int width, int height)
{
this.Width = (int)(width * dpiScaleFactor);
this.Height = (int)(height * dpiScaleFactor);
CenterToScreen();
}
private void FormWebView_Load(object sender, EventArgs e)
{
// 初始化
InitWebView(WebView,this.WebUrl, "webview");
}
}
}