Skip to content

Commit

Permalink
feat: Dashboard revisited
Browse files Browse the repository at this point in the history
Dashboard completely overhauled to provide more streamlined
and simpler UX. Recent repositories and categorised
repositories collections are combined. The repositories
list now only contains list of recent repositories
and is sync'ed with the list of repositories dropdown
to provide the consistent UX.
The list is managed via the FormRecentReposSettings.

The new dashboard has:
* two distinct themes - light and dark. A theme is
selected automatically based on the current Windows theme.

Closes #3658

Related issues/feature requests:
* Closes #633 as obsolete
* Closes #1062 as obsolete
* Fixes #1382
* Closes #1970 as obsolete
* Fixes #2228
* Fixes #2328
* Fixes #3624
* Closes #3648 as obsolete
* Fixes #3932
  • Loading branch information
RussKie committed May 13, 2018
1 parent 5b4f9fa commit 3b80052
Show file tree
Hide file tree
Showing 36 changed files with 2,137 additions and 991 deletions.
60 changes: 60 additions & 0 deletions GitCommands/UserRepositoryHistory/LocalRepositoryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ namespace GitCommands.UserRepositoryHistory
{
public interface ILocalRepositoryManager : IRepositoryManager
{
/// <summary>
/// Categorises the given <paramref name="repository"/> and assigns to the list of favourites,
/// if the <paramref name="category"/> is supplied; otherwise removes the repository from
/// the list of favourites.
/// </summary>
/// <param name="repository">The repository to categorise.</param>
/// <param name="category">The new category, if it is supplied.</param>
/// <returns>The current version of the list of favourite git repositories after the update.</returns>
[ContractAnnotation("repository:null=>halt")]
Task<IList<Repository>> AssignCategoryAsync(Repository repository, string category);

/// <summary>
/// Loads the list of favourite local git repositories from a persistent storage.
/// </summary>
Expand All @@ -21,13 +32,15 @@ public interface ILocalRepositoryManager : IRepositoryManager
/// </summary>
/// <param name="repositoryPath">A repository path to remove.</param>
/// <returns>The current version of the list of favourite git repositories after the update.</returns>
[ContractAnnotation("repositoryPath:null=>halt")]
Task<IList<Repository>> RemoveFavouriteAsync(string repositoryPath);

/// <summary>
/// Saves the list of favourite local git repositories to a persistent storage.
/// </summary>
/// <param name="repositoryHistory">A list of favourite git repositories.</param>
/// <returns>An awaitable task.</returns>
[ContractAnnotation("repositoryHistory:null=>halt")]
Task SaveFavouriteHistoryAsync(IEnumerable<Repository> repositoryHistory);
}

Expand Down Expand Up @@ -112,6 +125,53 @@ async Task<IList<Repository>> AddAsMostRecentRepositoryAsync(string path)
}
}

/// <summary>
/// Categorises the given <paramref name="repository"/> and assigns to the list of favourites,
/// if the <paramref name="category"/> is supplied; otherwise removes the repository from
/// the list of favourites.
/// </summary>
/// <param name="repository">The repository to categorise.</param>
/// <param name="category">The new category, if it is supplied.</param>
/// <returns>The current version of the list of favourite git repositories after the update.</returns>
/// <exception cref="ArgumentNullException"><paramref name="repository"/> is <see langword="null"/>.</exception>
[ContractAnnotation("repository:null=>halt")]
public async Task<IList<Repository>> AssignCategoryAsync(Repository repository, string category)
{
if (repository == null)
{
throw new ArgumentNullException(nameof(repository));
}

await TaskScheduler.Default;

var favourites = await LoadFavouriteHistoryAsync();
var favourite = favourites.FirstOrDefault(f => string.Equals(f.Path, repository.Path, StringComparison.OrdinalIgnoreCase));

if (favourite == null)
{
if (!string.IsNullOrWhiteSpace(category))
{
repository.Category = category;
favourites.Add(repository);
}
}
else
{
if (string.IsNullOrWhiteSpace(category))
{
favourites.Remove(favourite);
}
else
{
favourite.Category = category;
}
}

await SaveFavouriteHistoryAsync(favourites);

return favourites;
}

/// <summary>
/// Loads the list of favourite local git repositories from a persistent storage.
/// </summary>
Expand Down
23 changes: 23 additions & 0 deletions GitExtUtils/GitUI/DpiUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Drawing.Drawing2D;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using JetBrains.Annotations;
using Microsoft.Win32.SafeHandles;

Expand Down Expand Up @@ -80,13 +81,35 @@ public static int Scale(int i)
return (int)Math.Round(i * ScaleX);
}

/// <summary>
/// Returns a scaled copy of measurement <paramref name="i"/> which has
/// equivalent length on screen at the current DPI at the original would
/// at 96 DPI.
/// </summary>
public static float Scale(float i)
{
return (float)Math.Round(i * ScaleX);
}

public static Point Scale(Point point)
{
return new Point(
(int)(point.X * ScaleX),
(int)(point.Y * ScaleY));
}

/// <summary>
/// Returns a scaled copy of <paramref name="padding"/> which takes equivalent
/// screen space at the current DPI as the original would at 96 DPI.
/// </summary>
public static Padding Scale(Padding padding)
{
return new Padding((int)(padding.Left * ScaleX),
(int)(padding.Top * ScaleX),
(int)(padding.Right * ScaleX),
(int)(padding.Bottom * ScaleX));
}

[NotNull]
public static Image Scale([NotNull] Image image)
{
Expand Down
Loading

0 comments on commit 3b80052

Please sign in to comment.