Beispiel #1
0
        public void addCustomSetting()
        {
            this.usingCustomSettings = true;
            PreferencesSettings oldPreferencesSettings = this.curPreferencesSettings;
            PreferencesSettings preferencesSettings    = new PreferencesSettings("Custom");

            this.settingNames.Insert(0, preferencesSettings.name);
            this.preferencesSettings.Insert(0, preferencesSettings);
            preferencesSettings.set(oldPreferencesSettings);
        }
Beispiel #2
0
        private void saveSettingsFile(string name, ref WindowPreferences windowPreferences)
        {
            PreferencesSettings savedSettings = createCustomSettings(windowPreferences);

            // Saves the file via a FileStream created by the OpenFile method.
            string file = globalFuncs.applicationDirectory + "\\Settings\\" + name + ".set";

            using (FileStream stream = new FileStream(file, FileMode.OpenOrCreate))
            {
                stream.SetLength(0);
                using (StreamWriter sw = new StreamWriter(stream))
                {
                    string strValue = string.Empty;

                    strValue += "Default No";
                    strValue += System.Environment.NewLine;
                    strValue += "Theme " + savedSettings.theme;
                    strValue += System.Environment.NewLine;
                    strValue += "Language " + savedSettings.language;
                    strValue += System.Environment.NewLine;
                    strValue += "Currency " + savedSettings.currency;
                    strValue += System.Environment.NewLine;
                    strValue += "Wage " + savedSettings.wage;
                    strValue += System.Environment.NewLine;
                    strValue += "Height " + savedSettings.height;
                    strValue += System.Environment.NewLine;
                    strValue += "Weight " + savedSettings.weight;
                    strValue += System.Environment.NewLine;
                    strValue += "Editing " + savedSettings.editing;
                    strValue += System.Environment.NewLine;
                    strValue += "WonderkidsMaxAge " + savedSettings.wonderkidsMaxAge;
                    strValue += System.Environment.NewLine;
                    strValue += "WonderkidsMinPA " + savedSettings.wonderkidsMinPA;
                    strValue += System.Environment.NewLine;
                    strValue += "WonderstaffMinPA " + savedSettings.wonderstaffMinPA;
                    strValue += System.Environment.NewLine;
                    strValue += "WonderteamsMinRep " + savedSettings.wonderteamsMinRep;
                    strValue += System.Environment.NewLine;

                    // save player columns
                    strValue += "PlayerColumns ";
                    for (int i = 0; i < savedSettings.playerColumns.Count; ++i)
                    {
                        strValue += savedSettings.playerColumns[i] + " ";
                    }
                    strValue += System.Environment.NewLine;

                    // save staff columns
                    strValue += "StaffColumns ";
                    for (int i = 0; i < savedSettings.staffColumns.Count; ++i)
                    {
                        strValue += savedSettings.staffColumns[i] + " ";
                    }
                    strValue += System.Environment.NewLine;

                    // save teams columns
                    strValue += "TeamColumns ";
                    for (int i = 0; i < savedSettings.teamColumns.Count; ++i)
                    {
                        strValue += savedSettings.teamColumns[i] + " ";
                    }
                    strValue += System.Environment.NewLine;

                    // save shortlist columns
                    strValue += "ShortlistColumns ";
                    for (int i = 0; i < savedSettings.shortlistColumns.Count; ++i)
                    {
                        strValue += savedSettings.shortlistColumns[i] + " ";
                    }

                    sw.Write(strValue);
                    sw.Close();
                }
                stream.Close();
            }

            bool contains = false;
            int  index    = -1;

            for (int i = 0; i < this.settingNames.Count; ++i)
            {
                if (this.settingNames[i] == name)
                {
                    contains = true;
                    index    = i;
                    break;
                }
            }

            if (contains)
            {
                this.preferencesSettings[index].set(savedSettings);
                windowPreferences.removeCustomSetting();
                windowPreferences.vm.setting.ComboBoxSelectedIndex = index - 1;
            }
            else
            {
                PreferencesSettings set = new PreferencesSettings(name);
                set.set(savedSettings);
                this.preferencesSettings.Add(set);
                //this.preferencesSettings[this.settingNames.Count - 1].set(curPreferencesSettings);
                windowPreferences.removeCustomSetting();
                windowPreferences.vm.setting.ComboBoxSelectedIndex = this.settingNames.Count - 1;
            }
        }