//===================================================================== /// <summary> /// This is used to get the current plug-in settings from the project when needed /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void ucPlugInPropertiesPageContent_ComponentSettingsNeeded(object sender, ComponentSettingsNeededEventArgs e) { ProjectProperty plugInsProp; #if !STANDALONEGUI if (this.IsDisposed || this.ProjectMgr == null) { return; } plugInsProp = this.ProjectMgr.BuildProject.GetProperty("PlugInConfigurations"); #else if (this.IsDisposed || this.CurrentProject == null) { return; } plugInsProp = this.CurrentProject.MSBuildProject.GetProperty("PlugInConfigurations"); #endif var currentConfigs = new PlugInConfigurationDictionary(); if (plugInsProp != null && !String.IsNullOrEmpty(plugInsProp.UnevaluatedValue)) { currentConfigs.FromXml(plugInsProp.UnevaluatedValue); } e.ProjectLoaded = true; e.PlugIns = currentConfigs; }
/// <inheritdoc /> public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { PlugInConfigurationDictionary items = value as PlugInConfigurationDictionary; int disabled = 0; if (items == null || destinationType != typeof(string)) { return(base.ConvertTo(context, culture, value, destinationType)); } if (items.Count == 0) { return("(None)"); } foreach (PlugInConfiguration pc in items.Values) { if (!pc.Enabled) { disabled++; } } if (disabled == 0) { return(String.Format(culture, "{0} plug-in(s)", items.Count)); } return(String.Format(culture, "{0} plug-in(s), " + "{1} disabled", items.Count, disabled)); }
//===================================================================== // Methods, etc. /// <summary> /// Constructor /// </summary> /// <param name="configs">The current configurations</param> internal PlugInConfigurationEditorDlg( PlugInConfigurationDictionary configs) { int idx; InitializeComponent(); currentConfigs = configs; try { foreach(string key in PlugInManager.PlugIns.Keys) lbAvailablePlugIns.Items.Add(key); } catch(ReflectionTypeLoadException loadEx) { System.Diagnostics.Debug.WriteLine(loadEx.ToString()); System.Diagnostics.Debug.WriteLine( loadEx.LoaderExceptions[0].ToString()); MessageBox.Show("Unexpected error loading plug-ins: " + loadEx.LoaderExceptions[0].Message, Constants.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error); } catch(Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("Unexpected error loading plug-ins: " + ex.Message, Constants.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error); } if(lbAvailablePlugIns.Items.Count != 0) lbAvailablePlugIns.SelectedIndex = 0; else { MessageBox.Show("No valid plug-ins found", Constants.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information); gbAvailablePlugIns.Enabled = gbProjectAddIns.Enabled = false; } foreach(string key in currentConfigs.Keys) { idx = lbProjectPlugIns.Items.Add(key); lbProjectPlugIns.SetItemChecked(idx, currentConfigs[key].Enabled); } if(lbProjectPlugIns.Items.Count != 0) lbProjectPlugIns.SelectedIndex = 0; else btnConfigure.Enabled = btnDelete.Enabled = false; }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { // Get the plug-in configuration dictionary PlugInConfigurationDictionary items = value as PlugInConfigurationDictionary; if (context == null || provider == null || context.Instance == null || items == null) { return(base.EditValue(context, provider, value)); } using (PlugInConfigurationEditorDlg dlg = new PlugInConfigurationEditorDlg(items)) { dlg.ShowDialog(); } return(value); }
/// <summary> /// This refreshes the project instance property values by reloading them from the underlying MSBuild /// project. /// </summary> public void RefreshProjectProperties() { projectPropertyCache = null; docSources = null; apiFilter = null; namespaceSummaries = null; componentConfigs = null; plugInConfigs = null; msBuildProject.ReevaluateIfNecessary(); this.LoadProperties(); }
/// <summary> /// This is called when the component cache has finished being loaded and is available for use /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void componentCache_ComponentContainerLoaded(object sender, EventArgs e) { ComponentSettingsNeededEventArgs projectSettings = new ComponentSettingsNeededEventArgs(); this.ComponentSettingsNeeded?.Invoke(this, projectSettings); HashSet <string> plugInIds = new HashSet <string>(); try { Mouse.OverrideCursor = Cursors.Wait; lbAvailablePlugIns.Items.Clear(); lbProjectPlugIns.Items.Clear(); availablePlugIns = componentCache.ComponentContainer.GetExports <IPlugIn, IPlugInMetadata>().ToList(); availableConfigEditors = componentCache.ComponentContainer.GetExports <IPlugInConfigurationEditor, IPlugInConfigurationEditorMetadata>().ToList(); // There may be duplicate component IDs across the assemblies found. See // BuildComponentManger.GetComponentContainer() for the folder search precedence. Only the first // component for a unique ID will be used. We also ignore hidden plug-ins. foreach (var plugIn in availablePlugIns) { if (!plugIn.Metadata.IsHidden && !plugInIds.Contains(plugIn.Metadata.Id)) { lbAvailablePlugIns.Items.Add(plugIn.Metadata.Id); plugInIds.Add(plugIn.Metadata.Id); } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("Unexpected error loading plug-ins: " + ex.Message, Constants.AppName, MessageBoxButton.OK, MessageBoxImage.Error); } finally { lbAvailablePlugIns.Items.Refresh(); Mouse.OverrideCursor = null; } if (projectSettings.ProjectLoaded) { if (lbAvailablePlugIns.Items.Count != 0) { lbAvailablePlugIns.SelectedIndex = 0; gbAvailablePlugIns.IsEnabled = gbProjectPlugIns.IsEnabled = true; } else { MessageBox.Show("No valid plug-ins found", Constants.AppName, MessageBoxButton.OK, MessageBoxImage.Information); gbAvailablePlugIns.IsEnabled = gbProjectPlugIns.IsEnabled = false; return; } this.SelectedPlugIns = projectSettings.PlugIns; foreach (var kv in this.SelectedPlugIns) { lbProjectPlugIns.Items.Add(new PlugInConfig { Name = kv.Key, Configuration = kv.Value }); } if (lbProjectPlugIns.Items.Count != 0) { lbProjectPlugIns.Items.Refresh(); lbProjectPlugIns.SelectedIndex = 0; btnDelete.IsEnabled = true; } else { btnConfigure.IsEnabled = btnDelete.IsEnabled = false; } } }
//===================================================================== /// <inheritdoc /> protected override bool BindControlValue(Control control) { ProjectProperty projProp; int idx; lbProjectPlugIns.Items.Clear(); btnConfigure.Enabled = btnDelete.Enabled = false; #if !STANDALONEGUI SandcastleProject currentProject = null; if(base.ProjectMgr != null) currentProject = ((SandcastleBuilderProjectNode)base.ProjectMgr).SandcastleProject; if(componentContainer == null || currentProject == null || currentProject.Filename != lastProjectName) this.LoadAvailablePlugInMetadata(); if(this.ProjectMgr == null || currentProject == null) return false; projProp = this.ProjectMgr.BuildProject.GetProperty("PlugInConfigurations"); #else if(componentContainer == null || base.CurrentProject == null || base.CurrentProject.Filename != lastProjectName) this.LoadAvailablePlugInMetadata(); if(base.CurrentProject == null) return false; projProp = base.CurrentProject.MSBuildProject.GetProperty("PlugInConfigurations"); #endif currentConfigs = new PlugInConfigurationDictionary(); if(projProp != null && !String.IsNullOrEmpty(projProp.UnevaluatedValue)) currentConfigs.FromXml(projProp.UnevaluatedValue); foreach(string key in currentConfigs.Keys) { idx = lbProjectPlugIns.Items.Add(key); lbProjectPlugIns.SetItemChecked(idx, currentConfigs[key].Enabled); } if(lbProjectPlugIns.Items.Count != 0) { lbProjectPlugIns.SelectedIndex = 0; btnConfigure.Enabled = btnDelete.Enabled = true; } return true; }
//===================================================================== /// <inheritdoc /> protected override bool BindControlValue(Control control) { ProjectProperty projProp; int idx; lbProjectPlugIns.Items.Clear(); btnConfigure.Enabled = btnDelete.Enabled = false; #if !STANDALONEGUI SandcastleProject currentProject = null; if (base.ProjectMgr != null) { currentProject = ((SandcastleBuilderProjectNode)base.ProjectMgr).SandcastleProject; } if (componentContainer == null || currentProject == null || currentProject.Filename != lastProjectName) { this.LoadAvailablePlugInMetadata(); } if (this.ProjectMgr == null || currentProject == null) { return(false); } currentConfigs = new PlugInConfigurationDictionary(currentProject); projProp = this.ProjectMgr.BuildProject.GetProperty("PlugInConfigurations"); #else if (componentContainer == null || base.CurrentProject == null || base.CurrentProject.Filename != lastProjectName) { this.LoadAvailablePlugInMetadata(); } if (base.CurrentProject == null) { return(false); } currentConfigs = new PlugInConfigurationDictionary(base.CurrentProject); projProp = base.CurrentProject.MSBuildProject.GetProperty("PlugInConfigurations"); #endif if (projProp != null && !String.IsNullOrEmpty(projProp.UnevaluatedValue)) { currentConfigs.FromXml(projProp.UnevaluatedValue); } foreach (string key in currentConfigs.Keys) { idx = lbProjectPlugIns.Items.Add(key); lbProjectPlugIns.SetItemChecked(idx, currentConfigs[key].Enabled); } if (lbProjectPlugIns.Items.Count != 0) { lbProjectPlugIns.SelectedIndex = 0; btnConfigure.Enabled = btnDelete.Enabled = true; } return(true); }
/// <summary> /// This is called when the component cache has finished being loaded and is available for use /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void componentCache_ComponentContainerLoaded(object sender, EventArgs e) { ProjectProperty projProp; int idx; if(this.IsDisposed) return; lbAvailablePlugIns.Items.Clear(); HashSet<string> plugInIds = new HashSet<string>(); try { Cursor.Current = Cursors.WaitCursor; lbProjectPlugIns.Items.Clear(); availablePlugIns = componentCache.ComponentContainer.GetExports<IPlugIn, IPlugInMetadata>().ToList(); // There may be duplicate component IDs across the assemblies found. See // BuildComponentManger.GetComponentContainer() for the folder search precedence. Only the first // component for a unique ID will be used. We also ignore hidden plug-ins. foreach(var plugIn in availablePlugIns) if(!plugIn.Metadata.IsHidden && !plugInIds.Contains(plugIn.Metadata.Id)) { lbAvailablePlugIns.Items.Add(plugIn.Metadata.Id); plugInIds.Add(plugIn.Metadata.Id); } } catch(Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("Unexpected error loading build components: " + ex.Message, messageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { Cursor.Current = Cursors.Default; } if(lbAvailablePlugIns.Items.Count != 0) { lbAvailablePlugIns.SelectedIndex = 0; gbAvailablePlugIns.Enabled = gbProjectAddIns.Enabled = true; } else { MessageBox.Show("No valid build components found", messageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); gbAvailablePlugIns.Enabled = gbProjectAddIns.Enabled = false; return; } #if !STANDALONEGUI if(this.ProjectMgr == null) return; projProp = this.ProjectMgr.BuildProject.GetProperty("PlugInConfigurations"); #else if(this.CurrentProject == null) return; projProp = this.CurrentProject.MSBuildProject.GetProperty("PlugInConfigurations"); #endif currentConfigs = new PlugInConfigurationDictionary(); if(projProp != null && !String.IsNullOrEmpty(projProp.UnevaluatedValue)) currentConfigs.FromXml(projProp.UnevaluatedValue); // May already be binding so preserve the original state bool isBinding = this.IsBinding; try { this.IsBinding = true; foreach(string key in currentConfigs.Keys) { idx = lbProjectPlugIns.Items.Add(key); lbProjectPlugIns.SetItemChecked(idx, currentConfigs[key].Enabled); } if(lbProjectPlugIns.Items.Count != 0) { lbProjectPlugIns.SelectedIndex = 0; btnConfigure.Enabled = btnDelete.Enabled = true; } else btnConfigure.Enabled = btnDelete.Enabled = false; } finally { this.IsBinding = isBinding; } }
/// <summary> /// This is called when the component cache has finished being loaded and is available for use /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void componentCache_ComponentContainerLoaded(object sender, EventArgs e) { ProjectProperty projProp; int idx; if (this.IsDisposed) { return; } lbAvailablePlugIns.Items.Clear(); HashSet <string> plugInIds = new HashSet <string>(); try { Cursor.Current = Cursors.WaitCursor; lbProjectPlugIns.Items.Clear(); availablePlugIns = componentCache.ComponentContainer.GetExports <IPlugIn, IPlugInMetadata>().ToList(); // There may be duplicate component IDs across the assemblies found. See // BuildComponentManger.GetComponentContainer() for the folder search precedence. Only the first // component for a unique ID will be used. We also ignore hidden plug-ins. foreach (var plugIn in availablePlugIns) { if (!plugIn.Metadata.IsHidden && !plugInIds.Contains(plugIn.Metadata.Id)) { lbAvailablePlugIns.Items.Add(plugIn.Metadata.Id); plugInIds.Add(plugIn.Metadata.Id); } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("Unexpected error loading build components: " + ex.Message, messageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { Cursor.Current = Cursors.Default; } if (lbAvailablePlugIns.Items.Count != 0) { lbAvailablePlugIns.SelectedIndex = 0; gbAvailablePlugIns.Enabled = gbProjectAddIns.Enabled = true; } else { MessageBox.Show("No valid build components found", messageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); gbAvailablePlugIns.Enabled = gbProjectAddIns.Enabled = false; return; } #if !STANDALONEGUI if (this.ProjectMgr == null) { return; } projProp = this.ProjectMgr.BuildProject.GetProperty("PlugInConfigurations"); #else if (this.CurrentProject == null) { return; } projProp = this.CurrentProject.MSBuildProject.GetProperty("PlugInConfigurations"); #endif currentConfigs = new PlugInConfigurationDictionary(); if (projProp != null && !String.IsNullOrEmpty(projProp.UnevaluatedValue)) { currentConfigs.FromXml(projProp.UnevaluatedValue); } // May already be binding so preserve the original state bool isBinding = this.IsBinding; try { this.IsBinding = true; foreach (string key in currentConfigs.Keys) { idx = lbProjectPlugIns.Items.Add(key); lbProjectPlugIns.SetItemChecked(idx, currentConfigs[key].Enabled); } if (lbProjectPlugIns.Items.Count != 0) { lbProjectPlugIns.SelectedIndex = 0; btnConfigure.Enabled = btnDelete.Enabled = true; } else { btnConfigure.Enabled = btnDelete.Enabled = false; } } finally { this.IsBinding = isBinding; } }
//===================================================================== // Methods, etc. /// <summary> /// Constructor /// </summary> /// <param name="configs">The current configurations</param> internal PlugInConfigurationEditorDlg( PlugInConfigurationDictionary configs) { int idx; InitializeComponent(); currentConfigs = configs; try { foreach (string key in PlugInManager.PlugIns.Keys) { lbAvailablePlugIns.Items.Add(key); } } catch (ReflectionTypeLoadException loadEx) { System.Diagnostics.Debug.WriteLine(loadEx.ToString()); System.Diagnostics.Debug.WriteLine( loadEx.LoaderExceptions[0].ToString()); MessageBox.Show("Unexpected error loading plug-ins: " + loadEx.LoaderExceptions[0].Message, Constants.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("Unexpected error loading plug-ins: " + ex.Message, Constants.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error); } if (lbAvailablePlugIns.Items.Count != 0) { lbAvailablePlugIns.SelectedIndex = 0; } else { MessageBox.Show("No valid plug-ins found", Constants.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information); gbAvailablePlugIns.Enabled = gbProjectAddIns.Enabled = false; } foreach (string key in currentConfigs.Keys) { idx = lbProjectPlugIns.Items.Add(key); lbProjectPlugIns.SetItemChecked(idx, currentConfigs[key].Enabled); } if (lbProjectPlugIns.Items.Count != 0) { lbProjectPlugIns.SelectedIndex = 0; } else { btnConfigure.Enabled = btnDelete.Enabled = false; } }
//===================================================================== /// <summary> /// Constructor /// </summary> /// <overloads>There are five overloads for the constructor</overloads> protected SandcastleProject() { characterMatchEval = new MatchEvaluator(this.OnCharacterMatch); buildVarMatchEval = new MatchEvaluator(this.OnBuildVarMatch); docSources = new DocumentationSourceCollection(this); docSources.ListChanged += docSources_ListChanged; namespaceSummaries = new NamespaceSummaryItemCollection(this); namespaceSummaries.ListChanged += ItemList_ListChanged; references = new ReferenceItemCollection(this); references.ListChanged += ItemList_ListChanged; componentConfigs = new ComponentConfigurationDictionary(this); plugInConfigs = new PlugInConfigurationDictionary(this); apiFilter = new ApiFilterCollection(this); apiFilter.ListChanged += ItemList_ListChanged; helpAttributes = new MSHelpAttrCollection(this); helpAttributes.ListChanged += ItemList_ListChanged; try { loadingProperties = removeProjectWhenDisposed = true; contentPlacement = ContentPlacement.AboveNamespaces; cleanIntermediates = keepLogFile = binaryTOC = includeStopWordList = true; this.BuildLogFile = null; missingTags = MissingTags.Summary | MissingTags.Parameter | MissingTags.TypeParameter | MissingTags.Returns | MissingTags.AutoDocumentCtors | MissingTags.Namespace | MissingTags.AutoDocumentDispose; visibleItems = VisibleItems.InheritedFrameworkMembers | VisibleItems.InheritedMembers | VisibleItems.Protected | VisibleItems.ProtectedInternalAsProtected; buildAssemblerVerbosity = BuildAssemblerVerbosity.OnlyWarningsAndErrors; helpFileFormat = HelpFileFormats.HtmlHelp1; htmlSdkLinkType = websiteSdkLinkType = HtmlSdkLinkType.Msdn; help2SdkLinkType = MSHelp2SdkLinkType.Msdn; helpViewerSdkLinkType = MSHelpViewerSdkLinkType.Msdn; sdkLinkTarget = SdkLinkTarget.Blank; presentationStyle = Constants.DefaultPresentationStyle; namingMethod = NamingMethod.Guid; syntaxFilters = ComponentUtilities.DefaultSyntaxFilter; collectionTocStyle = CollectionTocStyle.Hierarchical; helpFileVersion = "1.0.0.0"; tocOrder = -1; maximumGroupParts = 2; this.OutputPath = null; this.HtmlHelp1xCompilerPath = this.HtmlHelp2xCompilerPath = this.WorkingPath = this.ComponentPath = null; this.HelpTitle = this.HtmlHelpName = this.CopyrightHref = this.CopyrightText = this.FeedbackEMailAddress = this.FeedbackEMailLinkText = this.HeaderText = this.FooterText = this.ProjectSummary = this.RootNamespaceTitle = this.PlugInNamespaces = this.TopicVersion = this.TocParentId = this.TocParentVersion = this.CatalogProductId = this.CatalogVersion = this.CatalogName = null; this.FrameworkVersion = null; language = new CultureInfo("en-US"); } finally { loadingProperties = false; } }