//===================================================================== /// <summary> /// This is used to get the current component 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 ucComponentPropertiesPageContent_ComponentSettingsNeeded(object sender, ComponentSettingsNeededEventArgs e) { ProjectProperty componentsProp; #if !STANDALONEGUI if (this.IsDisposed || this.ProjectMgr == null) { return; } componentsProp = this.ProjectMgr.BuildProject.GetProperty("ComponentConfigurations"); #else if (this.IsDisposed || this.CurrentProject == null) { return; } componentsProp = this.CurrentProject.MSBuildProject.GetProperty("ComponentConfigurations"); #endif var currentConfigs = new ComponentConfigurationDictionary(); if (componentsProp != null && !String.IsNullOrEmpty(componentsProp.UnevaluatedValue)) { currentConfigs.FromXml(componentsProp.UnevaluatedValue); } e.ProjectLoaded = true; e.Components = currentConfigs; }
/// <inheritdoc /> public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { ComponentConfigurationDictionary items = value as ComponentConfigurationDictionary; int disabled = 0; if (items == null || destinationType != typeof(string)) { return(base.ConvertTo(context, culture, value, destinationType)); } if (items.Count == 0) { return("(None)"); } foreach (BuildComponentConfiguration bcc in items.Values) { if (!bcc.Enabled) { disabled++; } } if (disabled == 0) { return(String.Format(culture, "{0} custom build component(s)", items.Count)); } return(String.Format(culture, "{0} custom build component(s), " + "{1} disabled", items.Count, disabled)); }
//===================================================================== // Methods, etc. /// <summary> /// Constructor /// </summary> /// <param name="configs">The current configurations</param> internal ComponentConfigurationEditorDlg( ComponentConfigurationDictionary configs) { int idx; InitializeComponent(); currentConfigs = configs; try { // Show all but the hidden components foreach (string key in BuildComponentManager.BuildComponents.Keys) { if (!BuildComponentManager.BuildComponents[key].IsHidden) { lbAvailableComponents.Items.Add(key); } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("Unexpected error loading build components: " + ex.Message, Constants.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error); } if (lbAvailableComponents.Items.Count != 0) { lbAvailableComponents.SelectedIndex = 0; } else { MessageBox.Show("No valid build components found", Constants.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information); gbAvailableComponents.Enabled = gbProjectAddIns.Enabled = false; } foreach (string key in currentConfigs.Keys) { idx = lbProjectComponents.Items.Add(key); lbProjectComponents.SetItemChecked(idx, currentConfigs[key].Enabled); } if (lbProjectComponents.Items.Count != 0) { lbProjectComponents.SelectedIndex = 0; } else { btnConfigure.Enabled = btnDelete.Enabled = false; } }
//===================================================================== // Methods, etc. /// <summary> /// Constructor /// </summary> /// <param name="configs">The current configurations</param> internal ComponentConfigurationEditorDlg( ComponentConfigurationDictionary configs) { int idx; InitializeComponent(); currentConfigs = configs; try { // Show all but the hidden components foreach(string key in BuildComponentManager.BuildComponents.Keys) if(!BuildComponentManager.BuildComponents[key].IsHidden) lbAvailableComponents.Items.Add(key); } catch(Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("Unexpected error loading build components: " + ex.Message, Constants.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error); } if(lbAvailableComponents.Items.Count != 0) lbAvailableComponents.SelectedIndex = 0; else { MessageBox.Show("No valid build components found", Constants.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information); gbAvailableComponents.Enabled = gbProjectAddIns.Enabled = false; } foreach(string key in currentConfigs.Keys) { idx = lbProjectComponents.Items.Add(key); lbProjectComponents.SetItemChecked(idx, currentConfigs[key].Enabled); } if(lbProjectComponents.Items.Count != 0) lbProjectComponents.SelectedIndex = 0; else btnConfigure.Enabled = btnDelete.Enabled = false; }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { // Get the component configuration dictionary ComponentConfigurationDictionary items = value as ComponentConfigurationDictionary; if (context == null || provider == null || context.Instance == null || items == null) { return(base.EditValue(context, provider, value)); } using (ComponentConfigurationEditorDlg dlg = new ComponentConfigurationEditorDlg(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> componentIds = new HashSet <string>(); try { Mouse.OverrideCursor = Cursors.Wait; lbAvailableComponents.Items.Clear(); lbProjectComponents.Items.Clear(); availableComponents = componentCache.ComponentContainer.GetExports <BuildComponentFactory, IBuildComponentMetadata>().ToList(); availableConfigEditors = componentCache.ComponentContainer.GetExports <IConfigurationEditor, IConfigurationEditorMetadata>().ToList(); // Only load those that indicate that they are visible to the property page. 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. foreach (var component in availableComponents) { if (!componentIds.Contains(component.Metadata.Id) && component.Metadata.IsVisible) { lbAvailableComponents.Items.Add(component.Metadata.Id); componentIds.Add(component.Metadata.Id); } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("Unexpected error loading build components: " + ex.Message, Constants.AppName, MessageBoxButton.OK, MessageBoxImage.Error); } finally { lbAvailableComponents.Items.Refresh(); Mouse.OverrideCursor = null; } if (projectSettings.ProjectLoaded) { if (lbAvailableComponents.Items.Count != 0) { lbAvailableComponents.SelectedIndex = 0; gbAvailableComponents.IsEnabled = gbProjectComponents.IsEnabled = true; } else { MessageBox.Show("No valid build components found", Constants.AppName, MessageBoxButton.OK, MessageBoxImage.Information); gbAvailableComponents.IsEnabled = gbProjectComponents.IsEnabled = false; return; } this.SelectedComponents = projectSettings.Components; foreach (var kv in this.SelectedComponents) { lbProjectComponents.Items.Add(new ComponentConfig { Name = kv.Key, Configuration = kv.Value }); } if (lbProjectComponents.Items.Count != 0) { lbProjectComponents.Items.Refresh(); lbProjectComponents.SelectedIndex = 0; btnDelete.IsEnabled = true; } else { btnConfigure.IsEnabled = btnDelete.IsEnabled = false; } } }
/// <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; } lbAvailableComponents.Items.Clear(); HashSet <string> componentIds = new HashSet <string>(); try { Cursor.Current = Cursors.WaitCursor; lbProjectComponents.Items.Clear(); availableComponents = componentCache.ComponentContainer.GetExports <BuildComponentFactory, IBuildComponentMetadata>().ToList(); // Only load those that indicate that they are visible to the property page. 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. foreach (var component in availableComponents) { if (!componentIds.Contains(component.Metadata.Id) && component.Metadata.IsVisible) { lbAvailableComponents.Items.Add(component.Metadata.Id); componentIds.Add(component.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 (lbAvailableComponents.Items.Count != 0) { lbAvailableComponents.SelectedIndex = 0; gbAvailableComponents.Enabled = gbProjectAddIns.Enabled = true; } else { MessageBox.Show("No valid build components found", messageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); gbAvailableComponents.Enabled = gbProjectAddIns.Enabled = false; return; } #if !STANDALONEGUI if (this.ProjectMgr == null) { return; } projProp = this.ProjectMgr.BuildProject.GetProperty("ComponentConfigurations"); #else if (this.CurrentProject == null) { return; } projProp = this.CurrentProject.MSBuildProject.GetProperty("ComponentConfigurations"); #endif currentConfigs = new ComponentConfigurationDictionary(); 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 = lbProjectComponents.Items.Add(key); lbProjectComponents.SetItemChecked(idx, currentConfigs[key].Enabled); } if (lbProjectComponents.Items.Count != 0) { lbProjectComponents.SelectedIndex = 0; btnConfigure.Enabled = btnDelete.Enabled = true; } else { btnConfigure.Enabled = btnDelete.Enabled = false; } } finally { this.IsBinding = isBinding; } }
//===================================================================== /// <inheritdoc /> protected override bool BindControlValue(Control control) { ProjectProperty projProp; int idx; lbProjectComponents.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.LoadAvailableBuildComponentMetadata(); } if (this.ProjectMgr == null || currentProject == null) { return(false); } projProp = this.ProjectMgr.BuildProject.GetProperty("ComponentConfigurations"); #else if (componentContainer == null || base.CurrentProject == null || base.CurrentProject.Filename != lastProjectName) { this.LoadAvailableBuildComponentMetadata(); } if (base.CurrentProject == null) { return(false); } projProp = base.CurrentProject.MSBuildProject.GetProperty("ComponentConfigurations"); #endif currentConfigs = new ComponentConfigurationDictionary(); if (projProp != null && !String.IsNullOrEmpty(projProp.UnevaluatedValue)) { currentConfigs.FromXml(projProp.UnevaluatedValue); } foreach (string key in currentConfigs.Keys) { idx = lbProjectComponents.Items.Add(key); lbProjectComponents.SetItemChecked(idx, currentConfigs[key].Enabled); } if (lbProjectComponents.Items.Count != 0) { lbProjectComponents.SelectedIndex = 0; btnConfigure.Enabled = btnDelete.Enabled = true; } return(true); }
//===================================================================== // Methods, etc. /// <summary> /// Constructor /// </summary> /// <param name="configs">The current configurations</param> internal ComponentConfigurationEditorDlg( ComponentConfigurationDictionary configs) { string id; InitializeComponent(); // Figure out where Sandcastle is if not done specified if (sandcastlePath == null) { Match m = Regex.Match(Environment.GetEnvironmentVariable("PATH"), @"[A-Z]:\\.[^;]+\\Sandcastle(?=\\Prod)", RegexOptions.IgnoreCase); // If not found in the path, search all fixed drives if (m.Success) { sandcastlePath = m.Value; } else { sandcastlePath = BuildProcess.FindOnFixedDrives( @"\Sandcastle"); // If not found there, try the VS 2005 SDK folders if (sandcastlePath.Length == 0) { sandcastlePath = BuildProcess.FindSdkExecutable( "MRefBuilder.exe"); if (sandcastlePath.Length != 0) { sandcastlePath = sandcastlePath.Substring(0, sandcastlePath.LastIndexOf('\\')); } else { MessageBox.Show("Unable to locate Sandcastle " + "installation folder. Please set the " + "SandcastlePath project property.", "Sandcastle Help File Builder", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } boldFont = new Font(this.Font, FontStyle.Bold); currentConfigs = configs; Assembly asm = Assembly.GetEntryAssembly(); shfbFolder = Path.GetDirectoryName(asm.Location) + @"\"; configFile = new XmlDocument(); configFile.Load(shfbFolder + @"Templates\sandcastle.config"); // Get all configurable items (those with an ID) foreach (XmlNode n in configFile.SelectNodes( "//component[string-length(@id) != 0]")) { id = n.Attributes["id"].Value; if (!lbComponents.Items.Contains(id)) { lbComponents.Items.Add(id); } else { MessageBox.Show("The component with ID '" + id + "' is defined more than once. Duplicates " + "will be ignored.", "Sandcastle Help File Builder", MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (lbComponents.Items.Count != 0) { lbComponents.SelectedIndex = 0; } else { MessageBox.Show("No configurable components found", "Sandcastle Help File Builder", MessageBoxButtons.OK, MessageBoxIcon.Information); btnConfigure.Enabled = false; } }
//===================================================================== /// <inheritdoc /> protected override bool BindControlValue(Control control) { ProjectProperty projProp; int idx; lbProjectComponents.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.LoadAvailableBuildComponentMetadata(); if(this.ProjectMgr == null || currentProject == null) return false; projProp = this.ProjectMgr.BuildProject.GetProperty("ComponentConfigurations"); #else if(componentContainer == null || base.CurrentProject == null || base.CurrentProject.Filename != lastProjectName) this.LoadAvailableBuildComponentMetadata(); if(base.CurrentProject == null) return false; projProp = base.CurrentProject.MSBuildProject.GetProperty("ComponentConfigurations"); #endif currentConfigs = new ComponentConfigurationDictionary(); if(projProp != null && !String.IsNullOrEmpty(projProp.UnevaluatedValue)) currentConfigs.FromXml(projProp.UnevaluatedValue); foreach(string key in currentConfigs.Keys) { idx = lbProjectComponents.Items.Add(key); lbProjectComponents.SetItemChecked(idx, currentConfigs[key].Enabled); } if(lbProjectComponents.Items.Count != 0) { lbProjectComponents.SelectedIndex = 0; btnConfigure.Enabled = btnDelete.Enabled = true; } return true; }
//===================================================================== /// <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; } }
/// <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; lbAvailableComponents.Items.Clear(); HashSet<string> componentIds = new HashSet<string>(); try { Cursor.Current = Cursors.WaitCursor; lbProjectComponents.Items.Clear(); availableComponents = componentCache.ComponentContainer.GetExports<BuildComponentFactory, IBuildComponentMetadata>().ToList(); // Only load those that indicate that they are visible to the property page. 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. foreach(var component in availableComponents) if(!componentIds.Contains(component.Metadata.Id) && component.Metadata.IsVisible) { lbAvailableComponents.Items.Add(component.Metadata.Id); componentIds.Add(component.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(lbAvailableComponents.Items.Count != 0) { lbAvailableComponents.SelectedIndex = 0; gbAvailableComponents.Enabled = gbProjectAddIns.Enabled = true; } else { MessageBox.Show("No valid build components found", messageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); gbAvailableComponents.Enabled = gbProjectAddIns.Enabled = false; return; } #if !STANDALONEGUI if(this.ProjectMgr == null) return; projProp = this.ProjectMgr.BuildProject.GetProperty("ComponentConfigurations"); #else if(this.CurrentProject == null) return; projProp = this.CurrentProject.MSBuildProject.GetProperty("ComponentConfigurations"); #endif currentConfigs = new ComponentConfigurationDictionary(); 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 = lbProjectComponents.Items.Add(key); lbProjectComponents.SetItemChecked(idx, currentConfigs[key].Enabled); } if(lbProjectComponents.Items.Count != 0) { lbProjectComponents.SelectedIndex = 0; btnConfigure.Enabled = btnDelete.Enabled = true; } else btnConfigure.Enabled = btnDelete.Enabled = false; } finally { this.IsBinding = isBinding; } }