private void TextBox_LuaPath_LostFocus(object sender, RoutedEventArgs e)
        {
            string path = TextBox_LuaPath.Text.Trim();

            if (!Directory.Exists(path))
            {
                System.Windows.MessageBox.Show(Properties.Resources.InvalidLuaPath);
                TextBox_LuaPath.Focus();
                TextBox_LuaPath.SelectAll();
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var name = TextBox_SettingName.Text.Trim();

            if (string.IsNullOrWhiteSpace(name))
            {
                System.Windows.MessageBox.Show(Properties.Resources.LoseSetName);
                TextBox_SettingName.Focus();
                return;
            }
            else if (name.IndexOfAny(Path.GetInvalidFileNameChars()) != -1)
            {
                string strConfirm = string.Format("\"{0}\" is a invalid name, please rename.", name);
                System.Windows.MessageBox.Show(strConfirm, "Error");
                TextBox_SettingName.Focus();
                TextBox_SettingName.SelectAll();
                return;
            }

            var luapath = TextBox_LuaPath.Text.Trim();

            if (string.IsNullOrWhiteSpace(luapath) || !Directory.Exists(luapath))
            {
                System.Windows.MessageBox.Show(Properties.Resources.InvalidLuaPath);
                TextBox_LuaPath.Focus();
                TextBox_LuaPath.SelectAll();
                return;
            }

            if (BabePackage.Setting.ContainsSetting(name))
            {
                string strReplaceConfirm = string.Format("Setting \"{0}\" already exists, replace setting?", name);
                if (System.Windows.MessageBox.Show(strReplaceConfirm, "replace", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
                {
                    return;
                }
                BabePackage.Setting.AddSetting(name, luapath, TextBox_LuaExecutablePath.Text.Trim(), TextBox_WorkingPath.Text.Trim(), TextBox_CommandLine.Text.Trim(), (EncodingName)ComboBox_FileEncoding.SelectedItem);
                BabePackage.Setting.Save();

                //如果保存的是当前选择工程且目录发生变化则重新加载
                if (name == BabePackage.Setting.CurrentSetting && luapath != BabePackage.Setting.GetSetting(name).Folder)
                {
                    IntellisenseHelper.Scan();
                    DTEHelper.Current.UpdateUI();
                }
            }
            else
            {
                BabePackage.Setting.AddSetting(name, luapath, TextBox_LuaExecutablePath.Text.Trim(), TextBox_WorkingPath.Text.Trim(), TextBox_CommandLine.Text.Trim(), (EncodingName)ComboBox_FileEncoding.SelectedItem);
                BabePackage.Setting.Save();
            }

            InitComboBox();

            //当前选择项为空时,则选择保存的项
            if (ComboBox_Settings.SelectedItem == null || string.IsNullOrWhiteSpace(ComboBox_Settings.SelectedItem.ToString()))
            {
                ComboBox_Settings.SelectedItem = name;
            }

            Button_Save.IsEnabled = false;
        }