// TODO: Too many arguments, pass a context instead public void SetSource(IEnumerable source, int groupLevels, TotalsPosition totalsPosition, int aggregatesLevel, int totalsCount, bool showAggregateValuesInline, bool restoreCollapsed) { if ((aggregatesLevel <= -1 || aggregatesLevel >= groupLevels) && totalsCount > 1) { aggregatesLevel = Math.Max(0, groupLevels - 1); } else if (totalsCount <= 1) { aggregatesLevel = 0; } this.GroupLevels = groupLevels; this.TotalsPosition = totalsPosition; this.AggregatesLevel = aggregatesLevel; // this.TotalsCount = totalsCount; this.ShowAggregateValuesInline = showAggregateValuesInline; this.SetItemsSource(source); this.SetItemsSourceOverride(this.ItemsSource, restoreCollapsed); this.UpdateStrategiesCount(); this.RaiseItemsSourceChanged(EventArgs.Empty); }
public void SetSource(IEnumerable source, int groupLevels, TotalsPosition totalsPosition, int aggregatesLevel, int totalsCount, bool showAggregateValuesInline) { this.SetSource(source, groupLevels, totalsPosition, aggregatesLevel, totalsCount, showAggregateValuesInline, false); }
private static void GenerateGroups(int level, int aggregatesLevel, IList <TestGroup> groups, int totalLevelCount, int childCount, int totalsCount, TotalsPosition totalsPosition, bool showAggregatesValueInline) { if (level < totalLevelCount) { aggregatesLevel = totalsCount > 1 ? aggregatesLevel : -1; int end = (level == aggregatesLevel && totalsCount > 1) ? totalsCount : childCount; for (int i = 1; i <= end; i++) { var group = new TestGroup(string.Format("Level: {0}, Group: {1}", level, i)); if (level == (totalLevelCount - 1)) { group.Type = GroupType.BottomLevel; } else if (level < (totalLevelCount - 1)) { group.Type = GroupType.Subheading; } groups.Add(group); GenerateGroups(level + 1, aggregatesLevel, group, totalLevelCount, childCount, totalsCount, totalsPosition, showAggregatesValueInline); } TestGroup tg = groups as TestGroup; if (tg != null && tg.Type == GroupType.Subheading && (level - 1) != aggregatesLevel) { if ((!showAggregatesValueInline || level != aggregatesLevel) && !(totalLevelCount - 1 == aggregatesLevel && level == totalLevelCount - 1)) { int aggCount = totalsCount; if (aggregatesLevel == -1) { aggCount = 1; } else if (aggregatesLevel < level) { aggCount = 1; } for (int i = 1; i <= aggCount; i++) { var type = level == totalLevelCount - 1 ? GroupType.BottomLevel : GroupType.Subtotal; var subTotal = new TestGroup(string.Format("Level: {0}, SubTotal: {1}", level, i)) { Type = type }; if (totalsPosition == TotalsPosition.First || (totalsPosition == TotalsPosition.Inline && aggCount > 1)) { tg.Insert(0, subTotal); } else if (totalsPosition == TotalsPosition.Last) { tg.Add(subTotal); } } } } } }
private ReadOnlyList <TestGroup> CreateGroups(int levels, int aggregatesLevel, int totalsCount = 2, TotalsPosition totalsPosition = TotalsPosition.First, bool showAggregatesValueInline = false) { ReadOnlyList <TestGroup> groups = new ReadOnlyList <TestGroup>(); Assert.IsTrue(levels >= 0); Assert.IsTrue(totalsCount >= 0); int totalLevelCount = totalsCount > 1 ? levels + 1 : levels; GenerateGroups(0, aggregatesLevel, groups, totalLevelCount, 3, totalsCount, totalsPosition, showAggregatesValueInline); Layout.SetSource(groups, totalLevelCount, totalsPosition, aggregatesLevel, totalsCount, showAggregatesValueInline); return(groups); }