Skip to content

Commit

Permalink
Seems like toolwindow is working properly
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKert committed Apr 6, 2019
1 parent fc16b7e commit afb62ac
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
35 changes: 23 additions & 12 deletions src/BuildVision/Core/BuildVisionPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
namespace BuildVision.Core
{
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[ProvideAutoLoad(UIContextGuids80.SolutionExists)]
[ProvideAutoLoad(ui.SolutionOpening_string, flags: PackageAutoLoadFlags.BackgroundLoad)]
[ProvideToolWindow(typeof(BuildVisionPane))]
[ProvideToolWindow(typeof(BuildVisionPane), Transient = true, MultiInstances = false)]
[ProvideToolWindowVisibility(typeof(BuildVisionPane), ui.SolutionOpening_string)]
[ProvideMenuResource("Menus.ctmenu", 1)]
[ProvideToolWindow(typeof(BuildVisionPane))]
[Guid(PackageGuids.GuidBuildVisionPackageString)]
[ProvideBindingPath]
[ProvideBindingPath(SubPath = "Lib")]
Expand All @@ -41,7 +43,7 @@ namespace BuildVision.Core
[ProvideOptionPage(typeof(GridSettingsDialogPage), "BuildVision", "Projects Grid", 0, 0, true)]
[ProvideOptionPage(typeof(BuildMessagesSettingsDialogPage), "BuildVision", "Build Messages", 0, 0, true)]
[ProvideOptionPage(typeof(ProjectItemSettingsDialogPage), "BuildVision", "Project Item", 0, 0, true)]
public sealed class BuildVisionPackage : AsyncPackage
public sealed class BuildVisionPackage : AsyncPackage, IVsPackageDynamicToolOwnerEx
{
private const string _loadContext = "dec9f70a-b8b1-4050-ae96-08f89c6eccd1";

Expand All @@ -59,6 +61,8 @@ public sealed class BuildVisionPackage : AsyncPackage
private ISolutionProvider _solutionProvider;
private Window _activeProjectContext;

public static ToolWindowPane ToolWindowPane { get; set; }


public ControlSettings ControlSettings { get; set; }

Expand Down Expand Up @@ -113,7 +117,7 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
SolutionEvents_Opened();
}

InitToolWindow(this);
//InitToolWindow(this);
}

private void SolutionEvents_Opened()
Expand Down Expand Up @@ -175,15 +179,22 @@ private void CommandEvents_AfterExecute(string guid, int id, object customIn, ob
}
}

public static void InitToolWindow(AsyncPackage package)
public int QueryShowTool(ref Guid rguidPersistenceSlot, uint dwId, out int pfShowTool)
{
package.JoinableTaskFactory.RunAsync(async () =>
{
var window = package.FindToolWindow(typeof(BuildVisionPane), 0, false) ?? package.FindToolWindow(typeof(BuildVisionPane), 0, true);
var windowStateService = await package.GetServiceAsync(typeof(IWindowStateService)) as IWindowStateService;
Assumes.Present(windowStateService);
windowStateService.Initialize(window);
});
ToolWindowPane = FindToolWindow(typeof(BuildVisionPane), 0, false) ?? FindToolWindow(typeof(BuildVisionPane), 0, true);
pfShowTool = 1;
return 0;
}

//public static void InitToolWindow(AsyncPackage package)
//{
// package.JoinableTaskFactory.RunAsync(async () =>
// {
// var window = package.FindToolWindow(typeof(BuildVisionPane), 0, false) ?? package.FindToolWindow(typeof(BuildVisionPane), 0, true);
// var windowStateService = await package.GetServiceAsync(typeof(IWindowStateService)) as IWindowStateService;
// Assumes.Present(windowStateService);
// windowStateService.Initialize(window);
// });
//}
}
}
11 changes: 10 additions & 1 deletion src/BuildVision/Services/WindowStateService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel.Composition;
using BuildVision.Core;
using BuildVision.UI.Settings.Models.ToolWindow;
using EnvDTE;
using Microsoft;
Expand All @@ -11,7 +12,7 @@
namespace BuildVision.Tool.Building
{
[Export(typeof(IWindowStateService))]
[PartCreationPolicy(CreationPolicy.Shared)]
[PartCreationPolicy(CreationPolicy.NonShared)]
public class WindowStateService : IWindowStateService
{
private DTE _dte;
Expand Down Expand Up @@ -127,6 +128,8 @@ private void ApplyToolWindowStateAction(WindowState windowState)

public void Initialize(ToolWindowPane toolWindowPane)
{
if (toolWindowPane == null)
return;
if (_window == null || _windowFrame == null)
{
ThreadHelper.ThrowIfNotOnUIThread();
Expand All @@ -141,6 +144,12 @@ public void Initialize(ToolWindowPane toolWindowPane)

public void ApplyToolWindowStateAction(WindowStateAction windowStateAction)
{
if(BuildVisionPackage.ToolWindowPane == null)
{
return;
}
Initialize(BuildVisionPackage.ToolWindowPane);

ApplyToolWindowStateAction(windowStateAction.State);
}
}
Expand Down

0 comments on commit afb62ac

Please sign in to comment.