forked from xps/VSTextMacros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVSTextMacrosPackage.cs
48 lines (39 loc) · 1.49 KB
/
VSTextMacrosPackage.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell;
using VSTextMacros.Model;
namespace VSTextMacros
{
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[InstalledProductRegistration("#110", "#112", "1.16", IconResourceID = 400)]
[ProvideMenuResource("Menus.ctmenu", 1)]
[Guid(GuidList.guidVSTextMacrosPkgString)]
[ProvideAutoLoad(VSConstants.UICONTEXT.NoSolution_string, PackageAutoLoadFlags.BackgroundLoad)]
public sealed class VSTextMacrosPackage : AsyncPackage
{
public static VSTextMacrosPackage Current { get; private set; }
public string MacroDirectory {
get { return Path.Combine(this.UserLocalDataPath, "Macros"); }
}
public DTE2 DTE { get; private set; }
public VSTextMacrosPackage()
{
Current = this;
}
protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
if (!Directory.Exists(MacroDirectory))
Directory.CreateDirectory(MacroDirectory);
if (File.Exists(Path.Combine(MacroDirectory, "Current.xml")))
Macro.CurrentMacro = Macro.LoadFromFile(Path.Combine(MacroDirectory, "Current.xml"));
RecordableCommands.AddFromFile(Path.Combine(MacroDirectory, "Custom.xml"));
DTE = (DTE2)await GetServiceAsync(typeof(DTE));
await base.InitializeAsync(cancellationToken, progress);
}
}
}