Пример #1
0
        private void loadPreferences()
        {
            Preferences preferences = new Preferences();

            if (System.IO.File.Exists(preferencesFile))
            {
                foreach (DataTable dataTable in preferences.Tables)
                {
                    dataTable.BeginLoadData();
                }
                preferences.ReadXml(preferencesFile);
                foreach (DataTable dataTable in preferences.Tables)
                {
                    dataTable.EndLoadData();
                }

                //Prüfen ob irgendwelche Datensätze DBNull enthalten, wenn ja, dann preferences Fenster öffnen
                bool checkPreferences = false;
                foreach (DataColumn column in preferences.MySQL.Columns)
                {
                    if (preferences.MySQL.Rows[0].IsNull(column.ColumnName))
                    {
                        checkPreferences = true;
                    }
                    //if (preferences.MySQL.Rows[0][column.ColumnName].GetType().ToString() == System.DBNull.Value.GetType().ToString()) checkPreferences = true;
                }

                foreach (DataColumn column in preferences.Basic.Columns)
                {
                    if (preferences.Basic.Rows[0].IsNull(column.ColumnName))
                    {
                        checkPreferences = true;
                    }
                    //if (preferences.Basic.Rows[0][column.ColumnName].GetType().ToString() == System.DBNull.Value.GetType().ToString()) checkPreferences = true;
                }

                if (checkPreferences == true)
                {
                    MessageBox.Show(Locales.GetString("preferences_new_options"));
                    preferencesToolStripMenuItem_Click(null, null);
                    return;
                }
            }
            else
            {
                Preferences.MySQLRow mysqlRow = preferences.MySQL.NewMySQLRow();
                preferences.MySQL.Rows.Add(mysqlRow);

                Preferences.BasicRow basicRow = preferences.Basic.NewBasicRow();
                preferences.Basic.Rows.Add(basicRow);

                preferences.WriteXml(preferencesFile);
                loadPreferences();
                return;
            }

            this.mysqlRow = (Preferences.MySQLRow)preferences.MySQL.Rows[0];
            this.basicRow = (Preferences.BasicRow)preferences.Basic.Rows[0];
        }
Пример #2
0
        private void loadPreferences()
        {
            if (System.IO.File.Exists(filename))
            {
                foreach (DataTable dataTable in preferences.Tables)
                {
                    dataTable.BeginLoadData();
                }
                preferences.ReadXml(filename);
                foreach (DataTable dataTable in preferences.Tables)
                {
                    dataTable.EndLoadData();
                }
            }
            else
            {
                Preferences.MySQLRow mysqlRow = this.preferences.MySQL.NewMySQLRow();
                preferences.MySQL.Rows.Add(mysqlRow);

                Preferences.BasicRow basicRow = this.preferences.Basic.NewBasicRow();
                preferences.Basic.Rows.Add(basicRow);

                this.preferences.WriteXml(filename);
                loadPreferences();
            }

            //Set default values for new options in MySQLRow
            Preferences.MySQLRow checkingMySQLRow = (Preferences.MySQLRow) this.preferences.MySQL.Rows[0];
            //cellDetection
            if (checkingMySQLRow.IscellDetectionNull())
            {
                if (checkingMySQLRow.Enabled == true)
                {
                    checkingMySQLRow.cellDetection = true;
                }
                else
                {
                    checkingMySQLRow.cellDetection = false;
                }
            }
            //ArtiID
            if (checkingMySQLRow.IsArtiIDNull())
            {
                checkingMySQLRow.ArtiID = true;
            }
            //LootTemplateTable
            if (checkingMySQLRow.IsLootTemplateTableNull())
            {
                checkingMySQLRow.LootTemplateTable = "LootTemplate";
            }
            //MobXLootTemplate
            if (checkingMySQLRow.IsMobXLootTemplateTableNull())
            {
                checkingMySQLRow.MobXLootTemplateTable = "MobXLootTemplate";
            }

            //Set default values for new options in BasicRow
            Preferences.BasicRow checkingBasicRow = (Preferences.BasicRow) this.preferences.Basic.Rows[0];
            //check Application updates
            if (checkingBasicRow.IscheckApplicationUpdatesNull())
            {
                checkingBasicRow.checkApplicationUpdates = true;
            }
            //check Database updates
            if (checkingBasicRow.IscheckDatabaseUpdatesNull())
            {
                checkingBasicRow.checkDatabaseUpdates = true;
            }
        }