-
Notifications
You must be signed in to change notification settings - Fork 452
/
Copy pathTextviewCreationListener.cs
31 lines (29 loc) · 1.14 KB
/
TextviewCreationListener.cs
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
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Utilities;
using OptionsSample.Options;
namespace OptionsSample
{
[Export(typeof(IWpfTextViewCreationListener))]
[ContentType("text")]
[TextViewRole(PredefinedTextViewRoles.PrimaryDocument)]
internal class TextviewCreationListener : IWpfTextViewCreationListener
{
// This method is executed when you open any file in the editor window
public void TextViewCreated(IWpfTextView textView)
{
// Call the Instance singleton from the UI thread is easy
bool showMessage = OtherOptions.Instance.ShowMessage;
if (showMessage)
{
System.Threading.Tasks.Task.Run(async () =>
{
// Make the call to GetLiveInstanceAsync from a background thread to avoid blocking the UI thread
GeneralOptions options = await GeneralOptions.GetLiveInstanceAsync();
string message = options.Message;
// Do something with message
});
}
}
}
}