Exemple #1
0
        public static Settings Load(string filename = "settings.xml")
        {
            Settings s = null;

            if (!File.Exists(filename))
            {
                s = new Settings();
                s.Save(filename);
                return s;
            }

            using (StreamReader sr = new StreamReader(filename))
            {
                XmlSerializer xs = new XmlSerializer(typeof(Settings));
                s = (Settings)xs.Deserialize(sr);
            }

            return s == null ? new Settings() : s;
        }
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Command[] rawCommands = new Command[lstActions.Items.Count];
            lstActions.Items.CopyTo(rawCommands, 0);

            Settings s = new Settings()
            {
                ActiveObjects = rawCommands,
                Cooldown = (int)nudCooldown.Value,
                MaxCutoff = (int)nudMaxCutoff.Value,
                MinCutoff = (int)nudCutoff.Value
            };

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                s.Save(saveFileDialog.FileName);
            }
        }