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 Egtra (@egtra) <http://dev.activebasic.com/egtra/>
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 AtIdSupplement : OTBaseForm
40 public string inputText = "";
41 public bool isBack = false;
42 private string startChar = "";
43 // private bool tabkeyFix = false;
45 private string _StartsWith = "";
47 public void AddItem(string id)
49 if (!this.TextId.AutoCompleteCustomSource.Contains(id))
51 this.TextId.AutoCompleteCustomSource.Add(id);
55 public void AddRangeItem(string[] ids)
57 foreach (var id in ids)
63 public List<string> GetItemList()
65 var ids = new List<string>();
66 for (int i = 0; i < this.TextId.AutoCompleteCustomSource.Count; ++i)
68 ids.Add(this.TextId.AutoCompleteCustomSource[i]);
77 return this.TextId.AutoCompleteCustomSource.Count;
81 private void ButtonOK_Click(object sender, EventArgs e) /*Handles ButtonOK.Click*/
83 inputText = this.TextId.Text;
87 private void ButtonCancel_Click(object sender, EventArgs e) /*Handles ButtonCancel.Click*/
93 private void TextId_KeyDown(object sender, KeyEventArgs e) /*Handles TextId.KeyDown*/
95 if (e.KeyCode == Keys.Back && string.IsNullOrEmpty(this.TextId.Text))
101 else if (e.KeyCode == Keys.Space || e.KeyCode == Keys.Tab)
103 inputText = this.TextId.Text + " ";
107 else if (e.Control && e.KeyCode == Keys.Delete)
109 if (!string.IsNullOrEmpty(this.TextId.Text))
111 var idx = this.TextId.AutoCompleteCustomSource.IndexOf(this.TextId.Text);
114 this.TextId.Text = "";
115 this.TextId.AutoCompleteCustomSource.RemoveAt(idx);
121 private void AtIdSupplement_Load(object sender, EventArgs e) /*Handles this.Load*/
123 if (startChar == "#")
125 this.ClientSize = new Size(this.TextId.Width, this.TextId.Height); //プロパティで切り替えできるように
126 this.TextId.ImeMode = ImeMode.Inherit;
130 private void AtIdSupplement_Shown(object sender, EventArgs e) /*Handles this.Shown*/
132 TextId.Text = startChar;
133 if (!string.IsNullOrEmpty(_StartsWith))
135 TextId.Text += _StartsWith.Substring(0, _StartsWith.Length);
137 TextId.SelectionStart = TextId.Text.Length;
141 public AtIdSupplement()
143 InitializeComponent();
146 public AtIdSupplement(List<string> ItemList, string startCharacter)
148 InitializeComponent();
150 for (int i = 0; i < ItemList.Count; ++i)
152 this.TextId.AutoCompleteCustomSource.Add(ItemList[i]);
154 startChar = startCharacter;
157 private void TextId_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) /*Handles TextId.PreviewKeyDown*/
159 if (e.KeyCode == Keys.Tab)
161 inputText = this.TextId.Text + " ";
167 public string StartsWith
179 private void AtIdSupplement_FormClosed(object sender, FormClosedEventArgs e) /*Handles MyBase.FormClosed*/
184 this.DialogResult = DialogResult.Cancel;
188 this.DialogResult = DialogResult.OK;