//===================================================================== /// <summary> /// Deserialize the state of a content pane. /// </summary> /// <param name="persistString">The name of the item being deserialized</param> /// <returns>The dock content if deserialized or null if not.</returns> private IDockContent DeserializeState(string persistString) { if(persistString == typeof(ProjectExplorerWindow).FullName) return projectExplorer; if(persistString == typeof(ProjectPropertiesWindow).FullName) return projectProperties; if(persistString == typeof(OutputWindow).FullName) { if(outputWindow == null) outputWindow = new OutputWindow(); return outputWindow; } if(persistString == typeof(EntityReferenceWindow).FullName) { if(entityReferencesWindow == null) { entityReferencesWindow = new EntityReferenceWindow(); entityReferencesWindow.CurrentProject = project; } return entityReferencesWindow; } // Ignore the preview window if(persistString == typeof(PreviewTopicWindow).FullName) return null; string[] parsedStrings = persistString.Split(new char[] { ',' }); if(projectExplorer == null || parsedStrings.Length != 2 || parsedStrings[1].Length == 0) return null; // Try for a built-in editor return projectExplorer.CreateFileEditor(parsedStrings[1], null); }
/// <summary> /// View the output from the last build /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void miViewOutput_Click(object sender, EventArgs e) { string lastBuildLog = null; if(outputWindow == null) { outputWindow = new OutputWindow(); outputWindow.Show(dockPanel); } if(project != null) { // Make sure we start out in the project's output folder // in case the output folder is relative to it. Directory.SetCurrentDirectory(Path.GetDirectoryName( Path.GetFullPath(project.Filename))); lastBuildLog = project.LogFileLocation; } if(sender == miViewLog) outputWindow.ViewLogFile(lastBuildLog); else { // Set the log file so that the user can switch to it if(!File.Exists(lastBuildLog)) outputWindow.LogFile = null; else outputWindow.LogFile = lastBuildLog; outputWindow.ViewBuildOutput(); } }
//===================================================================== /// <summary> /// Deserialize the state of a content pane. /// </summary> /// <param name="persistString">The name of the item being deserialized</param> /// <returns>The dock content if deserialized or null if not.</returns> private IDockContent DeserializeState(string persistString) { if(persistString == typeof(ProjectExplorerWindow).FullName) return projectExplorer; if(persistString == typeof(ProjectPropertiesWindow).FullName) return projectProperties; if(persistString == typeof(OutputWindow).FullName) { outputWindow = new OutputWindow(); return outputWindow; } if(persistString == typeof(EntityReferenceWindow).FullName) { entityReferencesWindow = new EntityReferenceWindow(tsslStatusText); return entityReferencesWindow; } if(persistString == typeof(PreviewTopicWindow).FullName) { previewWindow = new PreviewTopicWindow(); return previewWindow; } return null; }
//===================================================================== /// <summary> /// Clear the last build information from the output window /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void miClearOutput_Click(object sender, EventArgs e) { if(outputWindow != null) { if(sender == miClearOutput || sender == miBuildProject) outputWindow.Activate(); outputWindow.ResetLogViewer(); } else if(sender == miClearOutput || sender == miBuildProject) { outputWindow = new OutputWindow(); outputWindow.Show(dockPanel); } }
/// <summary> /// When the build finishes, load the topic if it was built /// successfully or view the log if the build failed. /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> /// <remarks>We have to wait for the thread to finish before we can /// view the log file so we use a timer event to wait for it.</remarks> private void timer_Tick(object sender, EventArgs e) { TopicFile topicFile; string path = null; string[] files; if (buildThread != null && !buildThread.IsAlive) { timer.Stop(); // If successful, preview the built topic if (lastBuildStep == BuildStep.Completed) { // If it's a MAML topic or an HTML file with an ID, use // the ID for the name. topicFile = new TopicFile(fileItem); if (!String.IsNullOrEmpty(topicFile.Id)) { path = String.Concat(buildProcess.WorkingFolder, @"Output\Website\html\", topicFile.Id, ".htm"); } else { // If not, try to find it by name files = Directory.GetFiles(buildProcess.WorkingFolder + @"Output\Website\", Path.GetFileNameWithoutExtension( fileItem.Name) + ".htm?", SearchOption.AllDirectories); if (files.Length != 0) { path = files[0]; } else { path = fileItem.FullPath; } } if (File.Exists(path)) { wbPreview.Navigate(path); } else { wbPreview.DocumentText = "Unable to locate built " + "topic file: " + path + "<br/><br/>Does the " + "project contain a content layout file with a " + "<b>BuildAction</b> of <b>ContentLayout</b>?"; } } else { wbPreview.DocumentText = OutputWindow.TransformLogFile( buildProcess.LogFilename, Settings.Default.FilterBuildLog); } pbWait.Visible = lblLoading.Visible = false; buildThread = null; buildProcess = null; } }