Example #1
0
        private void loadRulesButton_Click(object sender, EventArgs e)
        {
            var list = new List <string>();

            foreach (var item in Directory.GetFiles(Core._appData, "*_rules.bin"))
            {
                list.Add(Path.GetFileNameWithoutExtension(item).Replace("_rules", ""));
            }

            var loadWindow = new CustomListDialog("Load...", list, "OK", "Cancel");

            if ((loadWindow.ShowDialog() == DialogResult.OK) && (this._rules.IsEmpty() || (Settings.Default.AskBeforeLoad && (MessageBox.Show("Are you sure you want to load these rules?  This action will overwrite all rules currently loaded.", "Overwrite Warning", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)) || !Settings.Default.AskBeforeLoad))
            {
                var formatter = new BinaryFormatter();
                var reader    = new FileStream(_appData + Path.DirectorySeparatorChar + loadWindow.SelectedItem + "_rules.bin", FileMode.Open, FileAccess.Read);
                this._rules       = (RuleSet)formatter.Deserialize(reader);
                this.ruleBox.Text = this._rules.ToString();
                reader.Close();
            }

            loadWindow.Dispose();
        }
Example #2
0
        private void loadPreviousButton_Click(object sender, EventArgs e)
        {
            var list = new List <string>();

            foreach (var item in Directory.GetFiles(Core._appData, "*_stats.bin"))
            {
                list.Add(Path.GetFileNameWithoutExtension(item).Replace("_stats", ""));
            }

            var loadStatsWindow = new CustomListDialog("Load...", list, "OK", "Cancel");

            if (loadStatsWindow.ShowDialog() == DialogResult.OK)
            {
                var formatter   = new BinaryFormatter();
                var reader      = new FileStream(_appData + Path.DirectorySeparatorChar + loadStatsWindow.SelectedItem + "_stats.bin", FileMode.Open, FileAccess.Read);
                var statsWindow = new StatsWindow((RenamingStats)formatter.Deserialize(reader));
                statsWindow.Show();
                reader.Close();
            }

            loadStatsWindow.Dispose();
        }
Example #3
0
        private void editButton_Click(object sender, EventArgs e)
        {
            var ruleStrings = new List <string>();

            foreach (var rule in this._rules.RuleList)
            {
                ruleStrings.Add(rule.FindPattern);
            }

            var editSelect = new CustomListDialog("Select Rule...", ruleStrings, "OK", "Cancel");

            if (editSelect.ShowDialog() == DialogResult.OK)
            {
                var editing    = this._rules.GetRule(editSelect.SelectedItem);
                var editDialog = new AddRuleDialog(ref this._rules, ref editing);
                if (editDialog.ShowDialog() == DialogResult.OK)
                {
                    this.ruleBox.Text = this._rules.ToString();
                }

                editDialog.Dispose();
                editSelect.Dispose();
            }
        }