diff --git a/OpenTween/Tween.cs b/OpenTween/Tween.cs index d9492a09c..5e0a527ab 100644 --- a/OpenTween/Tween.cs +++ b/OpenTween/Tween.cs @@ -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) @@ -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)