-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommentDetailsWindow.cs
More file actions
60 lines (53 loc) · 1.77 KB
/
CommentDetailsWindow.cs
File metadata and controls
60 lines (53 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using Microsoft.VisualStudio.Shell;
using System;
using System.Runtime.InteropServices;
namespace ConsoleCompare
{
[Guid("d0925d87-0fdd-4a9e-bf73-ed0e4082aadf")]
internal class CommentDetailsWindow : ToolWindowPane
{
/// <summary>
/// The window control that has window elements
/// </summary>
private CommentDetailsControl windowControl;
/// <summary>
/// Creates a new comment details window
/// </summary>
public CommentDetailsWindow() : base(null)
{
this.windowControl = new CommentDetailsControl();
this.Content = windowControl;
}
/// <summary>
/// Sets the text of the comment details text box
/// </summary>
/// <param name="commentDetails">Details to display in the window</param>
public void SetCommentDetails(string commentDetails)
{
windowControl.TextCommentDetails.Text = commentDetails;
}
/// <summary>
/// Static helper to open the comment details window
/// </summary>
/// <param name="commentDetails">Comment details to display</param>
public static void OpenWindow(string commentDetails)
{
ThreadHelper.ThrowIfNotOnUIThread();
// Grab the overall package for our extension
AsyncPackage package = Command.Instance.ServiceProviderPackage;
if (package == null)
return;
// Perform an async show/create and set the details if possible
_ = package.JoinableTaskFactory.RunAsync(async delegate
{
ToolWindowPane window = await package.ShowToolWindowAsync(typeof(CommentDetailsWindow), 0, true, package.DisposalToken);
if ((null == window) || (null == window.Frame))
{
throw new NotSupportedException("Cannot create comment details window");
}
// Window create/show was successful, so update details
(window as CommentDetailsWindow)?.SetCommentDetails(commentDetails);
});
}
}
}