예제 #1
0
 private void bAssociate_Click(object sender, EventArgs e)
 {
     FileAssociation.Associate(true);
 }
예제 #2
0
        public static void Load()
        {
            Program.printLog("   Load configuration setting.");

            if (!Directory.Exists(scriptTempPath))
            {
                Directory.CreateDirectory(scriptTempPath);
            }
            else
            {
                foreach (string file in Directory.GetFiles(scriptTempPath))
                {
                    File.Delete(file);
                }
            }
            File.Delete("errors.txt");

            if (!Directory.Exists(SettingsFolder))
            {
                Directory.CreateDirectory(SettingsFolder);
            }
            if (!Directory.Exists(ResourcesFolder))
            {
                Directory.CreateDirectory(ResourcesFolder);
            }
            var templatesFolder = Path.Combine(ResourcesFolder, "templates");

            if (!Directory.Exists(templatesFolder))
            {
                Directory.CreateDirectory(templatesFolder);
            }

            BinaryReader brRecent = null, brSettings = null;

            if (File.Exists(RecentPath))
            {
                brRecent = new BinaryReader(File.OpenRead(RecentPath));
            }
            if (File.Exists(SettingsPath))
            {
                brSettings = new BinaryReader(File.OpenRead(SettingsPath));
            }
            LoadInternal(brSettings, brRecent);

            LoadScriptsProceduresFolding();

            if (!File.Exists(SearchHistoryPath))
            {
                File.Create(SearchHistoryPath).Close();
            }
            if (!File.Exists(PreprocDefPath))
            {
                File.Create(PreprocDefPath).Close();
            }

            if (!firstRun)
            {
                var culture = System.Globalization.CultureInfo.CurrentCulture;
                Settings.hintsLang = (byte)((culture.ToString() == "ru-RU") ? 1 : 0);
                FileAssociation.Associate();
            }

            EncCodePage = (encoding == (byte)EncodingType.OEM866) ? Encoding.GetEncoding("cp866") : Encoding.Default;

            //Load custom fonts
            try {
                foreach (string file in Directory.GetFiles(Settings.ResourcesFolder + @"\fonts\", "*.ttf"))
                {
                    Fonts.AddFontFile(file);
                }
            } catch (DirectoryNotFoundException) { }
        }