/// <summary> /// Initializes a new instance of <see cref="SingleHierarchyConfigurationUIHostAdapter"/>. /// </summary> /// <param name="hostConfiguration">The <see cref="HostAdapterConfiguration"/> that contains information on which assemblies to load into the designer.</param> /// <param name="serviceProvider">An <see cref="IServiceProvider"/> used to obtain services.</param> public SingleHierarchyConfigurationUIHostAdapter(HostAdapterConfiguration hostConfiguration, IServiceProvider serviceProvider) { this.serviceProvider = serviceProvider; editorUI = new ConfigurationEditorUI(); elementHost = new ElementHost { Child = editorUI, Dock = DockStyle.Fill }; editorControl = new UserControl() { Dock = DockStyle.Fill }; editorControl.Controls.Add(elementHost); container = new ConfigurationContainer(serviceProvider); container.RegisterInstance(new AssemblyLocator(hostConfiguration.PluginDirectory)); container.RegisterInstance <IWindowsFormsEditorService>(this); container.RegisterInstance <IUIServiceWpf>(this); container.RegisterInstance <IUIService>(this); container.RegisterInstance <IAssemblyDiscoveryService>(this); container.DiscoverSubstituteTypesFromAssemblies(); elementHost.Resize += ElementHostResize; applicationModel = container.Resolve <IApplicationModel>(); editorUI.DataContext = applicationModel; validationModel = applicationModel.ValidationModel; applicationModel.SelectedElementChanged += SelectedElementChanged; validationErrorsChanged = validationModel.ValidationResults as INotifyCollectionChanged; if (validationErrorsChanged != null) { validationErrorsChanged.CollectionChanged += ValidationErrorsCollectionChanged; } }
/// <summary> /// /// </summary> public SingleHierarchyConfigurationUIHostAdapter(HostAdapterConfiguration hostConfiguration) { ServiceContainer container = new ServiceContainer(); NodeNameCreationService nodeNameCreationService = new NodeNameCreationService(); ConfigurationUIHierarchyService configurationUIHierarchy = new ConfigurationUIHierarchyService(); configurationUIHierarchy.HierarchyRemoved += new EventHandler <HierarchyRemovedEventArgs>(configurationUIHierarchyRemoved); ComponentChangeService componentChangeService = new ComponentChangeService(); componentChangeService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged); container.AddService(typeof(IComponentChangeService), componentChangeService); container.AddService(typeof(INodeNameCreationService), nodeNameCreationService); container.AddService(typeof(IConfigurationUIHierarchyService), configurationUIHierarchy); container.AddService(typeof(IErrorLogService), new ErrorLogService()); container.AddService(typeof(INodeCreationService), new NodeCreationService()); container.AddService(typeof(IUICommandService), new UICommandService(configurationUIHierarchy)); container.AddService(typeof(IPluginDirectoryProvider), new PluginDirectoryProvider(hostConfiguration.PluginDirectory)); configurationEditor = new ConfigurationEditor(this, container); container.AddService(typeof(IUIService), configurationEditor); serviceProvider = container; }