Skip to content

Commit

Permalink
Added back most of the ermoved functionalities
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKert committed Mar 23, 2019
1 parent 06bf033 commit 6d18526
Show file tree
Hide file tree
Showing 22 changed files with 535 additions and 320 deletions.
2 changes: 2 additions & 0 deletions src/BuildVision.Contracts/Models/IBuildInformationModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.ComponentModel;
using System.Windows.Controls;
using BuildVision.UI.Models;

namespace BuildVision.Contracts.Models
{
Expand All @@ -22,5 +23,6 @@ public interface IBuildInformationModel : INotifyPropertyChanged

BuildResultState ResultState { get; }
string StateIconKey { get; }
IProjectItem CurrentProject { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public interface IBuildProgressViewModel
bool ActionProgressIsPaused { get; set; }
int CurrentQueuePosOfBuildingProject { get; }

void OnBuildBegin(int projectsCount);
void OnBuildBegin(IBuildInformationModel buildInformationModel, int projectsCount);
void OnBuildCancelled();
void OnBuildDone();
void OnBuildProjectBegin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ namespace BuildVision.Exports.Providers
{
public interface IBuildInformationProvider
{
void BuildFinished(bool success, bool modified, bool canceled);
void BuildFinished(bool success, bool canceled);
void BuildStarted(uint dwAction);
void BuildUpdate();
void ResetBuildInformationModel();
IBuildInformationModel GetBuildInformationModel();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public interface IBuildingProjectsProvider
void ProjectBuildStarted(IProjectItem projectItem, uint dwAction);
void ProjectBuildFinished(string projectIdentifier, bool succeess, bool canceled);
void ReloadCurrentProjects();
void ResetCurrentProjects();
bool TryGetProjectItem(BuildProjectContextEntry projectEntry, out IProjectItem projectItem);
}
}
1 change: 0 additions & 1 deletion src/BuildVision.UI/BuildVision.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@
</Compile>
<Compile Include="Models\BuildInformationModel.cs" />
<Compile Include="Models\SolutionModel.cs" />
<Compile Include="ViewModels\BuildProgressViewModel.cs" />
<Compile Include="ViewModels\BuildVisionPaneViewModel.cs" />
<Compile Include="Settings\Models\WindowSettings.cs" />
</ItemGroup>
Expand Down
42 changes: 10 additions & 32 deletions src/BuildVision.UI/ViewModels/BuildVisionPaneViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.ComponentModel;

using Process = System.Diagnostics.Process;
using Microsoft.VisualStudio;
using BuildVision.Common;
using BuildVision.Contracts;
using BuildVision.UI.DataGrid;
Expand All @@ -22,7 +21,6 @@
using BuildVision.Helpers;
using System.ComponentModel.Composition;
using System.Text;
using System.Collections.Generic;
using BuildVision.Core;
using BuildVision.Views.Settings;
using BuildVision.Exports.Services;
Expand All @@ -35,7 +33,6 @@ namespace BuildVision.UI.ViewModels
[Export(typeof(IBuildVisionPaneViewModel))]
public class BuildVisionPaneViewModel : BindableBase, IBuildVisionPaneViewModel
{
public IBuildProgressViewModel BuildProgressViewModel { get; set; }
public ISolutionModel SolutionModel { get; set; }

private ObservableCollection<DataGridColumn> _gridColumnsRef;
Expand Down Expand Up @@ -201,20 +198,27 @@ public BuildVisionPaneViewModel(IBuildService buildManager, IBuildingProjectsPro
_buildingProjectsProvider = buildingProjectsProvider;
_buildInformationProvider = buildInformationProvider;
BuildInformationModel = _buildInformationProvider.GetBuildInformationModel();
BuildProgressViewModel = new BuildProgressViewModel(ControlSettings, BuildInformationModel);
SolutionModel = solutionProvider.GetSolutionModel();
ControlSettings = settingsProvider.Settings;
Projects = _buildingProjectsProvider.GetBuildingProjects();

if (settingsProvider.Settings.GeneralSettings.FillProjectListOnBuildBegin)
{
Projects.CollectionChanged += (sender, e) =>
{
OnPropertyChanged(nameof(GroupedProjectsList));
};
}
}


/// <summary>
/// Uses as design-time ViewModel.
/// </summary>
internal BuildVisionPaneViewModel()
{
ControlSettings = new ControlSettings();
BuildInformationModel = new BuildInformationModel();
BuildProgressViewModel = new BuildProgressViewModel(ControlSettings, BuildInformationModel);
SolutionModel = new SolutionModel();
Projects = new ObservableCollection<IProjectItem>();
}
Expand Down Expand Up @@ -320,33 +324,7 @@ public void OnControlSettingsChanged(ControlSettings settings)
// Raise all properties have changed.
OnPropertyChanged(null);

BuildProgressViewModel.ResetTaskBarInfo(false);
}

public void OnBuildProjectBegin()
{
BuildProgressViewModel.OnBuildProjectBegin();
}

public void OnBuildProjectDone(BuildedProject buildedProjectInfo)
{
bool success = buildedProjectInfo.Success.GetValueOrDefault(true);
BuildProgressViewModel.OnBuildProjectDone(success);
}

public void OnBuildBegin(int projectsCount)
{
BuildProgressViewModel.OnBuildBegin(projectsCount);
}

public void OnBuildDone()
{
BuildProgressViewModel.OnBuildDone();
}

public void OnBuildCancelled()
{
BuildProgressViewModel.OnBuildCancelled();
//BuildProgressViewModel.ResetTaskBarInfo(false);
}

private bool IsProjectItemEnabledForActions()
Expand Down
12 changes: 8 additions & 4 deletions src/BuildVision/BuildVision.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@
<Compile Include="Constants\EnvDTECodeModelLanguageConstants2.cs" />
<Compile Include="Services\BuildInformationProvider.cs" />
<Compile Include="Services\BuildingProjectsProvider.cs" />
<Compile Include="Services\BuildProgressViewModel.cs" />
<Compile Include="Services\ErrorNavigationService.cs" />
<Compile Include="Services\IErrorNavigationService.cs" />
<Compile Include="Services\IProjectFileNavigationService.cs" />
<Compile Include="Services\IWindowStateService.cs" />
<Compile Include="Services\ProjectFileNavigationService.cs" />
<Compile Include="Services\SolutionProvider.cs" />
<Compile Include="Helpers\ProjectIdentifierGenerator.cs" />
Expand All @@ -113,11 +118,10 @@
<Compile Include="Helpers\UIHierarchyExtensions.cs" />
<Compile Include="Helpers\VsCfgExtensions.cs" />
<Compile Include="Helpers\VsHierarchyExtensions.cs" />
<Compile Include="Services\BackgroundBuildProcessUpdater.cs" />
<Compile Include="Services\BuildManager.cs" />
<Compile Include="Services\BuildService.cs" />
<Compile Include="Services\BuildOutputLogger.cs" />
<Compile Include="Core\IPackageContext.cs" />
<Compile Include="Services\WindowStateManager.cs" />
<Compile Include="Services\WindowStateService.cs" />
<Compile Include="Views\Settings\BuildMessagesSettingsDialogPage.cs">
<SubType>Component</SubType>
</Compile>
Expand All @@ -127,7 +131,7 @@
<Compile Include="Views\Settings\GridSettingsDialogPage.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Views\Settings\PackageSettingsProvider.cs" />
<Compile Include="Services\PackageSettingsProvider.cs" />
<Compile Include="Views\Settings\ProjectItemSettingsDialogPage.cs">
<SubType>Component</SubType>
</Compile>
Expand Down
67 changes: 59 additions & 8 deletions src/BuildVision/Core/BuildVisionPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading;
using System.Windows;
using BuildVision.Exports.Providers;
using BuildVision.Helpers;
using BuildVision.Tool;
using BuildVision.UI;
using BuildVision.UI.Common.Logging;
Expand All @@ -16,6 +17,7 @@
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Task = System.Threading.Tasks.Task;
using Window = EnvDTE.Window;

namespace BuildVision.Core
{
Expand All @@ -35,6 +37,8 @@ public sealed partial class BuildVisionPackage : AsyncPackage, IPackageContext
{
private DTE _dte;
private DTE2 _dte2;
private CommandEvents _commandEvents;
private WindowEvents _windowEvents;
private SolutionEvents _solutionEvents;
private IVsSolutionBuildManager2 _solutionBuildManager;
private IVsSolutionBuildManager5 _solutionBuildManager4;
Expand All @@ -43,6 +47,7 @@ public sealed partial class BuildVisionPackage : AsyncPackage, IPackageContext
private SolutionBuildEvents _solutionBuildEvents;
private ISolutionProvider _solutionProvider;
private IBuildingProjectsProvider _buildingProjectsProvider;
private Window _activeProjectContext;

public ControlSettings ControlSettings { get; set; }

Expand Down Expand Up @@ -83,8 +88,14 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
_buildingProjectsProvider = await GetServiceAsync(typeof(IBuildingProjectsProvider)) as IBuildingProjectsProvider;

IPackageContext packageContext = this;

_commandEvents = _dte.Events.CommandEvents;
_commandEvents.AfterExecute += CommandEvents_AfterExecute;

_windowEvents = _dte.Events.WindowEvents;
_windowEvents.WindowActivated += WindowEvents_WindowActivated;

_solutionEvents = _dte.Events.SolutionEvents;
_solutionEvents.BeforeClosing += SolutionEvents_BeforeClosing;
_solutionEvents.AfterClosing += SolutionEvents_AfterClosing;
_solutionEvents.Opened += SolutionEvents_Opened;

Expand All @@ -94,16 +105,14 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
}
}

private void SolutionEvents_BeforeClosing()
{
ThreadHelper.ThrowIfNotOnUIThread();
_solutionBuildManager.UnadviseUpdateSolutionEvents(_updateSolutionEvents4Cookie);
_solutionBuildManager4.UnadviseUpdateSolutionEvents4(_updateSolutionEvents4Cookie);
}

private void SolutionEvents_Opened()
{
ThreadHelper.ThrowIfNotOnUIThread();

_solutionProvider.ReloadSolution();
_buildingProjectsProvider.ResetCurrentProjects();
_buildInformationProvider.ResetBuildInformationModel();

_solutionBuildEvents = new SolutionBuildEvents(_solutionProvider, _buildInformationProvider, _buildingProjectsProvider);
_solutionBuildManager.AdviseUpdateSolutionEvents(_solutionBuildEvents, out _updateSolutionEvents4Cookie);
_solutionBuildManager4.AdviseUpdateSolutionEvents4(_solutionBuildEvents, out _updateSolutionEvents4Cookie);
Expand All @@ -112,6 +121,48 @@ private void SolutionEvents_Opened()
private void SolutionEvents_AfterClosing()
{
ThreadHelper.ThrowIfNotOnUIThread();

_solutionProvider.ReloadSolution();
_buildingProjectsProvider.ResetCurrentProjects();
_buildInformationProvider.ResetBuildInformationModel();

_solutionBuildManager.UnadviseUpdateSolutionEvents(_updateSolutionEvents4Cookie);
_solutionBuildManager4.UnadviseUpdateSolutionEvents4(_updateSolutionEvents4Cookie);
}


private void WindowEvents_WindowActivated(Window gotFocus, Window lostFocus)
{
if (gotFocus == null)
return;

switch (gotFocus.Type)
{
case vsWindowType.vsWindowTypeSolutionExplorer:
_activeProjectContext = gotFocus;
break;

case vsWindowType.vsWindowTypeDocument:
case vsWindowType.vsWindowTypeDesigner:
case vsWindowType.vsWindowTypeCodeWindow:
if (gotFocus.Project != null && !gotFocus.Project.IsHidden())
_activeProjectContext = gotFocus;
break;

default:
return;
}
}

private void CommandEvents_AfterExecute(string guid, int id, object customIn, object customOut)
{
if (id == (int)VSConstants.VSStd97CmdID.CancelBuild
&& Guid.Parse(guid) == VSConstants.GUID_VSStandardCommandSet97)
{
//_buildCancelled = true;
//if (!_buildCancelledInternally)
// OnBuildCancelled();
}
}

private async void ShowToolWindowAsync(object sender, EventArgs e)
Expand Down
Loading

0 comments on commit 6d18526

Please sign in to comment.