private TreeGridModel GenerateGroupedModel(TreeGridModel UngroupedModel) { IEnumerable <TimingDataViewModel> TimingDataModel = UngroupedModel.Cast <TimingDataViewModel>(); double OverrideDuration = TimingDataModel.ElementAt(0).ParentDurationOverride ?? TimingDataModel.Sum(d => d.InclusiveDuration); List <TimingDataViewModel> ClonedChildren = new List <TimingDataViewModel>(); foreach (TimingDataViewModel Child in TimingDataModel) { TimingDataViewModel ClonedChild = Child.Clone(); if (ClonedChild.HasChildren) { IEnumerable <TimingDataViewModel> GroupedChildren = GroupChildren(ClonedChild.Children.Cast <TimingDataViewModel>()); ClonedChild.Children.Clear(); foreach (TimingDataViewModel GroupedChild in GroupedChildren) { ClonedChild.Children.Add(GroupedChild); } } ClonedChildren.Add(ClonedChild); } IEnumerable <TimingDataViewModel> GroupedClonedChildren = GroupChildren(ClonedChildren); foreach (TimingDataViewModel Child in GroupedClonedChildren) { Child.ParentDurationOverride = OverrideDuration; } return(new TreeGridModel(GroupedClonedChildren)); }
private TreeGridModel GenerateFlattenedModel(TreeGridModel UnflattenedModel) { IEnumerable <TimingDataViewModel> TimingDataModel = UnflattenedModel.Cast <TimingDataViewModel>(); double OverrideDuration = TimingDataModel.ElementAt(0).ParentDurationOverride ?? TimingDataModel.Sum(d => d.InclusiveDuration); Dictionary <string, TimingDataViewModel> FlattenedIncludes = new Dictionary <string, TimingDataViewModel>(); FlattenIncludesInternal(FlattenedIncludes, TimingDataModel, OverrideDuration); return(new TreeGridModel(FlattenedIncludes.Values)); }