Skip to content

Commit

Permalink
Merge pull request #319 from opentween/tab-header-panel
Browse files Browse the repository at this point in the history
ユーザー・検索・Listタブのヘッダー部分を分離
  • Loading branch information
upsilon authored Apr 29, 2024
2 parents 4947ec3 + ee33408 commit eae1435
Show file tree
Hide file tree
Showing 11 changed files with 663 additions and 224 deletions.
34 changes: 34 additions & 0 deletions OpenTween.Tests/Controls/GeneralTimelineHeaderPanelTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// OpenTween - Client of Twitter
// Copyright (c) 2024 kim_upsilon (@kim_upsilon) <https://upsilo.net/~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 <http://www.gnu.org/licenses/>, 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();
}
}
}
34 changes: 34 additions & 0 deletions OpenTween.Tests/Controls/PublicSearchHeaderPanelTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// OpenTween - Client of Twitter
// Copyright (c) 2024 kim_upsilon (@kim_upsilon) <https://upsilo.net/~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 <http://www.gnu.org/licenses/>, 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 PublicSearchHeaderPanelTest
{
[WinFormsFact]
public void Initialize_Test()
{
using var panel = new PublicSearchHeaderPanel();
}
}
}
27 changes: 10 additions & 17 deletions OpenTween.Tests/TweenMainTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using System.Text.RegularExpressions;
using System.Windows.Forms;
using OpenTween.Api.DataModel;
using OpenTween.Controls;
using OpenTween.Models;
using OpenTween.OpenTweenCustomControl;
using OpenTween.Setting;
Expand Down Expand Up @@ -109,8 +110,8 @@ public void AddNewTab_UserTimelineTabTest()
Assert.Equal(2, tabPage.Controls.Count);
Assert.IsType<DetailsListView>(tabPage.Controls[0]);

var label = Assert.IsType<Label>(tabPage.Controls[1]);
Assert.Equal("twitterapi's Timeline", label.Text);
var header = Assert.IsType<GeneralTimelineHeaderPanel>(tabPage.Controls[1]);
Assert.Equal("twitterapi's Timeline", header.HeaderText);
});
}

Expand Down Expand Up @@ -139,8 +140,8 @@ public void AddNewTab_ListTimelineTabTest()
Assert.Equal(2, tabPage.Controls.Count);
Assert.IsType<DetailsListView>(tabPage.Controls[0]);

var label = Assert.IsType<Label>(tabPage.Controls[1]);
Assert.Equal("@opentween/tetete [Protected]", label.Text);
var header = Assert.IsType<GeneralTimelineHeaderPanel>(tabPage.Controls[1]);
Assert.Equal("@opentween/tetete [Protected]", header.HeaderText);
});
}

Expand All @@ -166,17 +167,9 @@ public void AddNewTab_PublicSearchTabTest()
Assert.Equal(2, tabPage.Controls.Count);
Assert.IsType<DetailsListView>(tabPage.Controls[0]);

var panel = Assert.IsType<Panel>(tabPage.Controls[1]);
Assert.Equal(4, panel.Controls.Count);

var comboSearchWord = Assert.IsType<ComboBox>(panel.Controls[0]);
Assert.Equal("#OpenTween", comboSearchWord.Text);

var comboSearchLang = Assert.IsType<ComboBox>(panel.Controls[1]);
Assert.Equal("ja", comboSearchLang.Text);

Assert.IsType<Button>(panel.Controls[2]);
Assert.IsType<Label>(panel.Controls[3]);
var header = Assert.IsType<PublicSearchHeaderPanel>(tabPage.Controls[1]);
Assert.Equal("#OpenTween", header.Query);
Assert.Equal("ja", header.Lang);
});
}

Expand All @@ -198,7 +191,7 @@ public void RemoveSpecifiedTab_Test()

var tabPage = tweenMain.ListTab.TabPages[4];
var listView = (DetailsListView)tabPage.Controls[0];
var searchPanel = (Panel)tabPage.Controls[1];
var header = (PublicSearchHeaderPanel)tabPage.Controls[1];
Assert.Equal("hoge", tabPage.Text);

tweenMain.RemoveSpecifiedTab("hoge", confirm: false);
Expand All @@ -207,7 +200,7 @@ public void RemoveSpecifiedTab_Test()
Assert.False(context.TabInfo.ContainsTab("hoge"));
Assert.True(tabPage.IsDisposed);
Assert.True(listView.IsDisposed);
Assert.True(searchPanel.IsDisposed);
Assert.True(header.IsDisposed);
});
}

Expand Down
54 changes: 54 additions & 0 deletions OpenTween/Controls/GeneralTimelineHeaderPanel.Designer.cs

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

53 changes: 53 additions & 0 deletions OpenTween/Controls/GeneralTimelineHeaderPanel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// OpenTween - Client of Twitter
// Copyright (c) 2007-2011 kiri_feather (@kiri_feather) <[email protected]>
// (c) 2008-2011 Moz (@syo68k)
// (c) 2008-2011 takeshik (@takeshik) <http://www.takeshik.org/>
// (c) 2010-2011 anis774 (@anis774) <http://d.hatena.ne.jp/anis774/>
// (c) 2010-2011 fantasticswallow (@f_swallow) <http://twitter.com/f_swallow>
// (c) 2011 kim_upsilon (@kim_upsilon) <https://upsilo.net/~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 <http://www.gnu.org/licenses/>, 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;
}
}
25 changes: 25 additions & 0 deletions OpenTween/Controls/GeneralTimelineHeaderPanel.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?><root xml:space="preserve">
<resheader name="resmimetype"><value>text/microsoft-resx</value></resheader>
<resheader name="version"><value>2.0</value></resheader>
<resheader name="reader"><value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value></resheader>
<resheader name="writer"><value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value></resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing"><value>96, 96</value></data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"><value>True</value></metadata>
<data name="$this.Size" type="System.Drawing.Size, System.Drawing"><value>400, 22</value></data>
<data name="&gt;&gt;$this.Name"><value>GeneralTimelineHeaderPanel</value></data>
<data name="&gt;&gt;$this.Type"><value>System.Windows.Forms.UserControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value></data>
<data name="&gt;&gt;labelHeader.Name"><value>labelHeader</value></data>
<data name="&gt;&gt;labelHeader.Parent"><value>$this</value></data>
<data name="&gt;&gt;labelHeader.Type"><value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value></data>
<data name="&gt;&gt;labelHeader.ZOrder"><value>0</value></data>
<data name="labelHeader.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms"><value>Fill</value></data>
<data name="labelHeader.Location" type="System.Drawing.Point, System.Drawing"><value>0, 0</value></data>
<data name="labelHeader.Size" type="System.Drawing.Size, System.Drawing"><value>400, 22</value></data>
<data name="labelHeader.TabIndex" type="System.Int32, mscorlib"><value>0</value></data>
<data name="labelHeader.Text"><value>labelHeader</value></data>
<data name="labelHeader.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing"><value>MiddleLeft</value></data>
</root>
122 changes: 122 additions & 0 deletions OpenTween/Controls/PublicSearchHeaderPanel.Designer.cs

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

Loading

0 comments on commit eae1435

Please sign in to comment.