Skip to content

Commit

Permalink
ウィンドウサイズ等の設定値を適用する処理をResizeイベントからコンストラクタに移動
Browse files Browse the repository at this point in the history
  • Loading branch information
upsilon committed Dec 6, 2023
1 parent 39e84d6 commit e7ea8f3
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions OpenTween/Tween.cs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ ThumbnailGenerator thumbGenerator
this.TimerRefreshIcon.Enabled = false;

this.ignoreConfigSave = false;
this.TweenMain_Resize(this, EventArgs.Empty);
this.ApplyLayoutFromSettings();
}

private void TweenMain_Activated(object sender, EventArgs e)
Expand Down Expand Up @@ -7180,56 +7180,56 @@ private void TweenMain_Resize(object sender, EventArgs e)
{
this.Visible = false;
}
if (this.initialLayout && this.settings.Local != null && this.WindowState == FormWindowState.Normal && this.Visible)
if (this.WindowState != FormWindowState.Minimized)
{
// 現在の DPI と設定保存時の DPI との比を取得する
var configScaleFactor = this.settings.Local.GetConfigScaleFactor(this.CurrentAutoScaleDimensions);
this.formWindowState = this.WindowState;
}
}

this.ClientSize = ScaleBy(configScaleFactor, this.settings.Local.FormSize);
private void ApplyLayoutFromSettings()
{
// 現在の DPI と設定保存時の DPI との比を取得する
var configScaleFactor = this.settings.Local.GetConfigScaleFactor(this.CurrentAutoScaleDimensions);

// Splitterの位置設定
var splitterDistance = ScaleBy(configScaleFactor.Height, this.settings.Local.SplitterDistance);
if (splitterDistance > this.SplitContainer1.Panel1MinSize &&
splitterDistance < this.SplitContainer1.Height - this.SplitContainer1.Panel2MinSize - this.SplitContainer1.SplitterWidth)
{
this.SplitContainer1.SplitterDistance = splitterDistance;
}
this.ClientSize = ScaleBy(configScaleFactor, this.settings.Local.FormSize);

// 発言欄複数行
this.StatusText.Multiline = this.settings.Local.StatusMultiline;
if (this.StatusText.Multiline)
{
var statusTextHeight = ScaleBy(configScaleFactor.Height, this.settings.Local.StatusTextHeight);
var dis = this.SplitContainer2.Height - statusTextHeight - this.SplitContainer2.SplitterWidth;
if (dis > this.SplitContainer2.Panel1MinSize && dis < this.SplitContainer2.Height - this.SplitContainer2.Panel2MinSize - this.SplitContainer2.SplitterWidth)
{
this.SplitContainer2.SplitterDistance = this.SplitContainer2.Height - statusTextHeight - this.SplitContainer2.SplitterWidth;
}
this.StatusText.Height = statusTextHeight;
}
else
// Splitterの位置設定
var splitterDistance = ScaleBy(configScaleFactor.Height, this.settings.Local.SplitterDistance);
if (splitterDistance > this.SplitContainer1.Panel1MinSize &&
splitterDistance < this.SplitContainer1.Height - this.SplitContainer1.Panel2MinSize - this.SplitContainer1.SplitterWidth)
{
this.SplitContainer1.SplitterDistance = splitterDistance;
}

// 発言欄複数行
this.StatusText.Multiline = this.settings.Local.StatusMultiline;
if (this.StatusText.Multiline)
{
var statusTextHeight = ScaleBy(configScaleFactor.Height, this.settings.Local.StatusTextHeight);
var dis = this.SplitContainer2.Height - statusTextHeight - this.SplitContainer2.SplitterWidth;
if (dis > this.SplitContainer2.Panel1MinSize && dis < this.SplitContainer2.Height - this.SplitContainer2.Panel2MinSize - this.SplitContainer2.SplitterWidth)
{
if (this.SplitContainer2.Height - this.SplitContainer2.Panel2MinSize - this.SplitContainer2.SplitterWidth > 0)
{
this.SplitContainer2.SplitterDistance = this.SplitContainer2.Height - this.SplitContainer2.Panel2MinSize - this.SplitContainer2.SplitterWidth;
}
this.SplitContainer2.SplitterDistance = this.SplitContainer2.Height - statusTextHeight - this.SplitContainer2.SplitterWidth;
}

var previewDistance = ScaleBy(configScaleFactor.Width, this.settings.Local.PreviewDistance);
if (previewDistance > this.SplitContainer3.Panel1MinSize && previewDistance < this.SplitContainer3.Width - this.SplitContainer3.Panel2MinSize - this.SplitContainer3.SplitterWidth)
this.StatusText.Height = statusTextHeight;
}
else
{
if (this.SplitContainer2.Height - this.SplitContainer2.Panel2MinSize - this.SplitContainer2.SplitterWidth > 0)
{
this.SplitContainer3.SplitterDistance = previewDistance;
this.SplitContainer2.SplitterDistance = this.SplitContainer2.Height - this.SplitContainer2.Panel2MinSize - this.SplitContainer2.SplitterWidth;
}

// Panel2Collapsed は SplitterDistance の設定を終えるまで true にしない
this.SplitContainer3.Panel2Collapsed = true;

this.initialLayout = false;
}
if (this.WindowState != FormWindowState.Minimized)

var previewDistance = ScaleBy(configScaleFactor.Width, this.settings.Local.PreviewDistance);
if (previewDistance > this.SplitContainer3.Panel1MinSize && previewDistance < this.SplitContainer3.Width - this.SplitContainer3.Panel2MinSize - this.SplitContainer3.SplitterWidth)
{
this.formWindowState = this.WindowState;
this.SplitContainer3.SplitterDistance = previewDistance;
}

// Panel2Collapsed は SplitterDistance の設定を終えるまで true にしない
this.SplitContainer3.Panel2Collapsed = true;
this.initialLayout = false;
}

private void PlaySoundMenuItem_CheckedChanged(object sender, EventArgs e)
Expand Down

0 comments on commit e7ea8f3

Please sign in to comment.