Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion GitDiffMargin.Extension/GitDiffMargin.Extension.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="MvvmLightLibs" Version="5.4.1.1" />
<PackageReference Include="LibGit2Sharp" Version="0.26.2" />

<PackageReference Include="Microsoft.VisualStudio.Editor" Version="15.6.27740" />
Expand Down
7 changes: 1 addition & 6 deletions GitDiffMargin.Extension/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,5 @@
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("e4701f35-8030-418e-8e8c-6ae72e229138")]

[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\GalaSoft.MvvmLight.dll")]
[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\GalaSoft.MvvmLight.Extras.dll")]
[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\GalaSoft.MvvmLight.Platform.dll")]
[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\GitDiffMargin.Shim.dll")]
[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\LibGit2Sharp.dll")]
[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\CommonServiceLocator.dll")]
[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\System.Windows.Interactivity.dll")]
[assembly: ProvideCodeBase(CodeBase = "$PackageFolder$\\LibGit2Sharp.dll")]
3 changes: 3 additions & 0 deletions GitDiffMargin.Shared/GitDiffMargin.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\DiffViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\EditorDiffMarginViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\EditorDiffViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\RelayCommand.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\RelayCommandGeneric.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\ScrollDiffMarginViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\ScrollDiffViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\ViewModelBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)View\OpaqueColorConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)View\PopupKeyboardBehavior.cs" />
</ItemGroup>
Expand Down
7 changes: 3 additions & 4 deletions GitDiffMargin.Shared/GitDiffMarginCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ namespace GitDiffMargin
using System;
using System.Linq;
using System.Windows.Input;
using GalaSoft.MvvmLight.Command;
using GitDiffMargin.ViewModel;
using ViewModel;
using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.Text.Editor;
using IVsTextView = Microsoft.VisualStudio.TextManager.Interop.IVsTextView;
Expand Down Expand Up @@ -60,7 +59,7 @@ protected override OLECMDF QueryCommandStatus(ref Guid commandGroup, uint comman
EditorDiffViewModel diffViewModel = viewModel.DiffViewModels.OfType<EditorDiffViewModel>().FirstOrDefault(i => i.ShowPopup);
if (diffViewModel != null)
{
RelayCommand<DiffViewModel> command = (GitDiffMarginCommand)commandId == GitDiffMarginCommand.NextChange ? viewModel.NextChangeCommand : viewModel.PreviousChangeCommand;
ICommand command = (GitDiffMarginCommand)commandId == GitDiffMarginCommand.NextChange ? viewModel.NextChangeCommand : viewModel.PreviousChangeCommand;
if (command.CanExecute(diffViewModel))
return OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_ENABLED;
else
Expand Down Expand Up @@ -148,7 +147,7 @@ protected override bool HandlePreExec(ref Guid commandGroup, uint commandId, OLE
if (viewModel == null)
return false;

RelayCommand<DiffViewModel> command = (GitDiffMarginCommand)commandId == GitDiffMarginCommand.NextChange ? viewModel.NextChangeCommand : viewModel.PreviousChangeCommand;
ICommand command = (GitDiffMarginCommand)commandId == GitDiffMarginCommand.NextChange ? viewModel.NextChangeCommand : viewModel.PreviousChangeCommand;

// First look for a diff already showing a popup
if (diffViewModel != null)
Expand Down
1 change: 0 additions & 1 deletion GitDiffMargin.Shared/GitDiffMarginPackage.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace GitDiffMargin
{
using System;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Shell;

Expand Down
1 change: 0 additions & 1 deletion GitDiffMargin.Shared/ViewModel/DiffMarginViewModelBase.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.ObjectModel;
using System.Linq;
using GalaSoft.MvvmLight;
using GitDiffMargin.Core;
using GitDiffMargin.Git;

Expand Down
9 changes: 4 additions & 5 deletions GitDiffMargin.Shared/ViewModel/DiffViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Windows;
using System.Windows.Media;
using GalaSoft.MvvmLight;
using GitDiffMargin.Core;
using GitDiffMargin.Git;

Expand Down Expand Up @@ -31,7 +30,7 @@ public double Height
set
{
_height = value;
RaisePropertyChanged(() => Height);
RaisePropertyChanged(nameof(Height));
}
}

Expand All @@ -41,7 +40,7 @@ public double Top
set
{
_top = value;
RaisePropertyChanged(() => Top);
RaisePropertyChanged(nameof(Top));
}
}

Expand Down Expand Up @@ -83,7 +82,7 @@ public virtual bool IsVisible
{
get { return _isVisible; }
set { _isVisible = value;
RaisePropertyChanged(() => IsVisible);}
RaisePropertyChanged(nameof(IsVisible));}
}

public double ScaleFactor => MarginCore.ScaleFactor;
Expand Down Expand Up @@ -115,7 +114,7 @@ public override void Cleanup()

private void HandleBrushesChanged(object sender, EventArgs e)
{
RaisePropertyChanged(() => DiffBrush);
RaisePropertyChanged(nameof(DiffBrush));
}

protected virtual void UpdateDimensions()
Expand Down
10 changes: 5 additions & 5 deletions GitDiffMargin.Shared/ViewModel/EditorDiffMarginViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

using System;
using System.Linq;
using GalaSoft.MvvmLight.Command;
using System.Windows.Input;
using GitDiffMargin.Core;
using GitDiffMargin.Git;

Expand All @@ -13,8 +13,8 @@ namespace GitDiffMargin.ViewModel
internal class EditorDiffMarginViewModel : DiffMarginViewModelBase
{
private readonly Action<DiffViewModel, HunkRangeInfo> _updateDiffDimensions;
private RelayCommand<DiffViewModel> _previousChangeCommand;
private RelayCommand<DiffViewModel> _nextChangeCommand;
private ICommand _previousChangeCommand;
private ICommand _nextChangeCommand;

internal EditorDiffMarginViewModel(IMarginCore marginCore, Action<DiffViewModel, HunkRangeInfo> updateDiffDimensions) :
base(marginCore)
Expand All @@ -25,12 +25,12 @@ internal EditorDiffMarginViewModel(IMarginCore marginCore, Action<DiffViewModel,
_updateDiffDimensions = updateDiffDimensions;
}

public RelayCommand<DiffViewModel> PreviousChangeCommand
public ICommand PreviousChangeCommand
{
get { return _previousChangeCommand ?? (_previousChangeCommand = new RelayCommand<DiffViewModel>(PreviousChange, PreviousChangeCanExecute)); }
}

public RelayCommand<DiffViewModel> NextChangeCommand
public ICommand NextChangeCommand
{
get { return _nextChangeCommand ?? (_nextChangeCommand = new RelayCommand<DiffViewModel>(NextChange, NextChangeCanExecute)); }
}
Expand Down
8 changes: 3 additions & 5 deletions GitDiffMargin.Shared/ViewModel/EditorDiffViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using GalaSoft.MvvmLight.Command;
using GitDiffMargin.Core;
using GitDiffMargin.Git;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using IOleCommandTarget = Microsoft.VisualStudio.OLE.Interop.IOleCommandTarget;

#endregion

Expand Down Expand Up @@ -188,8 +186,8 @@ public bool ShowPopup
ErrorHandler.CallWithCOMConvention(() => toolbarTrayHost.Close());
}

RaisePropertyChanged(() => ShowPopup);
RaisePropertyChanged(() => ToolBarTray);
RaisePropertyChanged(nameof(ShowPopup));
RaisePropertyChanged(nameof(ToolBarTray));
}
}

Expand All @@ -202,7 +200,7 @@ public bool IsDiffTextVisible
{
if (value == _isDiffTextVisible) return;
_isDiffTextVisible = value;
RaisePropertyChanged(() => IsDiffTextVisible);
RaisePropertyChanged(nameof(IsDiffTextVisible));
}
}

Expand Down
123 changes: 123 additions & 0 deletions GitDiffMargin.Shared/ViewModel/RelayCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// <copyright file="RelayCommand.cs" company="GalaSoft Laurent Bugnion">
// Copyright © GalaSoft Laurent Bugnion 2009-2011
// </copyright>
// ****************************************************************************
// <author>Laurent Bugnion</author>
// <email>laurent@galasoft.ch</email>
// <date>22.4.2009</date>
// <project>GalaSoft.MvvmLight</project>
// <web>http://www.galasoft.ch</web>
// <license>
// See license.txt in this project or http://www.galasoft.ch/license_MIT.txt
// </license>
// <LastBaseLevel>BL0008</LastBaseLevel>
// ****************************************************************************
// <credits>This class was developed by Josh Smith (http://joshsmithonwpf.wordpress.com) and
// slightly modified with his permission.</credits>
// ****************************************************************************

using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Windows.Input;

namespace GitDiffMargin.ViewModel

{
/// <summary>
/// A command whose sole purpose is to relay its functionality to other
/// objects by invoking delegates. The default return value for the CanExecute
/// method is 'true'. This class does not allow you to accept command parameters in the
/// Execute and CanExecute callback methods.
/// </summary>
////[ClassInfo(typeof(RelayCommand),
//// VersionString = "3.0.0.0",
//// DateString = "201003041420",
//// Description = "A command whose sole purpose is to relay its functionality to other objects by invoking delegates.",
//// UrlContacts = "http://www.galasoft.ch/contact_en.html",
//// Email = "laurent@galasoft.ch")]
public class RelayCommand : ICommand
{
private readonly Action _execute;

private readonly Func<bool> _canExecute;

/// <summary>
/// Initializes a new instance of the RelayCommand class that
/// can always execute.
/// </summary>
/// <param name="execute">The execution logic.</param>
/// <exception cref="ArgumentNullException">If the execute argument is null.</exception>
public RelayCommand(Action execute)
: this(execute, null)
{
}

/// <summary>
/// Initializes a new instance of the RelayCommand class.
/// </summary>
/// <param name="execute">The execution logic.</param>
/// <param name="canExecute">The execution status logic.</param>
/// <exception cref="ArgumentNullException">If the execute argument is null.</exception>
public RelayCommand(Action execute, Func<bool> canExecute)
{
if (execute == null)
{
throw new ArgumentNullException("execute");
}

_execute = execute;
_canExecute = canExecute;
}

/// <summary>
/// Occurs when changes occur that affect whether the command should execute.
/// </summary>
public event EventHandler CanExecuteChanged
{
add
{
if (_canExecute != null)
{
CommandManager.RequerySuggested += value;
}
}

remove
{
if (_canExecute != null)
{
CommandManager.RequerySuggested -= value;
}
}
}

/// <summary>
/// Raises the <see cref="CanExecuteChanged" /> event.
/// </summary>
public void RaiseCanExecuteChanged()
{
CommandManager.InvalidateRequerySuggested();
}

/// <summary>
/// Defines the method that determines whether the command can execute in its current state.
/// </summary>
/// <param name="parameter">This parameter will always be ignored.</param>
/// <returns>true if this command can be executed; otherwise, false.</returns>
[DebuggerStepThrough]
public bool CanExecute(object parameter)
{
return _canExecute == null ? true : _canExecute();
}

/// <summary>
/// Defines the method to be called when the command is invoked.
/// </summary>
/// <param name="parameter">This parameter will always be ignored.</param>
public void Execute(object parameter)
{
_execute();
}
}
}
Loading