Ignore:
Timestamp:
07/10/15 14:16:51 (6 years ago)
Author:
mkommend
Message:

#2335: Merged all changes into stable.

Location:
stable
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Data.Views

    • Property svn:mergeinfo set to (toggle deleted branches)
      /branches/HLScript/HeuristicLab.Data.Viewsmergedeligible
      /trunk/sources/HeuristicLab.Data.Viewsmergedeligible
      /branches/1721-RandomForestPersistence/HeuristicLab.Data.Views10321-10322
      /branches/Algorithms.GradientDescent/HeuristicLab.Data.Views5516-5520
      /branches/Benchmarking/sources/HeuristicLab.Data.Views6917-7005
      /branches/CloningRefactoring/HeuristicLab.Data.Views4656-4721
      /branches/CodeEditor/HeuristicLab.Data.Views11700-11806
      /branches/DataAnalysis Refactoring/HeuristicLab.Data.Views5471-5808
      /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Data.Views5815-6180
      /branches/DataAnalysis/HeuristicLab.Data.Views4458-4459,​4462,​4464
      /branches/DataPreprocessing/HeuristicLab.Data.Views10085-11101
      /branches/DataPreprocessingImprovements/HeuristicLab.Data.Views12160-12675
      /branches/GP.Grammar.Editor/HeuristicLab.Data.Views6284-6795
      /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Data.Views5060
      /branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Data.Views11570-12508
      /branches/HeuristicLab.Problems.DataAnalysis.Trading/HeuristicLab.Data.Views6123-9799
      /branches/LogResidualEvaluator/HeuristicLab.Data.Views10202-10483
      /branches/NET40/sources/HeuristicLab.Data.Views5138-5162
      /branches/NSGA-II Changes/HeuristicLab.Data.Views12033-12122
      /branches/ParallelEngine/HeuristicLab.Data.Views5175-5192
      /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Data.Views7568-7810
      /branches/QAPAlgorithms/HeuristicLab.Data.Views6350-6627
      /branches/Restructure trunk solution/HeuristicLab.Data.Views6828
      /branches/RuntimeOptimizer/HeuristicLab.Data.Views8943-9078
      /branches/ScatterSearch (trunk integration)/HeuristicLab.Data.Views7787-8333
      /branches/SlaveShutdown/HeuristicLab.Data.Views8944-8956
      /branches/SpectralKernelForGaussianProcesses/HeuristicLab.Data.Views10204-10479
      /branches/SuccessProgressAnalysis/HeuristicLab.Data.Views5370-5682
      /branches/Trunk/HeuristicLab.Data.Views6829-6865
      /branches/UnloadJobs/HeuristicLab.Data.Views9168-9215
      /branches/VNS/HeuristicLab.Data.Views5594-5752
      /branches/histogram/HeuristicLab.Data.Views5959-6341
  • stable/HeuristicLab.Data.Views/3.3

  • stable/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs

    r12199 r12718  
    109109        dataGridView.Columns.Clear();
    110110        virtualRowIndices = new int[0];
    111       } else
     111      } else if (!dataGridView.IsCurrentCellInEditMode) {
    112112        UpdateData();
     113      }
    113114    }
    114115
     
    295296    }
    296297
    297     private void dataGridView_KeyDown(object sender, KeyEventArgs e) {
     298    protected virtual void dataGridView_KeyDown(object sender, KeyEventArgs e) {
    298299      if (!ReadOnly && e.Control && e.KeyCode == Keys.V)
    299300        PasteValuesToDataGridView();
     
    398399    }
    399400
    400     private void dataGridView_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
     401    protected virtual void dataGridView_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
    401402      if (Content != null) {
    402403        if (e.Button == MouseButtons.Left && Content.SortableView) {
    403           bool addToSortedIndices = (Control.ModifierKeys & Keys.Control) == Keys.Control;
    404           SortOrder newSortOrder = SortOrder.Ascending;
    405           if (sortedColumnIndices.Any(x => x.Key == e.ColumnIndex)) {
    406             SortOrder oldSortOrder = sortedColumnIndices.Where(x => x.Key == e.ColumnIndex).First().Value;
    407             int enumLength = Enum.GetValues(typeof(SortOrder)).Length;
    408             newSortOrder = oldSortOrder = (SortOrder)Enum.Parse(typeof(SortOrder), ((((int)oldSortOrder) + 1) % enumLength).ToString());
    409           }
    410 
    411           if (!addToSortedIndices)
    412             sortedColumnIndices.Clear();
    413 
    414           if (sortedColumnIndices.Any(x => x.Key == e.ColumnIndex)) {
    415             int sortedIndex = sortedColumnIndices.FindIndex(x => x.Key == e.ColumnIndex);
    416             if (newSortOrder != SortOrder.None)
    417               sortedColumnIndices[sortedIndex] = new KeyValuePair<int, SortOrder>(e.ColumnIndex, newSortOrder);
    418             else
    419               sortedColumnIndices.RemoveAt(sortedIndex);
    420           } else
    421             if (newSortOrder != SortOrder.None)
    422               sortedColumnIndices.Add(new KeyValuePair<int, SortOrder>(e.ColumnIndex, newSortOrder));
    423           Sort();
     404          SortColumn(e.ColumnIndex);
    424405        }
    425406      }
     
    438419      dataGridView.Invalidate();
    439420    }
     421
     422    protected virtual void SortColumn(int columnIndex) {
     423      bool addToSortedIndices = (Control.ModifierKeys & Keys.Control) == Keys.Control;
     424      SortOrder newSortOrder = SortOrder.Ascending;
     425      if (sortedColumnIndices.Any(x => x.Key == columnIndex)) {
     426        SortOrder oldSortOrder = sortedColumnIndices.Where(x => x.Key == columnIndex).First().Value;
     427        int enumLength = Enum.GetValues(typeof(SortOrder)).Length;
     428        newSortOrder = oldSortOrder = (SortOrder)Enum.Parse(typeof(SortOrder), ((((int)oldSortOrder) + 1) % enumLength).ToString());
     429      }
     430
     431      if (!addToSortedIndices)
     432        sortedColumnIndices.Clear();
     433
     434      if (sortedColumnIndices.Any(x => x.Key == columnIndex)) {
     435        int sortedIndex = sortedColumnIndices.FindIndex(x => x.Key == columnIndex);
     436        if (newSortOrder != SortOrder.None)
     437          sortedColumnIndices[sortedIndex] = new KeyValuePair<int, SortOrder>(columnIndex, newSortOrder);
     438        else
     439          sortedColumnIndices.RemoveAt(sortedIndex);
     440      } else
     441        if (newSortOrder != SortOrder.None)
     442          sortedColumnIndices.Add(new KeyValuePair<int, SortOrder>(columnIndex, newSortOrder));
     443      Sort();
     444    }
     445
    440446    protected virtual int[] Sort(IEnumerable<KeyValuePair<int, SortOrder>> sortedColumns) {
    441447      int[] newSortedIndex = Enumerable.Range(0, Content.Rows).ToArray();
     
    510516    }
    511517
    512     private void dataGridView_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e) {
     518    protected virtual void dataGridView_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e) {
    513519      if (Content == null) return;
    514520      if (e.Button == MouseButtons.Right && Content.ColumnNames.Count() != 0)
     
    543549
    544550    protected virtual void dataGridView_SelectionChanged(object sender, EventArgs e) {
    545       string stringFormat = "{0,20:0.0000}";
    546551      statisticsTextBox.Text = string.Empty;
    547552      if (dataGridView.SelectedCells.Count > 1) {
     
    553558        }
    554559        if (selectedValues.Count > 1) {
    555           StringBuilder labelText = new StringBuilder();
    556           labelText.Append("Count: " + string.Format(stringFormat, selectedValues.Count) + "    ");
    557           labelText.Append("Sum: " + string.Format(stringFormat, selectedValues.Sum()) + "    ");
    558           labelText.Append("Min: " + string.Format(stringFormat, selectedValues.Min()) + "    ");
    559           labelText.Append("Max: " + string.Format(stringFormat, selectedValues.Max()) + "    ");
    560           labelText.Append("Average: " + string.Format(stringFormat, selectedValues.Average()) + "    ");
    561           labelText.Append("Standard Deviation: " + string.Format(stringFormat, selectedValues.StandardDeviation()) + "    ");
    562 
    563           statisticsTextBox.Text = labelText.ToString();
    564         }
    565       }
     560          statisticsTextBox.Text = CreateStatisticsText(selectedValues);
     561        }
     562      }
     563    }
     564
     565    protected virtual string CreateStatisticsText(ICollection<double> values) {
     566      string stringFormat = "{0,20:0.0000}";
     567      int overallCount = values.Count;
     568      values = values.Where(x => !double.IsNaN(x)).ToList();
     569      if (!values.Any()) {
     570        return "";
     571      }
     572      StringBuilder statisticsText = new StringBuilder();
     573      statisticsText.Append("Count: " + values.Count + "    ");
     574      statisticsText.Append("Sum: " + string.Format(stringFormat, values.Sum()) + "    ");
     575      statisticsText.Append("Min: " + string.Format(stringFormat, values.Min()) + "    ");
     576      statisticsText.Append("Max: " + string.Format(stringFormat, values.Max()) + "    ");
     577      statisticsText.Append("Average: " + string.Format(stringFormat, values.Average()) + "    ");
     578      statisticsText.Append("Standard Deviation: " + string.Format(stringFormat, values.StandardDeviation()) + "    ");
     579      if (overallCount > 0)
     580        statisticsText.Append("Missing Values: " + string.Format(stringFormat, ((overallCount - values.Count) / (double)overallCount) * 100) + "%    ");
     581      return statisticsText.ToString();
    566582    }
    567583  }
Note: See TracChangeset for help on using the changeset viewer.