Browse Source

完善布局

qdwf_with_date_js8180
Robin_PC\robin 9 hours ago
parent
commit
6f69a3c495
2 changed files with 24 additions and 9 deletions
  1. +6
    -5
      ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.Designer.cs
  2. +18
    -4
      ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.cs

+ 6
- 5
ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.Designer.cs View File

@ -454,9 +454,9 @@
// //
// flowLayoutPanel2 // flowLayoutPanel2
// //
this.flowLayoutPanel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.flowLayoutPanel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.flowLayoutPanel2.AutoScroll = true; this.flowLayoutPanel2.AutoScroll = true;
this.flowLayoutPanel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.flowLayoutPanel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.flowLayoutPanel2.Location = new System.Drawing.Point(-1, 89); this.flowLayoutPanel2.Location = new System.Drawing.Point(-1, 89);
@ -467,8 +467,9 @@
// //
// flowLayoutPanel1 // flowLayoutPanel1
// //
this.flowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.flowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));
this.flowLayoutPanel1.AutoScroll = true;
this.flowLayoutPanel1.WrapContents = true; // 关键:禁止换行,横向滚动
this.flowLayoutPanel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.flowLayoutPanel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 4); this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 4);
this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(4); this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(4);


+ 18
- 4
ButcherFactory.Form/SegmentProductionAuto_/SegmentProductionAutoForm.cs View File

@ -59,6 +59,8 @@ namespace ButcherFactory.SegmentProductionAuto_
netStateWatch1.GetConnectState = () => LoginUtil.TestConnection(500); netStateWatch1.GetConnectState = () => LoginUtil.TestConnection(500);
this.FormClosing += SegmentProductionAutoForm_FormClosing; this.FormClosing += SegmentProductionAutoForm_FormClosing;
this.Load += Form1_Load; this.Load += Form1_Load;
this.Resize += SegmentProductionAutoForm_Resize; // 新增Resize事件
workUnitSelect.SelectedIndexChanged += delegate workUnitSelect.SelectedIndexChanged += delegate
{ {
if (workUnitSelect.SelectedValue == null) if (workUnitSelect.SelectedValue == null)
@ -91,14 +93,26 @@ namespace ButcherFactory.SegmentProductionAuto_
}; };
} }
// 窗体大小变化时,刷新flowlayout布局,保证滚动区域生效
private void SegmentProductionAutoForm_Resize(object sender, EventArgs e)
{
if (_isFormClosing || this.IsDisposed) return;
// 强制刷新布局,解决低分辨率下FlowLayoutPanel不重绘、滚动失效
flowLayoutPanel1.PerformLayout();
flowLayoutPanel2.PerformLayout();
flowLayoutPanel3.PerformLayout();
flowLayoutPanel4.PerformLayout();
}
private void Form1_Load(object sender, EventArgs e) private void Form1_Load(object sender, EventArgs e)
{ {
Rectangle workArea = Screen.PrimaryScreen.WorkingArea; Rectangle workArea = Screen.PrimaryScreen.WorkingArea;
// 取屏幕可用区域的82%,上限限制 1440, 810
int initW = Math.Min((int)(workArea.Width * 0.9), 1440);
int initH = Math.Min((int)(workArea.Height * 0.9), 810);
// 初始窗口使用屏幕工作区,不再上限死1440,810
int initW = (int)(workArea.Width * 0.95);
int initH = (int)(workArea.Height * 0.95);
this.ClientSize = new Size(initW, initH); this.ClientSize = new Size(initW, initH);
this.MinimumSize = new Size(1000, 650);
this.MinimumSize = new Size(1024, 680); // 设置最小窗口,防止缩太小布局乱掉
} }


Loading…
Cancel
Save