/// <summary> /// Open or show the preview topic window /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void miPreviewTopic_Click(object sender, EventArgs e) { TopicEditorWindow editor; FileItem fileItem = null; dockPanel.CheckFocusedContent(); // HACK editor = dockPanel.ActiveDocument as TopicEditorWindow; // If we are in a topic editor, show it by default when the previewer opens if(editor == null) { foreach(IDockContent document in dockPanel.Contents) { editor = document as TopicEditorWindow; if(editor != null) break; } } if(editor != null) fileItem = project.FindFile(editor.Filename); try { Cursor.Current = Cursors.WaitCursor; if(previewWindow == null) { previewWindow = new PreviewTopicWindow(); previewWindow.Show(dockPanel); } previewWindow.PreviewTopic(project, (fileItem == null) ? null : fileItem.FullPath); previewWindow.Activate(); // When the state is restored and it's a document pane, it doesn't always become the active pane // unless this is called. previewWindow.Show(dockPanel, previewWindow.DockState); } finally { Cursor.Current = Cursors.Default; } }
/// <summary> /// Open or show the preview topic window /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void miPreviewTopic_Click(object sender, EventArgs e) { TopicEditorWindow editor; FileItem fileItem; dockPanel.CheckFocusedContent(); // HACK editor = dockPanel.ActiveDocument as TopicEditorWindow; if(editor == null) { foreach(IDockContent document in dockPanel.Contents) { editor = document as TopicEditorWindow; if(editor != null) break; } if(editor == null) return; } if(!this.SaveBeforeBuild()) return; if(previewWindow == null) { previewWindow = new PreviewTopicWindow(); previewWindow.Show(dockPanel); } fileItem = project.FindFile(editor.Filename); if(fileItem != null) { // Save the editor to ensure it is current on disk. This has // to happen regardless of the BeforeBuild preference or the // content won't be current. if(!editor.Save()) return; previewWindow.PreviewTopic(project, fileItem); previewWindow.Activate(); // When the state is restored and it's a document pane, it // doesn't always become the active pane unless this is called. previewWindow.Show(dockPanel, previewWindow.DockState); } }