public void AddMultipleItemStatisticsSet(MultipleItemStatisticsSet newSet) { _itemStatisticsSets.Add(newSet); comboBoxSelectedSet.Items.Add(newSet.Name); // Update the UI to comply with the new set of dataDelivery. foreach (PropertyStatisticsData data in newSet.PropertiesData) { ListViewItem listViewItemSelectionItem = new ListViewItem(data.Columns); // AddElement the name of the set here. listViewItemSelectionItem.Tag = data; listViewItemSelection.Items.Add(listViewItemSelectionItem); } if (listViewItemSelection.Columns.Count > 0) { listViewItemSelection.Columns[0].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); } }
/// <summary> /// MultipleItemStatisticsSet parentSet CAN be NULL. /// </summary> public PropertyStatisticsData(MultipleItemStatisticsSet parentSet, PropertyInfo info, object[] items) { _parentSet = parentSet; Info = info; if (items.Length == 0) { return; } int positiveCount = 0; int negativeCount = 0; int consecutivePositive = 0; int consecutiveNegative = 0; double consecutivePositivesSum = 0; double consecutiveNegativesSum = 0; MethodInfo getMethodInfo = info.GetGetMethod(false); foreach (object item in items) { object objResult = getMethodInfo.Invoke(item, null); double value; bool result = double.TryParse(objResult.ToString(), out value); _values.Add(value); System.Diagnostics.Debug.Assert(result, "Parsing value failed."); _maximumValue = Math.Max(value, _maximumValue); _minimumValue = Math.Min(value, _minimumValue); if (value > 0) { positiveCount++; consecutivePositive++; consecutivePositivesSum += value; consecutiveNegative = 0; consecutiveNegativesSum = 0; } else if (value < 0) { negativeCount++; consecutiveNegative++; consecutiveNegativesSum += value; consecutivePositive = 0; consecutivePositivesSum = 0; } _sum += value; _consecutivePositivesSum = Math.Max(_consecutivePositivesSum, consecutivePositivesSum); _consecutiveNegativesSum = Math.Min(_consecutiveNegativesSum, consecutiveNegativesSum); _consecutivePositives = Math.Max(_consecutivePositives, consecutivePositive); _consecutiveNegatives = Math.Max(_consecutiveNegatives, consecutiveNegative); } _positivePercentage = 100 * (double)positiveCount / (double)items.Length; _negativePercentage = 100 * (double)negativeCount / (double)items.Length; _averageValue = _sum / items.Length; }
/// <summary> /// MultipleItemStatisticsSet parentSet CAN be NULL. /// </summary> public PropertyStatisticsData(MultipleItemStatisticsSet parentSet, PropertyInfo info, object[] items) { _parentSet = parentSet; Info = info; if (items.Length == 0) { return; } int positiveCount = 0; int negativeCount = 0; int consecutivePositive = 0; int consecutiveNegative = 0; double consecutivePositivesSum = 0; double consecutiveNegativesSum = 0; MethodInfo getMethodInfo = info.GetGetMethod(false); foreach (object item in items) { object objResult = getMethodInfo.Invoke(item, null); double value; bool result = double.TryParse(objResult.ToString(), out value); _values.Add(value); System.Diagnostics.Debug.Assert(result, "Parsing value failed."); _maximumValue = Math.Max(value, _maximumValue); _minimumValue = Math.Min(value, _minimumValue); if (value > 0) { positiveCount++; consecutivePositive++; consecutivePositivesSum += value; consecutiveNegative = 0; consecutiveNegativesSum = 0; } else if (value < 0) { negativeCount++; consecutiveNegative++; consecutiveNegativesSum += value; consecutivePositive = 0; consecutivePositivesSum = 0; } _sum += value; _consecutivePositivesSum = Math.Max(_consecutivePositivesSum, consecutivePositivesSum); _consecutiveNegativesSum = Math.Min(_consecutiveNegativesSum, consecutiveNegativesSum); _consecutivePositives = Math.Max(_consecutivePositives, consecutivePositive); _consecutiveNegatives = Math.Max(_consecutiveNegatives, consecutiveNegative); } _positivePercentage = 100 * (double)positiveCount / (double)items.Length; _negativePercentage = 100 * (double)negativeCount / (double)items.Length; _averageValue = _sum / items.Length; }