Ejemplo n.º 1
0
        public void setInitialSettings()
        {
            PreferencesSettings initialSettings = (PreferencesSettings)preferencesSettings[0];

            currentTheme    = "Gray Power";
            currentLanguage = "English";

            initialSettings.currency = "Euro";
            initialSettings.wage     = "Yearly";
            initialSettings.height   = "Centimeters";
            initialSettings.weight   = "Kilos";
            initialSettings.editing  = "No";
            initialSettings.language = "English";
            initialSettings.theme    = "Stam Dark";
            setMultipliers(ref initialSettings);

            int[] playersDefCols = { 0, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 };
            initialSettings.playerColumns.AddRange(playersDefCols);
            int[] staffDefCols = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
            initialSettings.staffColumns.AddRange(staffDefCols);
            int[] teamsDefCols = { 0, 1, 2, 3, 4, 5, 6, 9, 10 };
            initialSettings.teamColumns.AddRange(teamsDefCols);
            int[] shortlistDefCols = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
            initialSettings.shortlistColumns.AddRange(shortlistDefCols);

            initialSettings.wonderkidsMaxAge  = 20;
            initialSettings.wonderkidsMinPA   = 170;
            initialSettings.wonderstaffMinPA  = 170;
            initialSettings.wonderteamsMinRep = 8000;
        }
Ejemplo n.º 2
0
        public void set(PreferencesSettings other)
        {
            this.currency = other.currency;
            this.currencyMultiplier.multiplier = other.currencyMultiplier.multiplier;
            this.currencyMultiplier.format     = other.currencyMultiplier.format;
            this.wage = other.wage;
            this.wageMultiplier.multiplier = other.wageMultiplier.multiplier;
            this.wageMultiplier.extended   = other.wageMultiplier.extended;
            this.height = other.height;
            this.heightMultiplier.multiplier = other.heightMultiplier.multiplier;
            this.heightMultiplier.extended   = other.heightMultiplier.extended;
            this.weight = other.weight;
            this.weightMultiplier.multiplier = other.weightMultiplier.multiplier;
            this.weightMultiplier.extended   = other.weightMultiplier.extended;
            this.editing           = other.editing;
            this.language          = other.language;
            this.theme             = other.theme;
            this.wonderkidsMaxAge  = other.wonderkidsMaxAge;
            this.wonderkidsMinPA   = other.wonderkidsMinPA;
            this.wonderstaffMinPA  = other.wonderstaffMinPA;
            this.wonderteamsMinRep = other.wonderteamsMinRep;

            this.playerColumns.Clear();
            this.playerColumns.AddRange(other.playerColumns);
            this.staffColumns.Clear();
            this.staffColumns.AddRange(other.staffColumns);
            this.teamColumns.Clear();
            this.teamColumns.AddRange(other.teamColumns);
            this.shortlistColumns.Clear();
            this.shortlistColumns.AddRange(other.shortlistColumns);
        }
Ejemplo n.º 3
0
 public void setMultipliers(ref PreferencesSettings settings)
 {
     setCurrencyMultiplier(ref settings);
     setWageMultiplier(ref settings);
     setHeightMultiplier(ref settings);
     setWeightMultiplier(ref settings);
 }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public void setDefault(int i)
        {
            PreferencesSettings set = preferencesSettings[i];

            if (set.name.Equals("Initial"))
            {
                return;
            }
            string file        = globalFuncs.applicationDirectory + "\\Settings\\" + set.name + ".set";
            string contents    = "";
            string defaultLine = "";

            using (FileStream stream = new FileStream(file, FileMode.Open))
            {
                string line = "";
                using (StreamReader sw = new StreamReader(stream))
                {
                    while (!sw.EndOfStream)
                    {
                        line = sw.ReadLine();
                        if (line.Contains("Default"))
                        {
                            defaultLine = line;
                        }
                        contents += line;
                        contents += System.Environment.NewLine;;
                    }
                    sw.Close();
                }
                stream.Close();
            }

            using (FileStream stream = new FileStream(file, FileMode.Open))
            {
                stream.SetLength(0);
                using (StreamWriter sw = new StreamWriter(stream))
                {
                    string strValue = string.Empty;
                    strValue += "Default ";
                    if (set.isDefault)
                    {
                        strValue += "Yes";
                    }
                    else
                    {
                        strValue += "No";
                    }

                    sw.Write(contents.Replace(defaultLine, strValue));
                    sw.Close();
                }
                stream.Close();
            }
        }
Ejemplo n.º 6
0
 public void setWeightMultiplier(ref PreferencesSettings settings)
 {
     for (int i = 0; i < globalFuncs.localization.weightsNative.Count; ++i)
     {
         if (settings.weight.Equals(globalFuncs.localization.weightsNative[i]))
         {
             settings.weightMultiplier.multiplier = weights[i].multiplier;
             settings.weightMultiplier.extended   = weights[i].extended;
         }
     }
 }
Ejemplo n.º 7
0
        public PreferencesSettings createCustomSettings(WindowPreferences windowPreferences)
        {
            PreferencesSettings customSettings = new PreferencesSettings("Custom");

            customSettings.currency          = globalFuncs.localization.currenciesNative[windowPreferences.GeneralTabItem.currency.ComboBox.SelectedIndex];
            customSettings.wage              = globalFuncs.localization.wagesNative[windowPreferences.GeneralTabItem.wage.ComboBox.SelectedIndex];
            customSettings.height            = globalFuncs.localization.heightsNative[windowPreferences.GeneralTabItem.height.ComboBox.SelectedIndex];
            customSettings.weight            = globalFuncs.localization.weightsNative[windowPreferences.GeneralTabItem.weight.ComboBox.SelectedIndex];
            customSettings.editing           = globalFuncs.localization.editing[windowPreferences.GeneralTabItem.allowEditing.ComboBox.SelectedIndex];
            customSettings.language          = (String)windowPreferences.GeneralTabItem.language.ComboBox.SelectedItem;
            customSettings.theme             = (String)windowPreferences.GeneralTabItem.theme.ComboBox.SelectedItem;
            customSettings.wonderkidsMaxAge  = (int)windowPreferences.GeneralTabItem.wonderkidsMaxAge.NumericUpDown.Value;
            customSettings.wonderkidsMinPA   = (int)windowPreferences.GeneralTabItem.wonderkidsMinPA.NumericUpDown.Value;
            customSettings.wonderstaffMinPA  = (int)windowPreferences.GeneralTabItem.wonderstaffMinPA.NumericUpDown.Value;
            customSettings.wonderteamsMinRep = (int)windowPreferences.GeneralTabItem.wonderteamsMinRep.NumericUpDown.Value;

            for (int i = 0; i < windowPreferences.PlayerColumnsTabItem.WrapPanelColumns.Children.Count; ++i)
            {
                CheckBox item = (CheckBox)windowPreferences.PlayerColumnsTabItem.WrapPanelColumns.Children[i];
                if (item.IsChecked == true)
                {
                    customSettings.playerColumns.Add(i);
                }
            }
            for (int i = 0; i < windowPreferences.StaffColumnsTabItem.WrapPanelColumns.Children.Count; ++i)
            {
                CheckBox item = (CheckBox)windowPreferences.StaffColumnsTabItem.WrapPanelColumns.Children[i];
                if (item.IsChecked == true)
                {
                    customSettings.staffColumns.Add(i);
                }
            }
            for (int i = 0; i < windowPreferences.TeamColumnsTabItem.WrapPanelColumns.Children.Count; ++i)
            {
                CheckBox item = (CheckBox)windowPreferences.TeamColumnsTabItem.WrapPanelColumns.Children[i];
                if (item.IsChecked == true)
                {
                    customSettings.teamColumns.Add(i);
                }
            }
            for (int i = 0; i < windowPreferences.ShortlistColumnsTabItem.WrapPanelColumns.Children.Count; ++i)
            {
                CheckBox item = (CheckBox)windowPreferences.ShortlistColumnsTabItem.WrapPanelColumns.Children[i];
                if (item.IsChecked == true)
                {
                    customSettings.shortlistColumns.Add(i);
                }
            }

            setMultipliers(ref customSettings);

            return(customSettings);
        }
Ejemplo n.º 8
0
 public void setCurrencyMultiplier(ref PreferencesSettings settings)
 {
     for (int i = 0; i < globalFuncs.localization.currenciesNative.Count; ++i)
     {
         if (settings.currency.Equals(globalFuncs.localization.currenciesNative[i]))
         {
             settings.currencyMultiplier.multiplier = currencies[i].multiplier;
             settings.currencyMultiplier.format     = currencies[i].format;
             break;
         }
     }
 }
Ejemplo n.º 9
0
        public void findCurrentSetting()
        {
            int currentIndex = -1;

            for (int i = 0; i < preferencesSettings.Count; ++i)
            {
                PreferencesSettings p = (PreferencesSettings)preferencesSettings[i];
                if (p.isCurrent)
                {
                    currentIndex = i;
                    break;
                }
            }

            if (currentIndex == -1)
            {
                for (int i = 0; i < preferencesSettings.Count; ++i)
                {
                    PreferencesSettings p = (PreferencesSettings)preferencesSettings[i];
                    if (p.isDefault)
                    {
                        currentIndex = i;
                        break;
                    }
                }
            }

            if (currentIndex == -1)
            {
                currentIndex = 0;
                preferencesSettings[currentIndex].isDefault = true;
            }

            curPreferencesSettings      = preferencesSettings[currentIndex];
            curPreferencesSettingsIndex = currentIndex;
        }
Ejemplo n.º 10
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;
            }
        }
Ejemplo n.º 11
0
        public void readSettings()
        {
            string        path = globalFuncs.applicationDirectory + "\\Settings";
            DirectoryInfo di   = new DirectoryInfo(path);

            if (!di.Exists)
            {
                Directory.CreateDirectory(path);
            }
            else
            {
                FileInfo[] rgFiles = di.GetFiles("*.set");
                int        counter = 0;
                foreach (FileInfo fi in rgFiles)
                {
                    string name = fi.Name.Substring(0, fi.Name.Length - 4);
                    preferencesSettings.Add(new PreferencesSettings(name));
                    int index = this.preferencesSettings.Count - 1;
                    PreferencesSettings fileSettings = (PreferencesSettings)preferencesSettings[index];
                    using (FileStream stream = new FileStream(path + "\\" + fi.Name, FileMode.Open))
                    {
                        using (StreamReader sw = new StreamReader(stream))
                        {
                            string readLine;
                            char[] sep = { ' ' };

                            ++counter;
                            while (!sw.EndOfStream)
                            {
                                readLine = sw.ReadLine();

                                string[] ar = readLine.Split(sep);
                                if (ar.Length == 2 || ar.Length == 3)
                                {
                                    if (ar[0].Equals("Default"))
                                    {
                                        bool isDefault = false;
                                        if (ar[1].Equals("Yes"))
                                        {
                                            isDefault = true;
                                        }
                                        fileSettings.isDefault = isDefault;
                                    }
                                    else if (ar[0].Equals("Language"))
                                    {
                                        string concat = ar[1];
                                        if (ar.Length == 3)
                                        {
                                            concat += " " + ar[2];
                                        }
                                        fileSettings.language = concat;
                                    }
                                    else if (ar[0].Equals("Theme"))
                                    {
                                        string concat = ar[1];
                                        if (ar.Length == 3)
                                        {
                                            concat += " " + ar[2];
                                        }
                                        fileSettings.theme = concat;
                                    }
                                    else if (ar[0].Equals("Currency"))
                                    {
                                        string concat = ar[1];
                                        if (ar.Length == 3)
                                        {
                                            concat += " " + ar[2];
                                        }
                                        fileSettings.currency = concat;
                                    }
                                    else if (ar[0].Equals("Wage"))
                                    {
                                        fileSettings.wage = ar[1];
                                    }
                                    else if (ar[0].Equals("Height"))
                                    {
                                        fileSettings.height = ar[1];
                                    }
                                    else if (ar[0].Equals("Weight"))
                                    {
                                        fileSettings.weight = ar[1];
                                    }
                                    else if (ar[0].Equals("Editing"))
                                    {
                                        fileSettings.editing = ar[1];
                                    }
                                    else if (ar[0].Equals("WonderkidsMaxAge"))
                                    {
                                        fileSettings.wonderkidsMaxAge = Int32.Parse(ar[1]);
                                    }
                                    else if (ar[0].Equals("WonderkidsMinPA"))
                                    {
                                        fileSettings.wonderkidsMinPA = Int32.Parse(ar[1]);
                                    }
                                    else if (ar[0].Equals("WonderstaffMinPA"))
                                    {
                                        fileSettings.wonderstaffMinPA = Int32.Parse(ar[1]);
                                    }
                                    else if (ar[0].Equals("WonderteamsMinRep"))
                                    {
                                        fileSettings.wonderteamsMinRep = Int32.Parse(ar[1]);
                                    }
                                }
                                else if (ar.Length > 0)
                                {
                                    if (ar[0].Equals("PlayerColumns"))
                                    {
                                        // restore player columns
                                        for (int i = 1; i < ar.Length - 1; ++i)
                                        {
                                            fileSettings.playerColumns.Add(Int32.Parse(ar[i]));
                                        }
                                    }
                                    else if (ar[0].Equals("StaffColumns"))
                                    {
                                        // restore staff columns
                                        for (int i = 1; i < ar.Length - 1; ++i)
                                        {
                                            fileSettings.staffColumns.Add(Int32.Parse(ar[i]));
                                        }
                                    }
                                    if (ar[0].Equals("TeamColumns"))
                                    {
                                        // restore teams columns
                                        for (int i = 1; i < ar.Length - 1; ++i)
                                        {
                                            fileSettings.teamColumns.Add(Int32.Parse(ar[i]));
                                        }
                                    }
                                    if (ar[0].Equals("ShortlistColumns"))
                                    {
                                        // restore shortlist columns
                                        for (int i = 1; i < ar.Length - 1; ++i)
                                        {
                                            fileSettings.shortlistColumns.Add(Int32.Parse(ar[i]));
                                        }
                                    }
                                }
                                else
                                {
                                    return;
                                }
                            }
                            sw.Close();
                        }
                        stream.Close();
                    }
                    setMultipliers(ref fileSettings);
                }
            }
        }
Ejemplo n.º 12
0
        public bool Equals(PreferencesSettings other)
        {
            if (Object.ReferenceEquals(other, null))
            {
                return(false);
            }
            if (Object.ReferenceEquals(other, this))
            {
                return(true);
            }
            bool element = this.currency == other.currency &&
                           this.wage == other.wage &&
                           this.height == other.height &&
                           this.weight == other.weight &&
                           this.editing == other.editing &&
                           this.language == other.language &&
                           this.theme == other.theme &&
                           this.wonderkidsMaxAge == other.wonderkidsMaxAge &&
                           this.wonderkidsMinPA == other.wonderkidsMinPA &&
                           this.wonderstaffMinPA == other.wonderstaffMinPA &&
                           this.wonderteamsMinRep == other.wonderteamsMinRep;

            bool list = true;

            for (int i = 0; i < this.playerColumns.Count; ++i)
            {
                if (this.playerColumns[i] != other.playerColumns[i])
                {
                    list = false;
                    break;
                }
            }

            for (int i = 0; i < this.staffColumns.Count; ++i)
            {
                if (this.staffColumns[i] != other.staffColumns[i])
                {
                    list = false;
                    break;
                }
            }

            for (int i = 0; i < this.teamColumns.Count; ++i)
            {
                if (this.teamColumns[i] != other.teamColumns[i])
                {
                    list = false;
                    break;
                }
            }

            for (int i = 0; i < this.shortlistColumns.Count; ++i)
            {
                if (this.shortlistColumns[i] != other.shortlistColumns[i])
                {
                    list = false;
                    break;
                }
            }

            return(element && list);
        }