OSDN Git Service

no message
authorwagashi <wagashi@users.sourceforge.jp>
Sun, 14 Nov 2010 17:06:05 +0000 (02:06 +0900)
committerwagashi <wagashi@users.sourceforge.jp>
Sun, 14 Nov 2010 17:06:05 +0000 (02:06 +0900)
passer/AddEngineForm.cs
passer/Program.cs
passer/ProgramEngine.cs
passer/SettingForm.cs

index 6c88a19..c8110e9 100644 (file)
@@ -79,14 +79,26 @@ namespace Lugens.Passer
             info.Display = this.textBox_display.Text;
             info.IconChanged = this.iconChanged;
 
-            foreach (string key in Program.SettingForm.EngineListTmp)
+            if (Program.SettingForm.EngineListTmp.Contains(this.textBox_name.Text) && !Program.SettingForm.EngineDicTmp[this.textBox_name.Text].Removed)
             {
-                if(info.Name.Equals(key))
-                {
-                    //重複エラー
-                }
+                //重複エラー
+                MessageBox.Show("すでに登録されている名前です");
+                return;
+            }
+
+            if (String.IsNullOrEmpty(info.Url))
+            {
+                MessageBox.Show("URLを入力してください", "入力エラー", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                return;
+            }
+
+            if (!info.Url.StartsWith("http://") && !info.Url.StartsWith("https://"))
+            {
+                MessageBox.Show("URLを正しく入力してください", "入力エラー", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                return;
             }
 
+
             if (this.iconChanged)
             {
                 if (!Directory.Exists(Program.EngineIconTmpDir))
@@ -133,8 +145,17 @@ namespace Lugens.Passer
 
         private void textBox_name_TextChanged(object sender, EventArgs e)
         {
-            if (Program.SettingForm.EngineListTmp.Contains(this.textBox_name.Text))
+            if (this.textBox_name.Text[0] == '@')
+            {
+                this.label_engine_duplicate.Text = "※先頭に@は使用できません";
+                this.label_engine_duplicate.Visible = true;
+                this.button_ok.Enabled = false;
+                return;
+            }
+
+            if (Program.SettingForm.EngineListTmp.Contains(this.textBox_name.Text) && !Program.SettingForm.EngineDicTmp[this.textBox_name.Text].Removed)
             {
+                this.label_engine_duplicate.Text = "※重複しています";
                 this.label_engine_duplicate.Visible = true;
                 this.button_ok.Enabled = false;
             }
index 4322072..5dd37a4 100644 (file)
@@ -1155,9 +1155,7 @@ namespace Lugens.Passer
                 return false;
             }
         }
-
-        
-
+            
 
         public static void WriteCommandList()
         {
index 9cb98a0..912eb6c 100644 (file)
@@ -288,7 +288,8 @@ namespace Lugens.Passer
 
                             Program.EngineList.Add(info.Name);
                             Program.EngineDic.Add(info.Name, info);
-                            Program.HotKeyEngineDic.Add(info.Shortcut, info);
+                            if(info.Shortcut > 0)
+                                Program.HotKeyEngineDic.Add(info.Shortcut, info);
                         }
                     }
                 }
@@ -326,6 +327,8 @@ namespace Lugens.Passer
                         string file = Program.EngineIconDir + "\\" + info.Id;
                         if (File.Exists(file))
                             File.Delete(file);
+
+                        Program.EngineDic.Remove(key);
                         continue;
                     }
                     writer.WriteStartElement("Engine");
index 2d9fb37..3e9a42e 100644 (file)
@@ -290,6 +290,8 @@ namespace Lugens.Passer
         /// </summary>
         public void ReadEngineList()
         {
+            Program.SettingForm.ReadEngineList(false);
+            /*
             this.engineListTmp.Clear();
             this.engineDicTmp.Clear();
             this.engine_iconListBox.Items.Clear();
@@ -306,7 +308,7 @@ namespace Lugens.Passer
                 item.Regex = Program.Ime.GetRomaji(key);
                 this.engine_iconListBox.Items.Add(item);
             }
-
+            */
         }
 
         /// <summary>
@@ -380,6 +382,9 @@ namespace Lugens.Passer
                 this.engine_iconListBox.Items.Clear();
                 foreach (string key in this.engineListTmp)
                 {
+                    if (this.EngineDicTmp[key].Removed)
+                        continue;
+
                     IconListBoxItem item = new IconListBoxItem();
                     item.Name = key;
                     item.Text = key;
@@ -1331,6 +1336,7 @@ namespace Lugens.Passer
             IconListBoxItem item = (IconListBoxItem)this.engine_iconListBox.Items[srcIndex];
 
             this.engine_iconListBox.Items.RemoveAt(srcIndex);
+            this.engineListTmp.RemoveAt(srcIndex);
             if (destIndex > srcIndex)
                 destIndex--;
             this.engine_iconListBox.Items.Insert(destIndex, item);
@@ -1405,9 +1411,15 @@ namespace Lugens.Passer
 
         private void engine_button_delete_Click(object sender, EventArgs e)
         {
-            int index = this.engine_iconListBox.SelectedIndex;
-            this.engineDicTmp[this.engineListTmp[index]].Removed = true;
-            this.engineListTmp.RemoveAt(index);
+            string key = this.engine_iconListBox.Text;
+            int index = this.engineListTmp.IndexOf(key);
+            this.engineListTmp[index] = "@" + this.engine_iconListBox.Text;
+
+            EngineInfo info = this.engineDicTmp[key];
+            info.Name = "@" + this.engine_iconListBox.Text;
+            info.Removed = true;
+            this.engineDicTmp.Remove(key);
+            this.EngineDicTmp.Add(info.Name, info);
 
             Program.SettingForm.ReadEngineList(true);
             if (this.engine_iconListBox.Items.Count > index)