Skip to content

Commit

Permalink
Further major refactorings.
Browse files Browse the repository at this point in the history
Using MFC for loading services.
Added basic DI concepts
  • Loading branch information
StefanKert committed Jan 4, 2019
1 parent 3bb9a5d commit 70932b1
Show file tree
Hide file tree
Showing 29 changed files with 1,078 additions and 890 deletions.
4 changes: 3 additions & 1 deletion src/BuildVision.UI/BuildVision.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<ItemGroup>
<Reference Include="PresentationFramework.Aero" />
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Data" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
Expand Down Expand Up @@ -106,6 +107,7 @@
<Compile Include="Helpers\DisplayStringAttribute.cs" />
<Compile Include="Helpers\EnumExtensions.cs" />
<Compile Include="Helpers\StyleConverting.cs" />
<Compile Include="IBuildVisionPaneViewModel.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -167,7 +169,7 @@
<DependentUpon>WindowSettingsControl.xaml</DependentUpon>
</Compile>
<Compile Include="ViewModels\BuildProgressViewModel.cs" />
<Compile Include="ViewModels\ControlViewModel.cs" />
<Compile Include="ViewModels\BuildVisionPaneViewModel.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="Converters\AlternatingRowBackgroundConverter.cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/BuildVision.UI/Components/ControlView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</ResourceDictionary.MergedDictionaries>


<viewModels:ControlViewModel x:Key="DesignViewModel"/>
<viewModels:BuildVisionPaneViewModel x:Key="DesignViewModel"/>
<helpers:BindingProxy x:Key="proxy" Data="{Binding}" />

<CollectionViewSource x:Key="GridColumnsCollection" Source="{Binding ElementName=Grid, Path=Columns}" />
Expand Down
4 changes: 2 additions & 2 deletions src/BuildVision.UI/Components/ControlView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace BuildVision.UI
/// </summary>
public partial class ControlView : UserControl
{
private ControlViewModel _viewModel;
private BuildVisionPaneViewModel _viewModel;

public ControlView()
{
Expand Down Expand Up @@ -60,7 +60,7 @@ private void OnDataContextChanged(object sender, DependencyPropertyChangedEventA
{
Debug.Assert(DataContext != null);

_viewModel = (ControlViewModel)DataContext;
_viewModel = (BuildVisionPaneViewModel)DataContext;
_viewModel.SetGridColumnsRef(Grid.Columns);
_viewModel.PropertyChanged += ViewModelOnPropertyChanged;
}
Expand Down
8 changes: 0 additions & 8 deletions src/BuildVision.UI/Contracts/IBuildDistributor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ namespace BuildVision.UI.Contracts
{
public interface IBuildDistributor
{
event EventHandler OnBuildBegin;
event EventHandler OnBuildProcess;
event EventHandler OnBuildDone;
event EventHandler OnBuildCancelled;
event EventHandler<BuildProjectEventArgs> OnBuildProjectBegin;
event EventHandler<BuildProjectEventArgs> OnBuildProjectDone;
event EventHandler<BuildErrorRaisedEventArgs> OnErrorRaised;

Task CancelBuildAsync();
}
}
17 changes: 17 additions & 0 deletions src/BuildVision.UI/IBuildVisionPaneViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BuildVision.UI.Models;

namespace BuildVision.UI
{
public interface IBuildVisionPaneViewModel
{
SolutionItem SolutionItem { get; }

ObservableCollection<ProjectItem> ProjectsList { get;}
}
}
2 changes: 1 addition & 1 deletion src/BuildVision.UI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public MainWindow()
{
InitializeComponent();

var controlViewModel = new ControlViewModel();
var controlViewModel = new BuildVisionPaneViewModel();
ControlView.DataContext = controlViewModel;
}

Expand Down
2 changes: 1 addition & 1 deletion src/BuildVision.UI/Settings/Models/ControlSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ private void Init()
ProjectItemSettings = new ProjectItemSettings();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
using SortDescription = BuildVision.UI.Settings.Models.Sorting.SortDescription;
using BuildVision.UI.Settings.Models;
using BuildVision.Helpers;
using System.ComponentModel.Composition;
using System.Text;

namespace BuildVision.UI.ViewModels
{
public class ControlViewModel : BindableBase
[Export(typeof(IBuildVisionPaneViewModel))]
public class BuildVisionPaneViewModel : BindableBase, IBuildVisionPaneViewModel
{
private BuildState _buildState;
private IBuildInfo _buildInfo;
Expand Down Expand Up @@ -211,7 +214,7 @@ public ProjectItem SelectedProjectItem
set => SetProperty(ref _selectedProjectItem, value);
}

public ControlViewModel(ControlModel model, ControlSettings controlSettings)
public BuildVisionPaneViewModel(ControlModel model, ControlSettings controlSettings)
{
Model = model;
ControlSettings = controlSettings;
Expand All @@ -221,7 +224,7 @@ public ControlViewModel(ControlModel model, ControlSettings controlSettings)
/// <summary>
/// Uses as design-time ViewModel.
/// </summary>
internal ControlViewModel()
internal BuildVisionPaneViewModel()
{
Model = new ControlModel();
ControlSettings = new ControlSettings();
Expand Down Expand Up @@ -383,6 +386,23 @@ private bool IsProjectItemEnabledForActions()
return (SelectedProjectItem != null && !string.IsNullOrEmpty(SelectedProjectItem.UniqueName) && !SelectedProjectItem.IsBatchBuildProject);
}

private void CopyErrorMessageToClipboard(ProjectItem projectItem)
{
try
{
var errors = new StringBuilder();
foreach (var errorItem in projectItem.ErrorsBox.Errors)
{
errors.AppendLine(string.Format("{0}({1},{2},{3},{4}): error {5}: {6}", errorItem.File, errorItem.LineNumber, errorItem.ColumnNumber, errorItem.EndLineNumber, errorItem.EndColumnNumber, errorItem.Code, errorItem.Message));
}
Clipboard.SetText(errors.ToString());
}
catch (Exception ex)
{
ex.TraceUnknownException();
}
}

#region Commands

public ICommand ReportIssues => new RelayCommand(obj => GithubHelper.OpenBrowserWithPrefilledIssue());
Expand Down Expand Up @@ -436,6 +456,5 @@ private bool IsProjectItemEnabledForActions()
public event Action CancelBuildSolution;
public event Action<ProjectItem> ProjectCopyBuildOutputFilesToClipBoard;
public event Action<ProjectItem, int> RaiseCommandForSelectedProject;
public event Action<ProjectItem> CopyErrorMessageToClipboard;
}
}
20 changes: 18 additions & 2 deletions src/BuildVision/BuildVision.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="PresentationFramework.Aero" />
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Design" />
Expand All @@ -91,15 +92,23 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Core\BuildVisionPackage.cs" />
<Compile Include="Core\IStatusBarNotificationService.cs" />
<Compile Include="Core\ServiceProviderExports.cs" />
<Compile Include="Core\ServiceProviderPackage.cs" />
<Compile Include="Core\Services.cs" />
<Compile Include="Core\StatusBarNotificationService.cs" />
<Compile Include="Helpers\ProjectItemExtensions.cs" />
<Compile Include="Helpers\SolutionProjectsExtensions.cs" />
<Compile Include="Helpers\ProjectExtensions.cs" />
<Compile Include="Helpers\ProjectItemsExtensions.cs" />
<Compile Include="Helpers\PropertiesExtensions.cs" />
<Compile Include="Helpers\UIHierarchyExtensions.cs" />
<Compile Include="Tool\Building\BuildContext.cs" />
<Compile Include="Tool\Building\BuildManager.cs" />
<Compile Include="Tool\Building\BuildOutputLogger.cs" />
<Compile Include="Core\IPackageContext.cs" />
<Compile Include="Tool\Building\IVsItemLocatorService.cs" />
<Compile Include="Tool\Building\VsItemLocatorService.cs" />
<Compile Include="Tool\Views\Settings\BuildMessagesSettingsDialogPage.cs">
<SubType>Component</SubType>
</Compile>
Expand All @@ -109,6 +118,8 @@
<Compile Include="Tool\Views\Settings\GridSettingsDialogPage.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Tool\Views\Settings\IPackageSettingsProvider.cs" />
<Compile Include="Tool\Views\Settings\PackageSettingsProvider.cs" />
<Compile Include="Tool\Views\Settings\ProjectItemSettingsDialogPage.cs">
<SubType>Component</SubType>
</Compile>
Expand All @@ -118,8 +129,7 @@
<Compile Include="Tool\Views\Settings\WindowSettingsDialogPage.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Tool\Tool.cs" />
<Compile Include="Tool\ToolWindow.cs" />
<Compile Include="Tool\BuildVisionPane.cs" />
<Compile Include="Core\PackageGuids.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Core\PackageIds.cs" />
Expand Down Expand Up @@ -216,6 +226,12 @@
<PackageReference Include="EnvDTE90a">
<Version>9.0.3</Version>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.ComponentModelHost">
<Version>15.8.525</Version>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.SDK.Analyzers">
<Version>15.8.36</Version>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Shell.14.0">
<Version>14.3.25407</Version>
</PackageReference>
Expand Down
Loading

0 comments on commit 70932b1

Please sign in to comment.