OSDN Git Service

コレクション初期化子を使用する (IDE0028)
[opentween/open-tween.git] / OpenTween / SearchWordDialog.cs
index 6e51599..d68c1b3 100644 (file)
@@ -51,13 +51,13 @@ namespace OpenTween
 
         public class SearchOptions
         {
-            public readonly SearchType Type;
-            public readonly string Query;
+            public SearchType Type { get; }
+            public string Query { get; }
 
             // タイムライン内検索のみで使用する
-            public readonly bool NewTab;
-            public readonly bool CaseSensitive;
-            public readonly bool UseRegex;
+            public bool NewTab { get; }
+            public bool CaseSensitive { get; }
+            public bool UseRegex { get; }
 
             public SearchOptions(SearchType type, string query, bool newTab, bool caseSensitive, bool useRegex)
             {
@@ -128,18 +128,30 @@ namespace OpenTween
             this.textSearchPublic.ResetText();
         }
 
-        private void textSearchTimeline_Shown(object sender, EventArgs e)
+        private void SearchWordDialog_Shown(object sender, EventArgs e)
         {
-            this.textSearchTimeline.SelectAll();
-            this.textSearchTimeline.Focus();
+            ActivateSelectedTabPage();
         }
 
         private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
         {
+            ActivateSelectedTabPage();
+        }
+
+        private void ActivateSelectedTabPage()
+        {
             if (this.tabControl.SelectedTab == this.tabPageTimeline)
+            {
                 this.AcceptButton = this.buttonSearchTimeline;
+                this.textSearchTimeline.SelectAll();
+                this.textSearchTimeline.Focus();
+            }
             else
+            {
                 this.AcceptButton = this.buttonSearchPublic;
+                this.textSearchPublic.SelectAll();
+                this.textSearchPublic.Focus();
+            }
         }
 
         private void buttonSearchTimeline_Click(object sender, EventArgs e)
@@ -199,13 +211,19 @@ namespace OpenTween
             );
         }
 
-        private /* async */ void linkLabelSearchHelp_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
+        private async void linkLabelSearchHelp_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
         {
             // 「検索オプションの使い方」ページのURL
             const string PublicSearchHelpUrl = "https://support.twitter.com/articles/249059";
 
             var tweenMain = (TweenMain)this.Owner;
-            tweenMain.OpenUriAsync(PublicSearchHelpUrl);
+            await tweenMain.OpenUriInBrowserAsync(PublicSearchHelpUrl);
+        }
+
+        private void SearchWordDialog_KeyDown(object sender, KeyEventArgs e)
+        {
+            if (e.KeyCode == Keys.Escape)
+                this.DialogResult = DialogResult.Cancel;
         }
     }
 }