private void BuildNextStep(bool setCurrentItem) { if (!InitSystem()) { return; } // Iterate. LSystems.IRewriteRules rules = definition as LSystems.IRewriteRules; if (rules != null) { LSystems.System nextStep = system.Clone(); switch (rules.RewriteDirection) { case LSystems.RewriteDirection.LeftToRight: nextStep.RewriteLeftToRight(); break; case LSystems.RewriteDirection.RightToLeft: nextStep.RewriteRightToLeft(); break; default: throw new InvalidOperationException("Unknown RewriteDirection"); } nextStep.Decomposite(); this.steps.Insert(0, new Step() { System = nextStep, Name = string.Format("Step {0}", steps.Count) }); system = nextStep; } if (setCurrentItem) { if (this.steps.Count > 0) { CollectionViewSource.GetDefaultView(this.steps).MoveCurrentTo(this.steps[0]); } NotifyPropertyChanged("System"); } }