private void ShowToolWindow() { if (toolWindow == null) { // Get the instance number 0 of this tool window. This window is single instance so this instance // is actually the only one. // The last flag is set to true so that if the tool window does not exists it will be created. toolWindow = this.FindToolWindow(typeof(LocalHistoryToolWindow), 0, true); if ((toolWindow == null) || (toolWindow.Frame == null)) { throw new NotSupportedException(Resources.CanNotCreateWindow); } // Provide the control with the Visual Studio Difference Service to compare files LocalHistoryControl control = (LocalHistoryControl)toolWindow.Content; // TODO: remove this // BUG: This will cause a null pointer exception if no solution is open when the user opens the tool window. documentRepository.Control = control; } // Make sure the tool window is visible to the user IVsWindowFrame windowFrame = (IVsWindowFrame)toolWindow.Frame; Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show()); }
private void ClearToolWindow() { if (toolWindow != null) { // Provide the control with the Visual Studio Difference Service to compare files LocalHistoryControl control = (LocalHistoryControl)toolWindow.Content; toolWindow.Caption = "Local History"; control.LatestDocument = null; control.DocumentItems.Clear(); } }
/// <summary> /// Standard constructor for the tool window. /// </summary> public LocalHistoryToolWindow() : base(null) { // Set the window title reading it from the resources. Caption = Resources.ToolWindowTitle; // Set the image that will appear on the tab of the window frame // when docked with an other window // The resource ID correspond to the one defined in the resx file // while the Index is the offset in the bitmap strip. Each image in // the strip being 16x16. BitmapResourceID = 301; BitmapIndex = 1; // This is the user control hosted by the tool window; Note that, even if this class implements IDisposable, // we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on // the object returned by the Content property. Content = new LocalHistoryControl(); }
public void UpdateToolWindow(string filePath) { List <DocumentNode> revisions = documentRepository.GetRevisions(filePath); // Update the tool window LocalHistoryControl control = (LocalHistoryControl)toolWindow.Content; toolWindow.Caption = "Local History - " + Path.GetFileName(filePath); // Remove all revisions from the revision list that belong to the previous document control.DocumentItems.Clear(); // Add the project item and its history to the revision list control.LatestDocument = new DocumentNode(filePath, filePath, Path.GetFileName(filePath), DateTime.Now); foreach (DocumentNode revision in revisions) { control.DocumentItems.Add(revision); } }