示例#1
0
        /// <summary>
        /// Checks the dic dir.
        /// </summary>
        /// <remarks>Documented by Dev02, 2008-05-20</remarks>
        public static void CheckDicDir()
        {
            IConnectionString cs = ConnectionStringHandler.GetDefaultConnectionString(Setup.UserConfigPath);

            string dicDir = Settings.Default.DicDir;

            if (cs == null)
            {
                Regex regexAppData = new Regex(@"\%appdata\%", RegexOptions.IgnoreCase);
                if (regexAppData.Match(dicDir).Success)
                {
                    dicDir = regexAppData.Replace(dicDir, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
                }
            }

            // check for value of dictionary directory
            FolderBrowserDialog DirDialog = new FolderBrowserDialog();

            while (string.IsNullOrEmpty(dicDir) || !Directory.Exists(dicDir) || !Path.IsPathRooted(dicDir))
            {
                MessageBox.Show(Resources.PERSONAL_FOLDER_TEXT, Resources.PERSONAL_FOLDER_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (DirDialog.ShowDialog() == DialogResult.OK)
                {
                    dicDir = DirDialog.SelectedPath;
                }
            }

            if (dicDir != Settings.Default.DicDir || ConnectionStringHandler.GetDefaultConnectionString(Setup.UserConfigPath) == null)
            {
                Setup.CreateDefaultConfig(dicDir);
            }
        }
示例#2
0
        /// <summary>
        /// Creates the default config.
        /// </summary>
        /// <param name="defaultLerningModulesPath">The default lerning modules path.</param>
        /// <remarks>Documented by Dev03, 2009-05-07</remarks>
        public static void CreateDefaultConfig(string defaultLerningModulesPath)
        {
            if (Directory.Exists(defaultLerningModulesPath))
            {
                Settings.Default.DicDir = defaultLerningModulesPath;
                Settings.Default.Save();

                string configPath = Setup.UserConfigPath;

                //Get the only connection from
                IConnectionString defaultConnection = ConnectionStringHandler.GetDefaultConnectionString(configPath);
                if (defaultConnection as UncConnectionStringBuilder == null)
                {
                    ConnectionStringHandler.CreateUncConnection(Resources.DEFAULT_CONNECTION_NAME, defaultLerningModulesPath, configPath, Resources.DEFAULT_CONNECTION_FILE, true, Setup.IsPathOnStick(defaultLerningModulesPath));
                }
                else
                {
                    UncConnectionStringBuilder builder = new UncConnectionStringBuilder(defaultLerningModulesPath, true, Setup.IsPathOnStick(defaultLerningModulesPath));
                    builder.Name = defaultConnection.Name;

                    ConnectionStringHandler.CreateUncConnection(builder, Path.GetDirectoryName(defaultConnection.ConfigFileName), Path.GetFileName(defaultConnection.ConfigFileName));
                }
            }
        }