set { complemented = value; }
}
+ private string imeText;
+ public string ImeText
+ {
+ get { return imeText; }
+ set { imeText = value; }
+ }
protected override void Dispose(bool disposing)
{
private Timer timer1;
+ public Timer timer_keyRecoding;
+
+ private Timer timer_suggest;
+
private int scrollPos = 0;
private bool showDropdownSupport = true;
private KeyboardHook keyboardHook;
//private MouseHook mouseHook;
private ToolStripMenuItem 表示ToolStripMenuItem;
- public Timer timer_keyRecoding;
private SearchTextBox searchTextBox;
public SearchTextBox SearchTextBox { get { return searchTextBox; } }
/// 検索エンジンサジェスト用
/// </summary>
private string suggestString = "";
+
+ /// <summary>
+ /// サジェストクエリー判定用
+ /// </summary>
+ private volatile bool textChanged = false;
+
+ private long latestKeyTime = DateTime.Now.Ticks;
public MainForm()
{
this.終了ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
this.timer_keyRecoding = new System.Windows.Forms.Timer(this.components);
- this.textBox_cmd = new Lugens.Components.AutoCompleteTextBox();
+ this.timer_suggest = new System.Windows.Forms.Timer(this.components);
this.searchTextBox = new Lugens.Components.SearchTextBox();
+ this.textBox_cmd = new Lugens.Components.AutoCompleteTextBox();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
this.timer_keyRecoding.Interval = 500;
this.timer_keyRecoding.Tick += new System.EventHandler(this.timer_keyRecoding_Tick);
//
+ // timer_suggest
+ //
+ this.timer_suggest.Enabled = true;
+ this.timer_suggest.Tick += new System.EventHandler(this.timer_suggest_Tick);
+ //
+ // searchTextBox
+ //
+ this.searchTextBox.BackColor = System.Drawing.Color.Transparent;
+ this.searchTextBox.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(127)))), ((int)(((byte)(157)))), ((int)(((byte)(185)))));
+ this.searchTextBox.FillBackColor = System.Drawing.Color.White;
+ this.searchTextBox.ForeColor = System.Drawing.SystemColors.WindowText;
+ this.searchTextBox.LabelFont = new System.Drawing.Font("MS UI Gothic", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
+ this.searchTextBox.LabelText = "label1";
+ this.searchTextBox.Location = new System.Drawing.Point(9, 4);
+ this.searchTextBox.Name = "searchTextBox";
+ this.searchTextBox.Size = new System.Drawing.Size(205, 25);
+ this.searchTextBox.TabIndex = 2;
+ //
// textBox_cmd
//
this.textBox_cmd.BackColor = System.Drawing.SystemColors.Window;
this.textBox_cmd.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox_cmd_KeyDown);
this.textBox_cmd.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);
//
- // searchTextBox
- //
- this.searchTextBox.BackColor = System.Drawing.Color.Transparent;
- this.searchTextBox.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(127)))), ((int)(((byte)(157)))), ((int)(((byte)(185)))));
- this.searchTextBox.FillBackColor = System.Drawing.Color.White;
- this.searchTextBox.ForeColor = System.Drawing.SystemColors.WindowText;
- this.searchTextBox.Location = new System.Drawing.Point(9, 4);
- this.searchTextBox.Name = "searchTextBox";
- this.searchTextBox.Size = new System.Drawing.Size(205, 25);
- this.searchTextBox.TabIndex = 2;
- //
// MainForm
//
this.AllowDrop = true;
this.SearchTextBox.LabelText = info.Display;
this.SearchTextBox.Icon.Image = info.IconImage;
this.SearchTextBox.Invalidate();
+ switch (this.SelectedEngineType)
+ {
+ case 0:
+ Program.CommandHistoryIndex = 0;
+ break;
+ }
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
<metadata name="timer_keyRecoding.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>275, 17</value>
</metadata>
+ <metadata name="timer_suggest.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>550, 17</value>
+ </metadata>
</root>
\ No newline at end of file
using System.Text;
using System.Windows.Forms;
using System.Net;
+using System.Web;
using Lugens.Components;
using Lugens.Utils;
using System.Runtime.InteropServices;
this.suggestString = "";
}
else
- this.SetEngineDropdownList(this.searchTextBox.TextBox.Text);
+ {
+ this.textChanged = true;
+ }
break;
}
}
return;
- string url = info.SuggestUrl.Replace("%s", Uri.EscapeUriString(text));
- WebRequest webReq = HttpWebRequest.Create(url);
- webReq.Method = "GET";
- webReq.ContentType = "application/x-www-form-urlencoded";
+ string url = info.SuggestUrl.Replace("%s", Uri.EscapeDataString(text));
+ HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
+ req.Method = "GET";
+ req.UserAgent = "Passer 2.6.0.0b";
+ //webReq.ContentType = "application/x-www-form-urlencoded";
AsyncCallback readCallBack = new AsyncCallback(SuggestReadCallBack);
- webReq.BeginGetResponse(readCallBack, webReq);
+ req.BeginGetResponse(readCallBack, req);
this.suggestString = text;
}
{
HttpWebRequest req = (HttpWebRequest)ar.AsyncState;
HttpWebResponse response = (HttpWebResponse)req.EndGetResponse(ar);
- StreamReader streamReader = new StreamReader(response.GetResponseStream());
+ StreamReader streamReader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(response.CharacterSet));
string str = streamReader.ReadToEnd();
streamReader.Close();
List<string> list = new List<string>();
catch (Exception ex)
{
Debug.WriteLine("error:" + ex);
- }
- }
+ string s = ex.ToString();
+ s += "hoge";
+ }
+ }
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
}
else
{
- if (!this.SearchTextBox.TextBox.DropdownForm.Visible)
+ if (this.SelectedEngineType == 0)
{
- if (Program.CommandHistoryList.Count > 0)
+ if (!this.SearchTextBox.TextBox.DropdownForm.Visible)
{
- if (Program.CommandHistoryList.Count > Program.CommandHistoryIndex)
- Program.CommandHistoryIndex++;
- this.showDropdownSupport = false;
- this.SearchTextBox.TextBox.Text = Program.CommandHistoryList[Program.CommandHistoryIndex - 1];
- this.SearchTextBox.TextBox.SelectionStart = this.SearchTextBox.TextBox.Text.Length;
- this.showDropdownSupport = true;
+ if (Program.CommandHistoryList.Count > 0)
+ {
+ if (Program.CommandHistoryList.Count > Program.CommandHistoryIndex)
+ Program.CommandHistoryIndex++;
+ this.showDropdownSupport = false;
+ this.SearchTextBox.TextBox.Text = Program.CommandHistoryList[Program.CommandHistoryIndex - 1];
+ this.SearchTextBox.TextBox.SelectionStart = this.SearchTextBox.TextBox.Text.Length;
+ this.showDropdownSupport = true;
+ }
}
}
}
}
else
{
- if (!this.SearchTextBox.TextBox.DropdownForm.Visible)
+ if (this.SelectedEngineType == 0)
{
- if (Program.CommandHistoryIndex > 0)
+ if (!this.SearchTextBox.TextBox.DropdownForm.Visible)
{
- Program.CommandHistoryIndex--;
- this.showDropdownSupport = false;
- if (Program.CommandHistoryIndex == 0)
- this.SearchTextBox.TextBox.Text = "";
+ if (Program.CommandHistoryIndex > 0)
+ {
+ Program.CommandHistoryIndex--;
+ this.showDropdownSupport = false;
+ if (Program.CommandHistoryIndex == 0)
+ this.SearchTextBox.TextBox.Text = "";
+ else
+ this.SearchTextBox.TextBox.Text = Program.CommandHistoryList[Program.CommandHistoryIndex - 1];
+ this.SearchTextBox.TextBox.SelectionStart = this.SearchTextBox.TextBox.Text.Length;
+ this.showDropdownSupport = true;
+ }
else
- this.SearchTextBox.TextBox.Text = Program.CommandHistoryList[Program.CommandHistoryIndex - 1];
- this.SearchTextBox.TextBox.SelectionStart = this.SearchTextBox.TextBox.Text.Length;
- this.showDropdownSupport = true;
- }
- else
- {
- this.ShowDropdownForm(false);
+ {
+ this.ShowDropdownForm(false);
+ }
}
}
}
private void textBox_cmd_TextChanged(object sender, EventArgs e)
{
+ this.latestKeyTime = DateTime.Now.Ticks;
+ this.searchTextBox.TextBox.ImeText = this.searchTextBox.TextBox.Text;
if (!this.showDropdownSupport)
return;
+ text
+ str.Substring(this.searchTextBox.TextBox.SelectionStart);
}
-
- Debug.WriteLine("str:" + text);
+ this.searchTextBox.TextBox.ImeText = text;
Debug.WriteLine("ImeComposition:(" + type + ") " + suggestString + "," + text);
if (String.IsNullOrEmpty(text))
}
else
{
- if((type & Win32.GCS_RESULTSTR) != Win32.GCS_RESULTSTR)
- this.SetEngineDropdownList(text);
+ if ((type & Win32.GCS_RESULTSTR) != Win32.GCS_RESULTSTR)
+ {
+ this.latestKeyTime = DateTime.Now.Ticks;
+ this.textChanged = true;
+ //this.SetEngineDropdownList(text);
+ }
}
}
Win32.PostMessage(Program.BallonWindowHandle, Win32.WM_MOUSEMOVE, (IntPtr)0, (IntPtr)0);
}
+ private void timer_suggest_Tick(object sender, EventArgs e)
+ {
+ if (this.SelectedEngineType == 2 && this.textChanged)
+ {
+ string text = this.searchTextBox.TextBox.ImeText;
+ if (DateTime.Now.Ticks > this.latestKeyTime + 000000 && !this.suggestString.Equals(text))
+ {
+ this.textChanged = false;
+ this.SetEngineDropdownList(text);
+ }
+ }
+ }
+
private void toolTip_Popup(object sender, PopupEventArgs e)
{
foreach (string key in Program.EngineList)
{
this.engineListTmp.Add(key);
- this.engineDicTmp.Add(key, Program.EngineDic[key]);
+ EngineInfo info = new EngineInfo();
+ info.Id = Program.EngineDic[key].Id;
+ info.Name = Program.EngineDic[key].Name;
+ info.Shortcut = Program.EngineDic[key].Shortcut;
+ info.Url = Program.EngineDic[key].Url;
+ info.SuggestUrl = Program.EngineDic[key].SuggestUrl;
+ info.Type = Program.EngineDic[key].Type;
+ info.IconImage = Program.EngineDic[key].IconImage;
+ info.IconChanged = false;
+ info.Removed = false;
+ this.engineDicTmp.Add(key, info);
IconListBoxItem item = new IconListBoxItem();
item.Name = key;
item.Text = key;
{
string key = this.engine_iconListBox.Text;
int index = this.engineListTmp.IndexOf(key);
+ int selectedIndex = this.engine_iconListBox.SelectedIndex;
this.engineListTmp[index] = "@" + this.engine_iconListBox.Text;
EngineInfo info = this.engineDicTmp[key];
this.EngineDicTmp.Add(info.Name, info);
Program.SettingForm.ReadEngineList(true);
- if (this.engine_iconListBox.Items.Count > index)
- this.engine_iconListBox.SelectedIndex = index;
+ if (this.engine_iconListBox.Items.Count > selectedIndex)
+ this.engine_iconListBox.SelectedIndex = selectedIndex;
else if (this.engine_iconListBox.Items.Count > 0)
this.engine_iconListBox.SelectedIndex = this.engine_iconListBox.Items.Count - 1;
else