diff --git a/VisualDump/Commands/BaseCommand.cs b/VisualDump/Commands/BaseCommand.cs deleted file mode 100644 index df902cb..0000000 --- a/VisualDump/Commands/BaseCommand.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using Microsoft.VisualStudio.Shell; -using System.ComponentModel.Design; -using Task = System.Threading.Tasks.Task; - -namespace VisualDump.Commands -{ - public abstract class BaseCommand where T : BaseCommand, new() - { - #region Var - public string Text - { - get => Command.Text; - set => ChangeText(value); - } - public static T Instance { get; private set; } - public AsyncPackage Package { get; private set; } - public static int CommandID { get; internal set; } - public static Guid CommandSet { get; internal set; } - protected IServiceProvider ServiceProvider => Package; - protected OleMenuCommand Command { get; private set; } - protected OleMenuCommandService Service { get; private set; } - protected IAsyncServiceProvider AsyncServiceProvider => Package; - #endregion - - #region Init - public static async Task InitializeAsync(AsyncPackage Package) - { - Instance = new T(); - Instance.Init(Package, await Package.GetServiceAsync((typeof(IMenuCommandService))) as OleMenuCommandService); - } - protected virtual void BeforeInit() { } - private void Init(AsyncPackage Package, OleMenuCommandService CommandService) - { - BeforeInit(); - this.Package = Package ?? throw new ArgumentNullException(nameof(Package)); - Service = CommandService ?? throw new ArgumentNullException(nameof(CommandService)); - Command = new OleMenuCommand((sender, e) => { ThreadHelper.ThrowIfNotOnUIThread(); Execute((OleMenuCommand)sender); }, new CommandID(CommandSet, CommandID)); - Service.AddCommand(Command); - AfterInit(); - } - protected virtual void AfterInit() { } - #endregion - - #region Functions - protected abstract void Execute(OleMenuCommand Button); - - private void ChangeText(string NewText) - { - if (ServiceProvider.GetService(typeof(IMenuCommandService)) is OleMenuCommandService commandService) - { - commandService.RemoveCommand(Command); - void change(object sender, EventArgs e) - { - OleMenuCommand command = (OleMenuCommand)sender; - command.Text = NewText; - command.BeforeQueryStatus -= change; - } - Command.BeforeQueryStatus += change; - commandService.AddCommand(Command); - } - } - #endregion - } -} diff --git a/VisualDump/Commands/ShowDumpWindowCommand.cs b/VisualDump/Commands/ShowDumpWindowCommand.cs index 381b3c9..8ec25b2 100644 --- a/VisualDump/Commands/ShowDumpWindowCommand.cs +++ b/VisualDump/Commands/ShowDumpWindowCommand.cs @@ -1,20 +1,11 @@ -using System; +using KE.VSIX.Commands; using Microsoft.VisualStudio.Shell; namespace VisualDump.Commands { + [CommandID("e3161eb3-4aec-49de-bfe6-2eb5a01a0c34", 0x0100)] public sealed class ShowDumpWindowCommand : BaseCommand { - #region Init - static ShowDumpWindowCommand() - { - CommandID = 0x0100; - CommandSet = new Guid("e3161eb3-4aec-49de-bfe6-2eb5a01a0c34"); - } - #endregion - - #region Functions protected override void Execute(OleMenuCommand Button) => VSPackage.ShowToolWindow(typeof(Controls.VisualDump)); - #endregion } } diff --git a/VisualDump/Controls/Options/OptionContainer.cs b/VisualDump/Controls/Options/OptionContainer.cs index b530ca1..fd05c1a 100644 --- a/VisualDump/Controls/Options/OptionContainer.cs +++ b/VisualDump/Controls/Options/OptionContainer.cs @@ -19,11 +19,11 @@ public class OptionContainer #region Init public static async Task InitializeAsync() => await Task.Run(() => { - ThemesPath = Path.Combine(VSPackage.Path, "Themes\\"); + ThemesPath = VSPackage.PathData.MapPath("Themes"); if (!Directory.Exists(ThemesPath)) Directory.CreateDirectory(ThemesPath); - DefaultThemesPath = Path.Combine(VSPackage.AssemblyPath, "DefaultThemes\\"); - Settings = Settings.Read(SettingsPath = Path.Combine(VSPackage.Path, "settings.xml")); + DefaultThemesPath = Path.Combine(VSPackage.PathData.DllLocation, "DefaultThemes"); + Settings = Settings.Read(SettingsPath = VSPackage.PathData.MapPath("settings.xml")); LoadThemes(); }); #endregion @@ -34,10 +34,10 @@ public static Theme[] LoadThemes() Theme[] themes = Theme.LoadThemes(ThemesPath).ToArray(); if (themes.Length == 0) { - foreach (string dirPath in Directory.GetDirectories(DefaultThemesPath, "*", SearchOption.AllDirectories)) + foreach (string dirPath in Directory.EnumerateDirectories(DefaultThemesPath, "*", SearchOption.AllDirectories)) Directory.CreateDirectory(dirPath.Replace(DefaultThemesPath, ThemesPath)); - foreach (string newPath in Directory.GetFiles(DefaultThemesPath, "*.*", SearchOption.AllDirectories)) + foreach (string newPath in Directory.EnumerateFiles(DefaultThemesPath, "*.*", SearchOption.AllDirectories)) File.Copy(newPath, newPath.Replace(DefaultThemesPath, ThemesPath), true); themes = Theme.LoadThemes(ThemesPath).ToArray(); diff --git a/VisualDump/Images/VSPackageIcon128x128.png b/VisualDump/Images/VSPackageIcon128x128.png new file mode 100644 index 0000000..d46a9d1 Binary files /dev/null and b/VisualDump/Images/VSPackageIcon128x128.png differ diff --git a/VisualDump/Images/VSPackageIcon256x256.png b/VisualDump/Images/VSPackageIcon256x256.png new file mode 100644 index 0000000..ce6d98a Binary files /dev/null and b/VisualDump/Images/VSPackageIcon256x256.png differ diff --git a/VisualDump/Properties/AssemblyInfo.cs b/VisualDump/Properties/AssemblyInfo.cs index b53f381..8635720 100644 --- a/VisualDump/Properties/AssemblyInfo.cs +++ b/VisualDump/Properties/AssemblyInfo.cs @@ -1,33 +1,13 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. [assembly: AssemblyTitle("VisualDump")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] [assembly: AssemblyProduct("VisualDump")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] +[assembly: AssemblyCompany("Kir_Antipov")] +[assembly: AssemblyCopyright("Kir_Antipov © 2019")] +[assembly: AssemblyDescription("This extension allows you to view a visual dump of your objects during the debugging of the program in Visual Studio")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("2.1.0.0")] +[assembly: AssemblyFileVersion("2.1.0.0")] diff --git a/VisualDump/VSHelpers/NuGetListener.cs b/VisualDump/VSHelpers/NuGetListener.cs index f06daef..036c00f 100644 --- a/VisualDump/VSHelpers/NuGetListener.cs +++ b/VisualDump/VSHelpers/NuGetListener.cs @@ -68,7 +68,7 @@ private static void AddReference(Project Project, int Wait, int TryIndex) } private static void AddOnlineReferece(Project Project) => VSPackage.PackageInstaller.InstallPackage(NuGetAPI, Project, NuGet, NuGetVersionString, false); - private static void AddOfflineReferece(Project Project) => VSPackage.PackageInstaller.InstallPackage(VSPackage.AssemblyPath, Project, NuGet, NuGetVersionString, false); + private static void AddOfflineReferece(Project Project) => VSPackage.PackageInstaller.InstallPackage(VSPackage.PathData.DllLocation, Project, NuGet, NuGetVersionString, false); #endregion } } diff --git a/VisualDump/VSPackage.cs b/VisualDump/VSPackage.cs index 61f6aac..d1cbfb6 100644 --- a/VisualDump/VSPackage.cs +++ b/VisualDump/VSPackage.cs @@ -1,5 +1,6 @@ using EnvDTE; using System; +using KE.VSIX; using System.Threading; using NuGet.VisualStudio; using VisualDump.Controls; @@ -28,25 +29,15 @@ namespace VisualDump public sealed partial class VSPackage : AsyncPackage { #region Var - public static string Path { get; } - public static string AssemblyPath { get; } public static DTE DTE { get; private set; } public static VSPackage Instance { get; private set; } public static IVsPackageInstaller PackageInstaller { get; private set; } - public static Guid Guid { get; } = new Guid(PackageGuidString); public const string PackageGuidString = "bf22b5f8-9ec7-4810-880d-8d2bec2b68af"; + public static PathContainer PathData { get; } = PackageHelper.Initialize(); public static OptionControl OptionPage => (Instance.GetDialogPage(typeof(OptionPageGrid)) as OptionPageGrid)?.OptionControl; #endregion #region Init - static VSPackage() - { - Path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "VisualDump\\"); - if (!System.IO.Directory.Exists(Path)) - System.IO.Directory.CreateDirectory(Path); - AssemblyPath = System.IO.Path.GetDirectoryName(new Uri(typeof(VSPackage).Assembly.CodeBase, UriKind.Absolute).LocalPath); - } - protected override async Task InitializeAsync(CancellationToken CancellationToken, IProgress Progress) { await JoinableTaskFactory.SwitchToMainThreadAsync(CancellationToken); diff --git a/VisualDump/VisualDump.csproj b/VisualDump/VisualDump.csproj index 46acaa1..6ff85a7 100644 --- a/VisualDump/VisualDump.csproj +++ b/VisualDump/VisualDump.csproj @@ -58,7 +58,6 @@ 7.3 - UserControl @@ -146,6 +145,14 @@ Always true + + Always + true + + + Always + true + Always true @@ -173,6 +180,9 @@ False + + ..\packages\KE.VSIX.1.2.0\lib\net47\KE.VSIX.dll + @@ -180,7 +190,9 @@ - + + ..\packages\Microsoft.VisualStudio.Shell.15.0.15.9.28307\lib\net45\Microsoft.VisualStudio.Shell.15.0.dll + @@ -228,6 +240,7 @@ True True + ..\packages\System.Net.Http.4.3.3\lib\net46\System.Net.Http.dll True diff --git a/VisualDump/app.config b/VisualDump/app.config index c9e4df7..dbd6e12 100644 --- a/VisualDump/app.config +++ b/VisualDump/app.config @@ -12,7 +12,7 @@ - + @@ -50,6 +50,10 @@ + + + + diff --git a/VisualDump/packages.config b/VisualDump/packages.config index 0d36ca7..78a5f24 100644 --- a/VisualDump/packages.config +++ b/VisualDump/packages.config @@ -2,6 +2,7 @@ + @@ -10,7 +11,7 @@ - + diff --git a/VisualDump/source.extension.vsixmanifest b/VisualDump/source.extension.vsixmanifest index 2d4926c..5ab858f 100644 --- a/VisualDump/source.extension.vsixmanifest +++ b/VisualDump/source.extension.vsixmanifest @@ -1,11 +1,11 @@ - + Visual Dump This extension allows you to view a visual dump of your objects during the debugging of the program in Visual Studio - Images\VSPackageIcon.ico - Images\VSPackageIcon.ico + Images\VSPackageIcon256x256.png + Images\VSPackageIcon128x128.png Visual Dump, VisualDump, Dump, Dumping, LINQPad