Ejemplo n.º 1
0
        /// <summary>
        /// Creates the Toolwindow's View and binds it to the Component Diagnostics data model.
        /// On failure, a suitable view is created to display the message in the toolwindow.
        /// </summary>
        /// <returns>A view for the toolwindow or error message as appropriate.</returns>
        static FrameworkElement CreateView()
        {
            Shell.ThreadHelper.ThrowIfNotOnUIThread();

            // CONSIDER: It has been suggested that this data model could be exposed as a
            // DataSource (via a DataSource factory) or even a DiagnosticsProvider itself.
            ServiceDataModel model = ServiceDataModel.CreateInstance();

            return(ViewHelper.CreateModelBoundViewOrErrorMessage(GuidList.UiFactory, UIElementIds.ToolWindowView, model));
        }
        internal static ServiceDataModel CreateInstance()
        {
            Shell.ThreadHelper.ThrowIfNotOnUIThread();
            ServiceDataModel dataModel = new ServiceDataModel();

            UIDataSourceCollection providers = new UIDataSourceCollection();

            // Pre-populate the Providers collection with known providers from
            // the settings store.
            foreach (ProviderRegistration provider in Settings.RegisteredProviders)
            {
                providers.AddItem(new RegisteredProvider(provider));
            }

            dataModel.Providers = providers;

            return(dataModel);
        }