1 // OpenTween - Client of Twitter
2 // Copyright (c) 2007-2011 kiri_feather (@kiri_feather) <kiri.feather@gmail.com>
3 // (c) 2008-2011 Moz (@syo68k)
4 // (c) 2008-2011 takeshik (@takeshik) <http://www.takeshik.org/>
5 // (c) 2010-2011 anis774 (@anis774) <http://d.hatena.ne.jp/anis774/>
6 // (c) 2010-2011 fantasticswallow (@f_swallow) <http://twitter.com/f_swallow>
7 // (c) 2011 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
8 // All rights reserved.
10 // This file is part of OpenTween.
12 // This program is free software; you can redistribute it and/or modify it
13 // under the terms of the GNU General Public License as published by the Free
14 // Software Foundation; either version 3 of the License, or (at your option)
17 // This program is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 // You should have received a copy of the GNU General Public License along
23 // with this program. If not, see <http://www.gnu.org/licenses/>, or write to
24 // the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
25 // Boston, MA 02110-1301, USA.
28 using System.Collections.Generic;
29 using System.ComponentModel;
34 using System.Windows.Forms;
38 public partial class SearchWordDialog : OTBaseForm
40 public enum SearchType
52 public class SearchOptions
54 public readonly SearchType Type;
55 public readonly string Query;
58 public readonly bool NewTab;
59 public readonly bool CaseSensitive;
60 public readonly bool UseRegex;
62 public SearchOptions(SearchType type, string query, bool newTab, bool caseSensitive, bool useRegex)
67 this.CaseSensitive = caseSensitive;
68 this.UseRegex = useRegex;
72 private SearchOptions resultOptoins = null;
73 public SearchOptions ResultOptions
75 get { return this.resultOptoins; }
78 this.resultOptoins = value;
88 case SearchType.Timeline:
89 this.tabControl.SelectedTab = this.tabPageTimeline;
90 this.textSearchTimeline.Text = value.Query;
91 this.checkTimelineCaseSensitive.Checked = value.CaseSensitive;
92 this.checkTimelineRegex.Checked = value.UseRegex;
94 case SearchType.Public:
95 this.tabControl.SelectedTab = this.tabPagePublic;
96 this.textSearchTimeline.Text = value.Query;
99 throw new InvalidEnumArgumentException("value.Type", (int)value.Type, typeof(SearchType));
104 private bool disableNetTabButton = false;
105 public bool DisableNewTabButton
107 get { return this.disableNetTabButton; }
110 this.disableNetTabButton = value;
111 this.buttonSearchTimelineNew.Enabled = !value;
115 public SearchWordDialog()
117 InitializeComponent();
122 this.tabControl.SelectedTab = this.tabPageTimeline;
124 this.textSearchTimeline.ResetText();
125 this.checkTimelineCaseSensitive.Checked = false;
126 this.checkTimelineRegex.Checked = false;
128 this.textSearchPublic.ResetText();
131 private void textSearchTimeline_Shown(object sender, EventArgs e)
133 this.textSearchTimeline.SelectAll();
134 this.textSearchTimeline.Focus();
137 private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
139 if (this.tabControl.SelectedTab == this.tabPageTimeline)
140 this.AcceptButton = this.buttonSearchTimeline;
142 this.AcceptButton = this.buttonSearchPublic;
145 private void buttonSearchTimeline_Click(object sender, EventArgs e)
147 if (string.IsNullOrEmpty(this.textSearchTimeline.Text))
149 this.DialogResult = DialogResult.Cancel;
153 this.DialogResult = DialogResult.OK;
155 this.ResultOptions = new SearchOptions(
157 this.textSearchTimeline.Text,
159 this.checkTimelineCaseSensitive.Checked,
160 this.checkTimelineRegex.Checked
164 private void buttonSearchTimelineNew_Click(object sender, EventArgs e)
166 if (string.IsNullOrEmpty(this.textSearchTimeline.Text))
168 this.DialogResult = DialogResult.Cancel;
172 this.DialogResult = DialogResult.OK;
174 this.ResultOptions = new SearchOptions(
176 this.textSearchTimeline.Text,
178 this.checkTimelineCaseSensitive.Checked,
179 this.checkTimelineRegex.Checked
183 private void buttonSearchPublic_Click(object sender, EventArgs e)
185 if (string.IsNullOrEmpty(this.textSearchPublic.Text))
187 this.DialogResult = DialogResult.Cancel;
191 this.DialogResult = DialogResult.OK;
193 this.ResultOptions = new SearchOptions(
195 this.textSearchPublic.Text,
202 private /* async */ void linkLabelSearchHelp_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
204 // 「検索オプションの使い方」ページのURL
205 const string PublicSearchHelpUrl = "https://support.twitter.com/articles/249059";
207 var tweenMain = (TweenMain)this.Owner;
208 tweenMain.OpenUriAsync(PublicSearchHelpUrl);