Beispiel #1
0
        /// <summary>
        /// Creates a window containing relevant statistics about a given Renamepler operation.
        /// </summary>
        /// <param name="p_stats">RenamingStats object for the search</param>
        public StatsWindow(RenamingStats p_stats)
        {
            InitializeComponent();

            this.Setup(p_stats);

            this.statsBox.Text = this._display;
        }
Beispiel #2
0
        private void goButton_Click(object sender, EventArgs e)
        {
            if (this._path.Equals(""))
            {
                this.dirDialogButton_Click(sender, e);
            }
            if (this._path.Equals(""))
            {
                goto Quit;
            }

            if (this._rules.IsEmpty() && MessageBox.Show("No rules have been entered!", "Error", MessageBoxButtons.OK) != DialogResult.No)
            {
                goto Quit;
            }


            //Give the user the option to name the rules
            //This might be phased out later when there are RuleSet-specific options (including naming, hopefully)
            //We just want the user to be comfortable with naming rule sets, to allow for a more object-oriented paradigm with the RuleSet object in the future
            if (this._rules.SetName.Equals("Unnamed") && (MessageBox.Show("Do you want to name this rule set?", "", MessageBoxButtons.YesNo) == DialogResult.Yes))
            {
                var namingDialog = new CustomDialog("Edit Name...", "[Enter name for this set of rules]", "OK", "Cancel");
                namingDialog.EnableEditing = true;

                //goto header in case the name is invalid
Name:
                if (namingDialog.ShowDialog() == DialogResult.OK)
                {
                    var regex = new Regex("[" + Regex.Escape(new string(System.IO.Path.GetInvalidPathChars())) + "]");
                    if (namingDialog.DialogText.Equals("[Enter name for this set of rules]"))
                    {
                        MessageBox.Show("Enter a name for this set of rules!", "Error: No name!", MessageBoxButtons.OK);
                        goto Name;
                    }
                    else if (regex.IsMatch(namingDialog.DialogText))
                    {
                        MessageBox.Show("Invalid name!  Please try again.", "Error: Invalid name", MessageBoxButtons.OK);
                        goto Name;
                    }
                    else
                    {
                        this._rules.SetName = namingDialog.DialogText;
                        namingDialog.Dispose(); //Only dispose after grabbing the message text
                        this._stats = new RenamingStats(this._rules.RuleList);
                        this.Execute();
                    }
                }
            }
            else
            {
                this._stats = new RenamingStats(this._rules.RuleList);
                this.Execute();
            }
Quit:
            return;
        }
Beispiel #3
0
        /// <summary>
        /// Sets up the statistics display string.
        /// </summary>
        /// <param name="p_stats">RenamingStats object for the search</param>
        private void Setup(RenamingStats p_stats)
        {
            this._display  = "";
            this._display += "DATE: " + DateTime.Now.Date.ToString();
            if (Settings.Default.OverallStats || Settings.Default.CopyFirst) //Overall stats must be shown if the user wants to copy first
            {
                this._display += Environment.NewLine + Environment.NewLine + "OVERALL STATS" + Environment.NewLine + "******************" +
                                 Environment.NewLine + Environment.NewLine + "FILES SEARCHED: " + p_stats.TotalSearched + Environment.NewLine + "FILES MATCHED: " +
                                 p_stats.TotalFound + Environment.NewLine + "FILES RENAMED: " + p_stats.TotalRenamed;
                if (Settings.Default.OverallFilenames)
                {
                    var nameList = p_stats.OldFilenames;
                    this._display += Environment.NewLine + Environment.NewLine + "FILE(S) RENAMED:";

                    foreach (var name in nameList)
                    {
                        this._display += Environment.NewLine + Environment.NewLine + "\t" + name.Value + "\t--->" + Environment.NewLine + "\t" + name.Key;
                    }
                }
            }

            if (Settings.Default.PerRuleStats)
            {
                this._display += Environment.NewLine + Environment.NewLine + "PER RULE STATS" + Environment.NewLine + "******************";

                foreach (var rule in p_stats.RuleList)
                {
                    this._display += Environment.NewLine + "RULE: " + rule + Environment.NewLine + "FILES MATCHED: " + p_stats.GetFoundForRule(rule) +
                                     Environment.NewLine + "FILES RENAMED: " + p_stats.GetRenamedForRule(rule);

                    if (Settings.Default.PerRuleFilenames)
                    {
                        var nameList = p_stats.GetFilenamesForRule(rule);
                        this._display += Environment.NewLine + Environment.NewLine + "FILE(S) RENAMED:";

                        foreach (var name in nameList)
                        {
                            this._display += Environment.NewLine + Environment.NewLine + "\t" + name.Value + "\t--->" + Environment.NewLine + "\t" + name.Key;
                        }
                    }
                }
            }
        }