예제 #1
0
 private void menuEditConfig_Click(object sender, EventArgs e)
 {
     Form showEditConfig = new editConfig();
     showEditConfig.Show();
 }
예제 #2
0
        public static void getConfigData()
        {
            string DataPath = Path.GetFullPath(Directory.GetCurrentDirectory()) + "\\data\\";
            string FilePath = DataPath + "Config.dat";
            string EncryptKey = Properties.Settings.Default.GUID;

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

            if (File.Exists(FilePath))
            {
                ConfigEncryptor ConfigEncrypt = new ConfigEncryptor();
                EncryptKey = Properties.Settings.Default.GUID;

                try
                {
                    ConfigEncrypt.DecryptConfig(FilePath, DataPath, EncryptKey);
                }
                catch
                {
                    MessageBox.Show("Config has become corrupt. Loading default values. Please update values again.");
                    corruptConfig = true;
                }

                if (corruptConfig)
                    goto Advance;

                StreamReader reader = new StreamReader(FilePath);
                ConfigEditor.ConfigEditor config = new ConfigEditor.ConfigEditor(reader);
                reader.Close();

                ConfigEncrypt.EncryptConfig(FilePath, DataPath, EncryptKey);

                ConfigProperties.timerInterval = (string)config.GetValue("TimerInterval");

                if ((string)config.GetValue("MangosHosted") == "1")
                {
                    ConfigProperties.mangosHosted = true;
                }
                else
                {
                    ConfigProperties.mangosHosted = false;
                }

                if ((string)config.GetValue("RealmHosted") == "1")
                {
                    ConfigProperties.realmHosted = true;
                }
                else
                {
                    ConfigProperties.realmHosted = false;
                }

                ConfigProperties.mangosAppName = (string)config.GetValue("MangosAppName");
                ConfigProperties.mangosAppPath = (string)config.GetValue("MangosAppPath");
                ConfigProperties.realmAppName = (string)config.GetValue("RealmAppName");
                ConfigProperties.realmAppPath = (string)config.GetValue("RealmAppPath");
                ConfigProperties.dbHost = (string)config.GetValue("DbHost");
                ConfigProperties.dbPort = (string)config.GetValue("DbPort");
                ConfigProperties.dbUser = (string)config.GetValue("DbUser");
                ConfigProperties.dbPassword = (string)config.GetValue("DbPassword");
                ConfigProperties.mangosDatabaseName = (string)config.GetValue("MangosDatabaseName");
                ConfigProperties.realmDatabaseName = (string)config.GetValue("RealmDatabaseName");
                ConfigProperties.charDatabaseName = (string)config.GetValue("CharDatabaseName");
                ConfigProperties.mangosMOTD = (string)config.GetValue("MangosMOTD");
                goto Finish;

            Advance:
                ConfigProperties.timerInterval = "10000";
                ConfigProperties.mangosHosted = true;
                ConfigProperties.realmHosted = true;
                ConfigProperties.mangosAppName = "mangosd";
                ConfigProperties.mangosAppPath = "C:\\mangos\\";
                ConfigProperties.realmAppName = "realmd";
                ConfigProperties.realmAppPath = "C:\\mangos\\";
                ConfigProperties.dbHost = "localhost";
                ConfigProperties.dbPort = "3306";
                ConfigProperties.dbUser = "******";
                ConfigProperties.dbPassword = "******";
                ConfigProperties.mangosDatabaseName = "mangos";
                ConfigProperties.realmDatabaseName = "realm";
                ConfigProperties.charDatabaseName = "characters";
                ConfigProperties.mangosMOTD = "Welcome to MaNGOS";
                editConfig showEditConfig = new editConfig();
                showEditConfig.Show();

            Finish: ;
            }
            else
            {
                ConfigProperties.timerInterval = "10000";
                ConfigProperties.mangosHosted = true;
                ConfigProperties.realmHosted = true;
                ConfigProperties.mangosAppName = "mangosd";
                ConfigProperties.mangosAppPath = "C:\\mangos\\";
                ConfigProperties.realmAppName = "realmd";
                ConfigProperties.realmAppPath = "C:\\mangos\\";
                ConfigProperties.dbHost = "localhost";
                ConfigProperties.dbPort = "3306";
                ConfigProperties.dbUser = "******";
                ConfigProperties.dbPassword = "******";
                ConfigProperties.mangosDatabaseName = "mangos";
                ConfigProperties.realmDatabaseName = "realm";
                ConfigProperties.charDatabaseName = "characters";
                ConfigProperties.mangosMOTD = "Welcome to MaNGOS";

                MessageBox.Show(string.Format(Resources.hcStringResources.Global_DataAccess_Config_NotSavedAnyConfigValues ));
                editConfig showEditConfig = new editConfig();
                showEditConfig.Show();
            }
        }