OSDN Git Service

テストコード修正
[opentween/open-tween.git] / OpenTween / AtIdSupplement.cs
index 2595319..d87967d 100644 (file)
@@ -35,14 +35,13 @@ using System.Windows.Forms;
 
 namespace OpenTween
 {
-    public partial class AtIdSupplement : Form
+    public partial class AtIdSupplement : OTBaseForm
     {
+        public string StartsWith { get; set; } = "";
+
         public string inputText = "";
         public bool isBack = false;
         private string startChar = "";
-        //    private bool tabkeyFix = false;
-
-        private string _StartsWith = "";
 
         public void AddItem(string id)
         {
@@ -71,12 +70,7 @@ namespace OpenTween
         }
 
         public int ItemCount
-        {
-            get
-            {
-                return this.TextId.AutoCompleteCustomSource.Count;
-            }
-        }
+            => this.TextId.AutoCompleteCustomSource.Count;
 
         private void ButtonOK_Click(object sender, EventArgs e) /*Handles ButtonOK.Click*/
         {
@@ -92,21 +86,21 @@ namespace OpenTween
 
         private void TextId_KeyDown(object sender, KeyEventArgs e) /*Handles TextId.KeyDown*/
         {
-            if (e.KeyCode == Keys.Back && this.TextId.Text == "")
+            if (e.KeyCode == Keys.Back && string.IsNullOrEmpty(this.TextId.Text))
             {
                 inputText = "";
                 isBack = true;
                 this.Close();
             }
-            if (e.KeyCode == Keys.Space || e.KeyCode == Keys.Tab)
+            else if (e.KeyCode == Keys.Space || e.KeyCode == Keys.Tab)
             {
                 inputText = this.TextId.Text + " ";
                 isBack = false;
                 this.Close();
             }
-            if (e.Control && e.KeyCode == Keys.Delete)
+            else if (e.Control && e.KeyCode == Keys.Delete)
             {
-                if (this.TextId.Text != "")
+                if (!string.IsNullOrEmpty(this.TextId.Text))
                 {
                     var idx = this.TextId.AutoCompleteCustomSource.IndexOf(this.TextId.Text);
                     if (idx > -1)
@@ -130,18 +124,16 @@ namespace OpenTween
         private void AtIdSupplement_Shown(object sender, EventArgs e) /*Handles this.Shown*/
         {
             TextId.Text = startChar;
-            if (!string.IsNullOrEmpty(_StartsWith))
+            if (!string.IsNullOrEmpty(this.StartsWith))
             {
-                TextId.Text += _StartsWith.Substring(0, _StartsWith.Length);
+                TextId.Text += this.StartsWith.Substring(0, this.StartsWith.Length);
             }
             TextId.SelectionStart = TextId.Text.Length;
             TextId.Focus();
         }
 
         public AtIdSupplement()
-        {
-            InitializeComponent();
-        }
+            => this.InitializeComponent();
 
         public AtIdSupplement(List<string> ItemList, string startCharacter)
         {
@@ -164,21 +156,9 @@ namespace OpenTween
             }
         }
 
-        public string StartsWith
-        {
-            get
-            {
-                return _StartsWith;
-            }
-            set
-            {
-                _StartsWith = value;
-            }
-        }
-
         private void AtIdSupplement_FormClosed(object sender, FormClosedEventArgs e) /*Handles MyBase.FormClosed*/
         {
-            _StartsWith = "";
+            this.StartsWith = "";
             if (isBack)
             {
                 this.DialogResult = DialogResult.Cancel;