Exemple #1
0
        private void RemoveComparison(DataGridViewTextBoxColumn column)
        {
            var name = column.Name;
            runGrid.Columns.Remove(column);
            Run.CustomComparisons.Remove(name);

            if (CurrentState.CurrentComparison == name)
                CurrentState.CurrentComparison = Model.Run.PersonalBestComparisonName;

            var args = new RenameEventArgs();
            args.OldName = name;
            args.NewName = "Current Comparison";
            ComparisonRenamed(this, args);

            foreach (var segment in Run)
                segment.Comparisons.Remove(name);
            RaiseRunEdited();
        }
Exemple #2
0
 private void RenameComparison(DataGridViewTextBoxColumn column)
 {
     var name = column.Name;
     var newName = name;
     var dialogResult = InputBox.Show("Rename Comparison", "Comparison Name:", ref newName);
     if (dialogResult == DialogResult.OK)
     {
         if (!Run.Comparisons.Contains(newName))
         {
             if (!newName.StartsWith("[Race]"))
             {
                 column.Name = newName;
                 column.Width = Math.Max(100, column.GetPreferredWidth(DataGridViewAutoSizeColumnMode.ColumnHeader, true));
                 if (CurrentState.CurrentComparison == name)
                     CurrentState.CurrentComparison = newName;
                 Run.CustomComparisons[Run.CustomComparisons.IndexOf(name)] = newName;
                 foreach (var segment in Run)
                 {
                     segment.Comparisons[newName] = segment.Comparisons[name];
                     segment.Comparisons.Remove(name);
                 }
                 var args = new RenameEventArgs();
                 args.OldName = name;
                 args.NewName = newName;
                 ComparisonRenamed(this, args);
             }
             else
             {
                 var result = MessageBox.Show(this, "A Comparison name cannot start with [Race].", "Invalid Comparison Name", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                 if (result == DialogResult.Retry)
                     RenameComparison(column);
             }
         }
         else if (newName != name)
         {
             var result = MessageBox.Show(this, "A Comparison with this name already exists.", "Comparison Already Exists", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
             if (result == DialogResult.Retry)
                 RenameComparison(column);
         }
     }
     RaiseRunEdited();
 }