/// <summary> /// The event-handler that is invoked by the subscription that listens for <see cref="Option"/>s added /// </summary> /// <param name="option">the Iteration</param> private void OptionAddedEventHandler(Option option) { var session = this.Sessions.SingleOrDefault(s => s.Assembler.Cache == option.Cache); if (session == null) { throw new InvalidOperationException("There is no ISession associated with an option."); } var groupViewModel = this.OpenIterations.SingleOrDefault(x => x.Thing == option.Container); if (groupViewModel != null) { // if there is no iteration group that this option depends on do nothing // only add if not present yet. if (groupViewModel.SelectedOptions.All(x => x.Option != option)) { var menuItem = new RibbonMenuItemOptionDependentViewModel(option, session, this.InstantiatePanelViewModelFunction); groupViewModel.SelectedOptions.Add(menuItem); } } }
/// <summary> /// The event-handler that is invoked by the subscription that listens for <see cref="Iteration"/>s added /// </summary> /// <param name="iteration">the Iteration</param> private void IterationAddedEventHandler(Iteration iteration) { var session = this.Sessions.SingleOrDefault(s => s.Assembler.Cache == iteration.Cache); if (session == null) { throw new InvalidOperationException("There is no ISession associated with an Iteration."); } var modelGroupViewModel = this.OpenIterations.SingleOrDefault(x => x.Thing == iteration); if (modelGroupViewModel == null) { modelGroupViewModel = new IterationMenuGroupViewModel(iteration, session); this.OpenIterations.Add(modelGroupViewModel); } foreach (var option in iteration.Option) { var menuItem = new RibbonMenuItemOptionDependentViewModel((Option)option, session, this.InstantiatePanelViewModelFunction); modelGroupViewModel.SelectedOptions.Add(menuItem); } }