From 696462e35d09d6673eb6af796311a217f3b73eb3 Mon Sep 17 00:00:00 2001 From: Kimura Youichi Date: Wed, 13 Apr 2022 03:11:32 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC=E3=83=BBLi?= =?UTF-8?q?st=E3=82=BF=E3=83=96=E3=81=AE=E3=83=98=E3=83=83=E3=83=80?= =?UTF-8?q?=E3=83=BC=E9=83=A8=E5=88=86=E3=82=92GeneralTimelineHeaderPanel?= =?UTF-8?q?=E3=81=AB=E5=88=86=E9=9B=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GeneralTimelineHeaderPanelTest.cs | 34 ++++++++++++ .../GeneralTimelineHeaderPanel.Designer.cs | 54 +++++++++++++++++++ .../Controls/GeneralTimelineHeaderPanel.cs | 53 ++++++++++++++++++ .../Controls/GeneralTimelineHeaderPanel.resx | 25 +++++++++ OpenTween/OpenTween.csproj | 9 ++++ OpenTween/Tween.cs | 40 +++++--------- 6 files changed, 189 insertions(+), 26 deletions(-) create mode 100644 OpenTween.Tests/Controls/GeneralTimelineHeaderPanelTest.cs create mode 100644 OpenTween/Controls/GeneralTimelineHeaderPanel.Designer.cs create mode 100644 OpenTween/Controls/GeneralTimelineHeaderPanel.cs create mode 100644 OpenTween/Controls/GeneralTimelineHeaderPanel.resx diff --git a/OpenTween.Tests/Controls/GeneralTimelineHeaderPanelTest.cs b/OpenTween.Tests/Controls/GeneralTimelineHeaderPanelTest.cs new file mode 100644 index 000000000..de5614376 --- /dev/null +++ b/OpenTween.Tests/Controls/GeneralTimelineHeaderPanelTest.cs @@ -0,0 +1,34 @@ +// OpenTween - Client of Twitter +// Copyright (c) 2024 kim_upsilon (@kim_upsilon) +// All rights reserved. +// +// This file is part of OpenTween. +// +// This program is free software; you can redistribute it and/or modify it +// under the terms of the GNU General public License as published by the Free +// Software Foundation; either version 3 of the License, or (at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General public License +// for more details. +// +// You should have received a copy of the GNU General public License along +// with this program. If not, see , or write to +// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, +// Boston, MA 02110-1301, USA. + +using Xunit; + +namespace OpenTween.Controls +{ + public class GeneralTimelineHeaderPanelTest + { + [WinFormsFact] + public void Initialize_Test() + { + using var panel = new GeneralTimelineHeaderPanel(); + } + } +} diff --git a/OpenTween/Controls/GeneralTimelineHeaderPanel.Designer.cs b/OpenTween/Controls/GeneralTimelineHeaderPanel.Designer.cs new file mode 100644 index 000000000..e5af858a4 --- /dev/null +++ b/OpenTween/Controls/GeneralTimelineHeaderPanel.Designer.cs @@ -0,0 +1,54 @@ +namespace OpenTween.Controls +{ + partial class GeneralTimelineHeaderPanel + { + /// + /// 必要なデザイナー変数です。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 使用中のリソースをすべてクリーンアップします。 + /// + /// マネージド リソースを破棄する場合は true を指定し、その他の場合は false を指定します。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region コンポーネント デザイナーで生成されたコード + + /// + /// デザイナー サポートに必要なメソッドです。このメソッドの内容を + /// コード エディターで変更しないでください。 + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GeneralTimelineHeaderPanel)); + this.labelHeader = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // labelHeader + // + resources.ApplyResources(this.labelHeader, "labelHeader"); + this.labelHeader.Name = "labelHeader"; + // + // GeneralTimelineHeaderPanel + // + resources.ApplyResources(this, "$this"); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.Controls.Add(this.labelHeader); + this.Name = "GeneralTimelineHeaderPanel"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label labelHeader; + } +} diff --git a/OpenTween/Controls/GeneralTimelineHeaderPanel.cs b/OpenTween/Controls/GeneralTimelineHeaderPanel.cs new file mode 100644 index 000000000..961b17f04 --- /dev/null +++ b/OpenTween/Controls/GeneralTimelineHeaderPanel.cs @@ -0,0 +1,53 @@ +// OpenTween - Client of Twitter +// Copyright (c) 2007-2011 kiri_feather (@kiri_feather) +// (c) 2008-2011 Moz (@syo68k) +// (c) 2008-2011 takeshik (@takeshik) +// (c) 2010-2011 anis774 (@anis774) +// (c) 2010-2011 fantasticswallow (@f_swallow) +// (c) 2011 kim_upsilon (@kim_upsilon) +// All rights reserved. +// +// This file is part of OpenTween. +// +// This program is free software; you can redistribute it and/or modify it +// under the terms of the GNU General public License as published by the Free +// Software Foundation; either version 3 of the License, or (at your option) +// any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General public License +// for more details. +// +// You should have received a copy of the GNU General public License along +// with this program. If not, see , or write to +// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, +// Boston, MA 02110-1301, USA. + +#nullable enable + +using System.Windows.Forms; + +namespace OpenTween.Controls +{ + public partial class GeneralTimelineHeaderPanel : UserControl + { + public string HeaderText + { + get => this.headerText; + set + { + this.headerText = value; + this.UpdateLabelUser(); + } + } + + private string headerText = ""; + + public GeneralTimelineHeaderPanel() + => this.InitializeComponent(); + + private void UpdateLabelUser() + => this.labelHeader.Text = this.headerText; + } +} diff --git a/OpenTween/Controls/GeneralTimelineHeaderPanel.resx b/OpenTween/Controls/GeneralTimelineHeaderPanel.resx new file mode 100644 index 000000000..db07e6f61 --- /dev/null +++ b/OpenTween/Controls/GeneralTimelineHeaderPanel.resx @@ -0,0 +1,25 @@ + + text/microsoft-resx + 2.0 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + 96, 96 + True + 400, 22 + GeneralTimelineHeaderPanel + System.Windows.Forms.UserControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + labelHeader + $this + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + 0 + Fill + 0, 0 + 400, 22 + 0 + labelHeader + MiddleLeft + diff --git a/OpenTween/OpenTween.csproj b/OpenTween/OpenTween.csproj index a08f3638b..f505d8aa3 100644 --- a/OpenTween/OpenTween.csproj +++ b/OpenTween/OpenTween.csproj @@ -71,6 +71,12 @@ PublicSearchHeaderPanel.cs + + UserControl + + + GeneralTimelineHeaderPanel.cs + Form @@ -343,6 +349,9 @@ PublicSearchHeaderPanel.cs + + GeneralTimelineHeaderPanel.cs + EncryptApiKeyDialog.cs diff --git a/OpenTween/Tween.cs b/OpenTween/Tween.cs index 576bfb1e6..d643b99a9 100644 --- a/OpenTween/Tween.cs +++ b/OpenTween/Tween.cs @@ -2842,33 +2842,21 @@ public bool AddNewTab(TabModel tab, bool startup) Control? headerPanel = null; - // UserTimeline関連 - var userTab = tab as UserTimelineTabModel; - var listTab = tab as ListTimelineTabModel; - - if (userTab != null || listTab != null) + if (tab is UserTimelineTabModel userTab) { - var label = new Label + headerPanel = new GeneralTimelineHeaderPanel { Dock = DockStyle.Top, - Name = "labelUser", - TabIndex = 0, + HeaderText = $"{userTab.ScreenName}'s Timeline", }; - - if (listTab != null) - { - label.Text = listTab.ListInfo.ToString(); - } - else if (userTab != null) - { - label.Text = userTab.ScreenName + "'s Timeline"; - } - label.TextAlign = ContentAlignment.MiddleLeft; - using (var tmpComboBox = new ComboBox()) + } + else if (tab is ListTimelineTabModel listTab) + { + headerPanel = new GeneralTimelineHeaderPanel { - label.Height = tmpComboBox.Height; - } - tabPage.Controls.Add(label); + Dock = DockStyle.Top, + HeaderText = listTab.ListInfo.ToString(), + }; } // 検索関連の準備 else if (tab is PublicSearchTabModel searchTab) @@ -2994,11 +2982,11 @@ public bool RemoveSpecifiedTab(string tabName, bool confirm) this.ListTab.Controls.Remove(tabPage); // 後付けのコントロールを破棄 - if (tabInfo.TabType == MyCommon.TabUsageType.UserTimeline || tabInfo.TabType == MyCommon.TabUsageType.Lists) + if (tabInfo.TabType == MyCommon.TabUsageType.UserTimeline || + tabInfo.TabType == MyCommon.TabUsageType.Lists) { - using var label = tabPage.Controls["labelUser"]; - tabPage.Controls.Remove(label); - listCustom = (DetailsListView)tabPage.Tag; + using var panel = tabPage.Controls.OfType().First(); + tabPage.Controls.Remove(panel); } else if (tabInfo.TabType == MyCommon.TabUsageType.PublicSearch) {