private void SelectButton_Click(object sender, EventArgs e) { TireDataSet tds = Editor.SelectedDataSet; var table = (TableCB.SelectedItem as Table?).Value; if (SourceCB.SelectedItem as ProjectTree.Node_TireDataSet != null) { var ntds = SourceCB.SelectedItem as ProjectTree.Node_TireDataSet; tds = ntds.GetIDataSet().GetDataSet(); } if (tds.GetDataList(table).Count == 0) { return; } ValidateCount(); int i = SortedBin[selected[SelectedColumn]].Item1; var max = tds.MaxminSet.Limit(table).Max[SelectedColumn]; var min = tds.MaxminSet.Limit(table).Min[SelectedColumn]; double dif = (max - min) / Bin.Count; var value = i * dif + dif / 2 + min; selectedTB[SelectedColumn].Text = value.ToString(); TextBox_KeyDown(selectedTB[SelectedColumn], new KeyEventArgs(Keys.Enter)); }
private void CalcBin_ShowGraph(TireDataColumn column) { TireDataSet tds = Editor.SelectedDataSet; if (SourceCB.SelectedItem as ProjectTree.Node_TireDataSet != null) { var ntds = SourceCB.SelectedItem as ProjectTree.Node_TireDataSet; tds = ntds.GetIDataSet().GetDataSet(); } var table = (TableCB.SelectedItem as Table?).Value; Target = new List <double>(); foreach (var data in tds.GetDataList(table)) { Target.Add(data[column]); } Target.Sort(); MainChart.Series[SeriesData].Points.Clear(); if (Target.Count == 0) { return; } var max = tds.MaxminSet.Limit(table).Max[column]; var min = tds.MaxminSet.Limit(table).Min[column]; var bin = CalculateMinimumEntropyBin(Target, TireData.Resolution()[column], max, min); double dif = (max - min) / bin.Count; for (int i = 0; i < bin.Count; ++i) { var data = new DataPoint(i * dif + dif / 2 + min, bin[i]); MainChart.Series[SeriesData].Points.Add(data); } //選択 SortedBin = new List <Tuple <int, double> >(bin.Count); for (int i = 0; i < bin.Count; ++i) { SortedBin.Add(new Tuple <int, double>(i, bin[i])); } SortedBin.Sort(delegate(Tuple <int, double> ls, Tuple <int, double> rh) { if (ls.Item2 == rh.Item2) { return(0); } return(ls.Item2 - rh.Item2 > 0 ? -1 : 1); } ); Bin = bin; SelectBin(column); }
void SelectBin(TireDataColumn column) { TireDataSet tds = Editor.SelectedDataSet; var table = (TableCB.SelectedItem as Table?).Value; if (SourceCB.SelectedItem as ProjectTree.Node_TireDataSet != null) { var ntds = SourceCB.SelectedItem as ProjectTree.Node_TireDataSet; tds = ntds.GetIDataSet().GetDataSet(); } if (tds.GetDataList(table).Count == 0) { return; } ValidateCount(); int i = SortedBin[selected[column]].Item1; var max = tds.MaxminSet.Limit(table).Max[column]; var min = tds.MaxminSet.Limit(table).Min[column]; double dif = (max - min) / Bin.Count; var data = new DataPoint(i * dif + dif / 2 + min, Bin[i]); MainChart.Series[SeriesSelected].Points.Clear(); MainChart.Series[SeriesSelected].Points.Add(data); for (int j = 0; j < Bin.Count; ++j) { if (j == i) { continue; } data = new DataPoint(j * dif + dif / 2 + min, 0); MainChart.Series[SeriesSelected].Points.Add(data); } }