根据设备自动计算宽度
This commit is contained in:
parent
98885c3aef
commit
a03a5f4348
Binary file not shown.
@ -58,6 +58,11 @@ namespace AIProofread
|
||||
System.Windows.Forms.MessageBox.Show(message);
|
||||
}
|
||||
|
||||
public int getMinWIdth()
|
||||
{
|
||||
return Globals.ThisAddIn.GetMinWidth();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加事件
|
||||
/// </summary>
|
||||
|
@ -29,6 +29,7 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.web = new Microsoft.Web.WebView2.WinForms.WebView2();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.web)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@ -46,21 +47,34 @@
|
||||
this.web.TabIndex = 0;
|
||||
this.web.ZoomFactor = 1D;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(175, 590);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(41, 12);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "校对王";
|
||||
this.label1.Visible = false;
|
||||
//
|
||||
// ProofreadMainControl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.web);
|
||||
this.Name = "ProofreadMainControl";
|
||||
this.Size = new System.Drawing.Size(400, 800);
|
||||
this.Load += new System.EventHandler(this.ProofreadMainControl_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.web)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public Microsoft.Web.WebView2.WinForms.WebView2 web;
|
||||
private System.Windows.Forms.Label label1;
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ namespace AIProofread.Controls
|
||||
|
||||
private void ProofreadMainControl_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.web.Source = new Uri(Config.WebPath("#home?version=" + Config.APP_VERSION));
|
||||
this.web.Source = new Uri(Config.WebPath("home?version=" + Config.APP_VERSION + "&t=" + DateTime.Now.Ticks));
|
||||
//this.SizeChanged += ProofreadMainControl_SizeChanged;
|
||||
}
|
||||
|
||||
@ -32,5 +32,9 @@ namespace AIProofread.Controls
|
||||
this.Width = this.minWidth;
|
||||
}
|
||||
}
|
||||
public int LabelWidth()
|
||||
{
|
||||
return label1.Width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace AIProofread
|
||||
/// <summary>
|
||||
/// 最小宽度
|
||||
/// </summary>
|
||||
private const int MinWidth = 420;
|
||||
public static int MinWidth = 0;
|
||||
/// <summary>
|
||||
/// 启动路径
|
||||
/// </summary>
|
||||
@ -147,14 +147,17 @@ namespace AIProofread
|
||||
|
||||
//proofreadPanel = new ProofreadMainControl();
|
||||
var control = new ProofreadMainControl(doc, MinWidth);
|
||||
if (MinWidth < 10)
|
||||
{
|
||||
MinWidth = 420 * control.LabelWidth() / 42;
|
||||
}
|
||||
var panel = Globals.ThisAddIn.CustomTaskPanes.Add(control, AddinName);
|
||||
this.currentDocumentTaskPane = panel;
|
||||
taskPanels.Add(doc, panel);
|
||||
control.Width = MinWidth;
|
||||
panel.Width = MinWidth;
|
||||
panel.Visible = false;
|
||||
panel.VisibleChanged += Panel_VisibleChanged;
|
||||
|
||||
control.Width = MinWidth;
|
||||
panel.Width = MinWidth;
|
||||
// 监听尺寸变化 防止最小尺寸小于设置值
|
||||
control.SizeChanged += Control_SizeChanged;
|
||||
return panel;
|
||||
@ -185,6 +188,11 @@ namespace AIProofread
|
||||
}
|
||||
}
|
||||
|
||||
public int GetMinWidth()
|
||||
{
|
||||
return MinWidth;
|
||||
}
|
||||
|
||||
public void Send(SendOrPostCallback d)
|
||||
{
|
||||
FmainThreadContext.Send(d, null);
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user