/// <summary> /// Distribute the changes made to the plotitem 'pivotitem' to all other items in the collection and if neccessary, also up and down the plot item tree. /// </summary> /// <param name="pivotitem">The plot item where changes to the plot item's styles were made.</param> public void DistributeChanges(IGPlotItem pivotitem) { int pivotidx = _plotItems.IndexOf(pivotitem); if (pivotidx < 0) { return; } // Distribute the changes backward to the first item PrepareStylesIterativeBackward(pivotidx, this.ParentLayer); PlotItemCollection rootCollection = ApplyStylesIterativeBackward(pivotidx); // now prepare and apply the styles forward normally beginning from the root collection // we can set the parent styles to null since rootCollection is the lowest collection that don't inherit from a lower group. rootCollection.PrepareStylesForward_HierarchyUpOnly(null, this.ParentLayer); rootCollection.ApplyStylesForward_HierarchyUpOnly(null); }
/// <summary> /// Apply styles forward, but only up in the hierarchy. /// </summary> /// <param name="parentstyles">The parent group style collection.</param> protected void ApplyStylesForward_HierarchyUpOnly(PlotGroupStyleCollection parentstyles) { bool transferFromParentStyles = parentstyles != null && parentstyles.Count != 0 && parentstyles.DistributeToChildGroups && this._styles.InheritFromParentGroups; if (transferFromParentStyles) { PlotGroupStyleCollection.TransferFromTo(parentstyles, _styles); } _styles.BeginApply(); // now distibute the styles from the first item down to the last item int last = _plotItems.Count - 1; for (int i = 0; i <= last; i++) { IGPlotItem pi = _plotItems[i]; if (pi is PlotItemCollection) { PlotItemCollection pic = (PlotItemCollection)pi; pic.ApplyStylesForward_HierarchyUpOnly(_styles); _styles.StepIfForeignSteppingFalse(1, ((PlotItemCollection)pi)._styles); } else { pi.ApplyStyles(_styles); _styles.Step(1); } } _styles.EndApply(); if (transferFromParentStyles) { PlotGroupStyleCollection.TransferFromToIfBothSteppingEnabled(_styles, parentstyles); parentstyles.SetAllToApplied(); // to indicate that we have applied this styles and so to enable stepping } }