Skip to content

Commit

Permalink
Refactoring/quality of life changes (#26)
Browse files Browse the repository at this point in the history
* Updated squirrel.windows to 1.8.0

* Updated further nuget packages

* Added new resharper style settings

* Applied new code styles to whole solution

* Fixed resharper async/await issues
  • Loading branch information
Luka Grabarevic authored Jul 9, 2018
1 parent 7487f5c commit 6ffc68f
Show file tree
Hide file tree
Showing 145 changed files with 1,066 additions and 2,487 deletions.
17 changes: 3 additions & 14 deletions BuildsAppReborn.Access.UI/Base/View/BuildProviderViewBase.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
using System;
using System.Windows.Controls;

using BuildsAppReborn.Access.UI.Resources;
using BuildsAppReborn.Contracts.UI;

namespace BuildsAppReborn.Access.UI.View
{
internal abstract class BuildProviderViewBase : UserControl, IBuildProviderView
{
#region Implementation of IBuildProviderView
public String Header => Resource.TfsConnectBoxLabel;

public virtual IBuildProviderViewModel ViewModel
{
get
{
return (IBuildProviderViewModel)DataContext;
}
protected set
{
DataContext = value;
}
get { return (IBuildProviderViewModel) DataContext; }
protected set { DataContext = value; }
}

public String Header => Resource.TfsConnectBoxLabel;

#endregion
}
}
48 changes: 13 additions & 35 deletions BuildsAppReborn.Access.UI/Base/ViewModel/ProviderViewModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Windows.Input;

using BuildsAppReborn.Contracts;
using BuildsAppReborn.Contracts.Composition;
using BuildsAppReborn.Contracts.Models;
Expand All @@ -14,26 +12,28 @@ namespace BuildsAppReborn.Access.UI.ViewModel
{
internal abstract class ProviderViewModelBase : ViewModelBase, IBuildProviderViewModel, IPartImportsSatisfiedNotification
{
#region Implementation of IBuildProviderViewModel
public abstract String DisplayName { get; protected set; }

public BuildMonitorSettings MonitorSettings { get; private set; }

public virtual void Initialize(BuildMonitorSettings settings)
{
if (settings == null) throw new ArgumentNullException(nameof(settings));
MonitorSettings = settings;
OnInitialized();
}
public abstract IEnumerable<IBuildDefinition> SelectedBuildDefinitions { get; }

public abstract String DisplayName { get; protected set; }
public Boolean SupportsDefaultCredentials => BuildProviderMetaData.SupportedAuthenticationModes.HasFlag(AuthenticationModes.Default);

public abstract IEnumerable<IBuildDefinition> SelectedBuildDefinitions { get; }
public Boolean SupportsPersonalAccessToken => BuildProviderMetaData.SupportedAuthenticationModes.HasFlag(AuthenticationModes.AccessToken);

public abstract String Url { get; }

#endregion
public virtual void Initialize(BuildMonitorSettings settings)
{
if (settings == null)
{
throw new ArgumentNullException(nameof(settings));
}

#region Implementation of IPartImportsSatisfiedNotification
MonitorSettings = settings;
OnInitialized();
}

public virtual void OnImportsSatisfied()
{
Expand All @@ -57,40 +57,18 @@ public virtual void OnImportsSatisfied()
}
}

#endregion

#region Public Properties

public Boolean SupportsDefaultCredentials => BuildProviderMetaData.SupportedAuthenticationModes.HasFlag(AuthenticationModes.Default);

public Boolean SupportsPersonalAccessToken => BuildProviderMetaData.SupportedAuthenticationModes.HasFlag(AuthenticationModes.AccessToken);

#endregion

#region Protected Properties

protected IBuildProvider BuildProvider { get; private set; }

protected IBuildProviderMetadata BuildProviderMetaData { get; private set; }

#endregion

#region Protected Methods

protected virtual void OnInitialized()
{
}

#endregion

#region Private Fields

[ImportMany]
#pragma warning disable 649
private Lazy<IBuildProvider, IBuildProviderMetadata>[] buildProviders;

#pragma warning restore 649

#endregion
}
}
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
using System;

using BuildsAppReborn.Contracts.Models;
using BuildsAppReborn.Infrastructure;

namespace BuildsAppReborn.Access.UI.ViewModel.SubViewModels
{
internal class BuildDefinitionViewModel : ViewModelBase
{
#region Constructors

public BuildDefinitionViewModel(IBuildDefinition buildDefinition)
{
if (buildDefinition == null) throw new ArgumentNullException(nameof(buildDefinition));
if (buildDefinition == null)
{
throw new ArgumentNullException(nameof(buildDefinition));
}

BuildDefinition = buildDefinition;
}

#endregion

#region Public Properties

public IBuildDefinition BuildDefinition { get; }

public Boolean IsSelected
{
get
{
return this.isSelected;
}
get { return this.isSelected; }
set
{
this.isSelected = value;
Expand All @@ -36,12 +30,6 @@ public Boolean IsSelected

public String Name => BuildDefinition.Name;

#endregion

#region Private Fields

private Boolean isSelected;

#endregion
}
}
10 changes: 4 additions & 6 deletions BuildsAppReborn.Access.UI/BuildsAppReborn.Access.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="ToastNotifications, Version=2.1.0.0, Culture=neutral, PublicKeyToken=e89d9d7314a7c797, processorArchitecture=MSIL">
<HintPath>..\packages\ToastNotifications.2.1.0\lib\net452\ToastNotifications.dll</HintPath>
<Private>True</Private>
<Reference Include="ToastNotifications, Version=2.2.5.0, Culture=neutral, PublicKeyToken=e89d9d7314a7c797, processorArchitecture=MSIL">
<HintPath>..\packages\ToastNotifications.2.2.5\lib\net40\ToastNotifications.dll</HintPath>
</Reference>
<Reference Include="ToastNotifications.Messages, Version=2.1.0.0, Culture=neutral, PublicKeyToken=e89d9d7314a7c797, processorArchitecture=MSIL">
<HintPath>..\packages\ToastNotifications.Messages.2.1.0\lib\net452\ToastNotifications.Messages.dll</HintPath>
<Private>True</Private>
<Reference Include="ToastNotifications.Messages, Version=2.2.5.0, Culture=neutral, PublicKeyToken=e89d9d7314a7c797, processorArchitecture=MSIL">
<HintPath>..\packages\ToastNotifications.Messages.2.2.5\lib\net40\ToastNotifications.Messages.dll</HintPath>
</Reference>
<Reference Include="Windows" />
<Reference Include="WindowsBase" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
using BuildsAppReborn.Contracts.Models;
using BuildsAppReborn.Contracts.UI.Notifications;
using ToastNotifications;
using ToastNotifications.Core;
using ToastNotifications.Lifetime;
using ToastNotifications.Messages;
using ToastNotifications.Messages.Core;
using ToastNotifications.Position;

namespace BuildsAppReborn.Access.UI.Notifications
Expand All @@ -17,39 +17,38 @@ namespace BuildsAppReborn.Access.UI.Notifications
[PartCreationPolicy(CreationPolicy.Shared)]
internal class DefaultNotificationProvider : NotificationProviderBase, INotificationProvider
{
#region Constructors

[ImportingConstructor]
public DefaultNotificationProvider(GeneralSettings generalSettings) : base(generalSettings)
{
this.notifier = new Notifier(cfg =>
{
cfg.PositionProvider = new PrimaryScreenPositionProvider(Corner.BottomRight, 10, 50);
cfg.LifetimeSupervisor = new TimeAndCountBasedLifetimeSupervisor(TimeSpan.FromSeconds(10), MaximumNotificationCount.FromCount(3));
cfg.Dispatcher = Application.Current.Dispatcher;
});
{
cfg.PositionProvider = new PrimaryScreenPositionProvider(Corner.BottomRight, 10, 50);
cfg.LifetimeSupervisor = new TimeAndCountBasedLifetimeSupervisor(TimeSpan.FromSeconds(10), MaximumNotificationCount.FromCount(3));
cfg.Dispatcher = Application.Current.Dispatcher;
});
}

#endregion

#region Implementation of INotificationProvider
public Boolean IsSupported => true;

public void ShowBuild(IBuild build, Func<IBuild, String> iconProvider, Action<IBuild> notificationClickAction)
{
if (build == null) return;
if (build == null)
{
return;
}

var sb = new StringBuilder();
sb.AppendLine(GetTitle(build));
sb.AppendLine(build.GenerateStatus());
sb.AppendLine(build.GenerateUsername());
var displayOptions = new MessageOptions
{
NotificationClickAction = n =>
{
notificationClickAction?.Invoke(build);
n.Close();
}
};
{
NotificationClickAction = n =>
{
notificationClickAction?.Invoke(build);
n.Close();
}
};

switch (build.Status)
{
Expand Down Expand Up @@ -92,25 +91,17 @@ public void ShowMessage(String title, String message, Action clickAction)
else
{
var displayOptions = new MessageOptions
{
NotificationClickAction = n =>
{
clickAction.Invoke();
n.Close();
}
};
{
NotificationClickAction = n =>
{
clickAction.Invoke();
n.Close();
}
};
this.notifier.ShowInformation(sb.ToString(), displayOptions);
}
}

public Boolean IsSupported => true;

#endregion

#region Private Fields

private Notifier notifier;

#endregion
private readonly Notifier notifier;
}
}
4 changes: 0 additions & 4 deletions BuildsAppReborn.Access.UI/Notifications/NotificationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ namespace BuildsAppReborn.Access.UI.Notifications
{
internal static class NotificationHelper
{
#region Public Static Methods

public static String GenerateStatus(this IBuild build)
{
return build.Status.ToString();
Expand All @@ -29,7 +27,5 @@ public static String GenerateUsername(this IBuild build)
{
return build.Requester.DisplayName;
}

#endregion
}
}
Loading

0 comments on commit 6ffc68f

Please sign in to comment.