/// <summary> /// Initializes a new instance of the <see cref="SolutionBuilderViewModel"/> class. /// </summary> /// <param name="context">The pattern explorer context.</param> /// <param name="serviceProvider">The service provider.</param> public SolutionBuilderViewModel(ISolutionBuilderContext context, IServiceProvider serviceProvider) { Guard.NotNull(() => context, context); Guard.NotNull(() => serviceProvider, serviceProvider); this.context = context; this.context.ViewModel = this; this.serviceProvider = serviceProvider; this.context.SetSelected = p => this.CurrentNode = p; this.solutionListener = this.GetService <ISolutionEvents>(); this.isSolutionOpened = this.solutionListener.IsSolutionOpened; this.isStateOpened = this.context.PatternManager.IsOpen || this.isSolutionOpened; this.TopLevelNodes = new ObservableCollection <IProductElementViewModel>(); if (this.IsStateOpened) { this.Refresh(); } this.solutionListener.SolutionOpened += this.OnSolutionOpened; this.solutionListener.SolutionClosed += this.OnSolutionClosed; context.PatternManager.IsOpenChanged += this.OnIsOpenChanged; context.PatternManager.ElementDeleted += this.OnElementDeleted; context.PatternManager.ElementCreated += this.OnElementCreated; this.InitializeCommands(); }
public ElementViewModel(IAbstractElement element, ISolutionBuilderContext context) : base(element, context) { // Initialize default value for icon path this.IconPath = string.Format(CultureInfo.InvariantCulture, IconPathFormat, element.GetType().Name); if (element.Info != null) { this.CreateAddMenuOptions(); } }
public ProductViewModel(IProduct product, ISolutionBuilderContext context) : base(product, context) { this.InitializeCommands(); if (product.Info != null) { this.IconPath = IconEnabledPath; this.HasSingleView = product.Views.Count() == 1; this.CreateViewMenuOptions(); this.addOption = this.CreateAddMenuOptions(); } else { this.IconPath = IconUninstalledPath; this.HasSingleView = true; } }
protected ProductElementViewModel(IProductElement model, ISolutionBuilderContext context) : base(model) { Guard.NotNull(() => context, context); this.Context = context; this.ChildNodes = new ObservableCollection <IProductElementViewModel>(); this.MenuOptions = new ObservableCollection <IMenuOptionViewModel>(); this.InitializeCommands(); this.CreateStandardMenuOptions(); model.PropertyChanged += this.OnElementPropertyChanged; if (model.Info != null) { this.ChildNodes.CollectionChanged += this.OnNodesCollectionChanged; this.CreateAutomationMenuOptions(); } }
// Methods public LabelElementViewModel(IAbstractElement element, ISolutionBuilderContext ctx) { this.Data = element; this.Context = ctx; this.MenuOptions = new ObservableCollection<IMenuOptionViewModel>(); }
// Methods public LabelElementViewModel(IAbstractElement element, ISolutionBuilderContext ctx) { this.Data = element; this.Context = ctx; this.MenuOptions = new ObservableCollection <IMenuOptionViewModel>(); }
internal static ProductElementViewModel CreateViewModel(IProductElement child, ISolutionBuilderContext ctx) { var factory = FindFactory(child); return(factory(child, ctx).With(vm => vm.IsExpanded = true)); }