Skip to content

Commit

Permalink
refactor: resize MainForm when no Profile
Browse files Browse the repository at this point in the history
  • Loading branch information
chsbuffer committed Oct 20, 2020
1 parent 30854de commit a2ae28d
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 39 deletions.
92 changes: 63 additions & 29 deletions Netch/Forms/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 1 addition & 8 deletions Netch/Forms/MainForm.Profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ public partial class Dummy

partial class MainForm
{
/// init at <see cref="MainForm_Load"/>
private int _sizeHeight;

private int _profileConfigurationHeight;
private int _profileGroupboxHeight;
private int _configurationGroupBoxHeight;
private int _profileConfigurationHeight;

private void InitProfile()
{
Expand All @@ -41,7 +37,6 @@ private void InitProfile()
ProfileGroupBox.Visible = false;

ConfigurationGroupBox.Size = new Size(ConfigurationGroupBox.Size.Width, _configurationGroupBoxHeight - _profileConfigurationHeight);
Size = new Size(Size.Width, _sizeHeight - (_profileConfigurationHeight + _profileGroupboxHeight));
}
else
{
Expand Down Expand Up @@ -75,11 +70,9 @@ private void InitProfile()
ProfileTable.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 1));
}

if (Size.Height == _sizeHeight) return;
configLayoutPanel.RowStyles[2].SizeType = SizeType.AutoSize;
ProfileGroupBox.Visible = true;
ConfigurationGroupBox.Size = new Size(ConfigurationGroupBox.Size.Width, _configurationGroupBoxHeight);
Size = new Size(Size.Width, _sizeHeight);
}
}

Expand Down
2 changes: 0 additions & 2 deletions Netch/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@ private void MainForm_Load(object sender, EventArgs e)
// 隐藏 NatTypeStatusLabel
NatTypeStatusText();

_sizeHeight = Size.Height;
_configurationGroupBoxHeight = ConfigurationGroupBox.Height;
_profileConfigurationHeight = ConfigurationGroupBox.Controls[0].Height / 3; // 因为 AutoSize, 所以得到的是Controls的总高度
_profileGroupboxHeight = ProfileGroupBox.Height;
// 加载快速配置
InitProfile();

Expand Down

0 comments on commit a2ae28d

Please sign in to comment.