OSDN Git Service

no message
authorwagashi <wagashi@users.sourceforge.jp>
Mon, 1 Nov 2010 08:50:15 +0000 (17:50 +0900)
committerwagashi <wagashi@users.sourceforge.jp>
Mon, 1 Nov 2010 08:50:15 +0000 (17:50 +0900)
components/AutoCompleteTextBox.cs
components/SearchTextBox.Designer.cs
components/SearchTextBox.cs
passer/MainForm.cs
passer/MainFormEvent.cs
passer/Program.cs

index 5ff5739..c90ee30 100644 (file)
@@ -318,5 +318,6 @@ namespace Lugens.Components
         {
             this.SetDropdownFormLocation();
         }
+
     }
 }
\ No newline at end of file
index 3722e7b..2aabe66 100644 (file)
@@ -29,6 +29,7 @@
         private void InitializeComponent()
         {
             this.icon = new System.Windows.Forms.PictureBox();
+            this.label = new System.Windows.Forms.Label();
             this.textBox = new Lugens.Components.AutoCompleteTextBox();
             ((System.ComponentModel.ISupportInitialize)(this.icon)).BeginInit();
             this.SuspendLayout();
             this.icon.TabIndex = 1;
             this.icon.TabStop = false;
             // 
+            // label
+            // 
+            this.label.AutoSize = true;
+            this.label.Cursor = System.Windows.Forms.Cursors.IBeam;
+            this.label.Enabled = false;
+            this.label.Location = new System.Drawing.Point(26, 6);
+            this.label.Name = "label";
+            this.label.Size = new System.Drawing.Size(35, 12);
+            this.label.TabIndex = 2;
+            this.label.Text = "label1";
+            // 
             // textBox
             // 
             this.textBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
             this.textBox.ShowableDropdownList = true;
             this.textBox.Size = new System.Drawing.Size(180, 19);
             this.textBox.TabIndex = 0;
+            this.textBox.TextChanged += new System.EventHandler(this.textBox_TextChanged);
             // 
             // SearchTextBox
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.BackColor = System.Drawing.SystemColors.Window;
+            this.Controls.Add(this.label);
             this.Controls.Add(this.icon);
             this.Controls.Add(this.textBox);
             this.Name = "SearchTextBox";
@@ -75,5 +89,6 @@
 
         private AutoCompleteTextBox textBox;
         private System.Windows.Forms.PictureBox icon;
+        private System.Windows.Forms.Label label;
     }
 }
index c1a59a1..dd1df73 100644 (file)
@@ -22,13 +22,19 @@ namespace Lugens.Components
         [Description("背景色です。")]
         public Color FillBackColor { get { return fillBackColor; } set { fillBackColor = value; } }
 
+        [Category("表示")]
+        [Description("ラベルのテキストです。")]
+        public string LabelText { get { return this.label.Text; } set { this.label.Text = value; } }
+
+        [Category("表示")]
+        [Description("ラベルのフォントです。")]
+        public Font LabelFont { get { return this.label.Font; } set { this.label.Font = value; } }
+
         public AutoCompleteTextBox TextBox { get { return textBox; } }
 
         public PictureBox Icon { get { return this.icon; } }
 
         
-
-
         public SearchTextBox()
         {
             InitializeComponent();
@@ -73,5 +79,10 @@ namespace Lugens.Components
             this.textBox.Width = this.Width - 25;
             this.Invalidate();
         }
+
+        private void textBox_TextChanged(object sender, EventArgs e)
+        {
+            this.label.Visible = String.IsNullOrEmpty(this.textBox.Text);
+        }
     }
 }
index 2a2a348..30b8984 100644 (file)
@@ -86,6 +86,11 @@ namespace Lugens.Passer
         public SearchTextBox SearchTextBox { get { return searchTextBox; } }
 
         /// <summary>
+        /// 現在選択中の検索エンジン
+        /// </summary>
+        private string SelectedEngine;
+
+        /// <summary>
         /// ツールチップ表示用
         /// </summary>
         private string dropdownListBoxText = "";
@@ -100,6 +105,9 @@ namespace Lugens.Passer
             //
             // TODO: InitializeComponent 呼び出しの後に、コンストラクタ コードを追加してください。
             //
+            //this.searchTextBox.TextBox.BackTextColor = System.Drawing.SystemColors.Control;
+            //this.searchTextBox.TextBox.BackTextFont = this.searchTextBox.TextBox.Font;
+            //this.searchTextBox.TextBox.BackText = "コマンドを入力してください";
             this.searchTextBox.TextBox.Complement += new Lugens.Components.AutoCompleteTextBox.ComplementEventHandler(this.textBox_cmd_Complement);
             this.searchTextBox.TextBox.TextChanged += new System.EventHandler(this.textBox_cmd_TextChanged);
             this.searchTextBox.TextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox_cmd_KeyDown);
@@ -271,6 +279,8 @@ namespace Lugens.Passer
             // 
             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);
@@ -509,6 +519,19 @@ namespace Lugens.Passer
             return ret;
         }
 
+        
+        /// <summary>
+        /// 検索エンジンを変更
+        /// </summary>
+        /// <param name="info"></param>
+        public void SetSearchEngine(EngineInfo info)
+        {
+            this.SelectedEngine = info.Name;
+            this.SearchTextBox.LabelText = info.Display;
+            this.SearchTextBox.Icon.Image = info.Icon;
+            this.SearchTextBox.Invalidate();
+        }
+
 
         protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
         {
@@ -596,6 +619,7 @@ namespace Lugens.Passer
                 this.searchTextBox.TextBox.Text = "";
                 this.searchTextBox.TextBox.ShowableDropdownList = false;
                 this.searchTextBox.TextBox.DropdownForm.DoVisibleChange(false);
+                this.SetSearchEngine(Program.HotKeyEngineDic[4176]);
                 this.timer1.Stop();
             }
         }
index cc806da..8bbf158 100644 (file)
@@ -162,7 +162,6 @@ namespace Lugens.Passer
                 command = commands[commands.Length - 1];
 
             this.searchTextBox.TextBox.DropdownForm.DropdownListBox.Items.Clear();
-            //this.searchTextBox.a
             if (filter && command.Equals(""))
             {
                 this.searchTextBox.TextBox.DropdownForm.DoVisibleChange(false);
@@ -360,8 +359,7 @@ namespace Lugens.Passer
             if (Program.HotKeyEngineDic.ContainsKey(KeyboardHook.Keycode))
             {
                 EngineInfo info = Program.HotKeyEngineDic[KeyboardHook.Keycode];
-                searchTextBox.Icon.Image = info.Icon;
-                searchTextBox.Invalidate();
+                this.SetSearchEngine(info);
                 e.Handled = true;
                 return;
             }
@@ -447,22 +445,28 @@ namespace Lugens.Passer
                     break;
 
                 case Keys.Down:
-                    if (!this.SearchTextBox.TextBox.DropdownForm.Visible)
+                    if ((Keys.Control & Control.ModifierKeys) == Keys.Control)
+                    {
+                    }
+                    else
                     {
-                        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);
+                            }
                         }
                     }
                     break;
index c34dc5c..8e6a2a0 100644 (file)
@@ -1169,6 +1169,11 @@ namespace Lugens.Passer
             }
         }
 
+        
+        /// <summary>
+        /// 検索エンジンリスト読み込み
+        /// </summary>
+        /// <returns></returns>
         public static bool ReadEngineList()
         {
             string file = null;
@@ -1193,6 +1198,15 @@ namespace Lugens.Passer
             Program.EngineList.Clear();
             Program.HotKeyEngineDic.Clear();
 
+            //デフォルトのエンジンを追加
+            info.Name = "Passer";
+            info.Type = 0;
+            info.Shortcut = 4176; //RControl + P
+            info.Icon = Properties.Resources.engine_command;
+            info.Display = "コマンドを入力してください";
+            Program.EngineList.Add(info.Name);
+            Program.HotKeyEngineDic.Add(info.Shortcut, info);
+
             try
             {
                 using (reader = new XmlTextReader(file))
@@ -1221,7 +1235,11 @@ namespace Lugens.Passer
                             if (reader.LocalName.Equals("Icon"))
                             {
                                 reader.Read();
-                                info.Icon = Image.FromFile(reader.Value);
+                                try
+                                {
+                                    info.Icon = Image.FromFile(reader.Value);
+                                }
+                                catch{}
                                 continue;
                             }
                             if (reader.LocalName.Equals("Display"))
@@ -1245,6 +1263,7 @@ namespace Lugens.Passer
                         }
                        else if (reader.LocalName.Equals("Engine"))
                         {
+                            info.Type = 2;
                             Program.EngineList.Add(info.Name);
                             Program.HotKeyEngineDic.Add(info.Shortcut, info);
                         }
@@ -1744,6 +1763,11 @@ namespace Lugens.Passer
         public string Name;
 
         /// <summary>
+        /// タイプ(0.COMMAND 1.LOCAL_SEARCH 2.WEB_SEARCH)
+        /// </summary>
+        public int Type;
+
+        /// <summary>
         /// URL
         /// </summary>
         public string Url;
@@ -1768,10 +1792,6 @@ namespace Lugens.Passer
         /// </summary>
         public string Comment;
 
-        /// <summary>
-        /// アイコン
-        /// </summary>
-        public Icon ApplicationIcon;
     }
 
     public class KeyRecordInfo