Skip to content

Commit

Permalink
Adds UI notification on threshold exceeded (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryannewington committed Jan 8, 2018
1 parent 097252d commit f562c85
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/Lithnet.Miiserver.AutoSync/MAInterface/MAController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,7 @@ public void Start(MAControllerConfiguration config)
this.WaitAndTakeLock(this.serviceControlLock, nameof(this.serviceControlLock), this.controllerCancellationTokenSource);
gotLock = true;
this.ControlState = ControlState.Starting;
this.InternalStatus.ThresholdExceeded = false;
this.pendingActionList = new ExecutionParameterCollection();
this.pendingActions = new BlockingCollection<ExecutionParameters>(this.pendingActionList);
this.perProfileLastRunStatus = new Dictionary<string, string>();
Expand Down Expand Up @@ -1244,7 +1245,8 @@ public void Stop(bool cancelRun, bool waitForInternalTask, bool thresholdExceede

if (thresholdExceeded)
{
this.Message = "Threshold exceeded";
this.InternalStatus.ThresholdExceeded = true;
this.RaiseStateChange();
}

if (gotLock)
Expand Down
3 changes: 3 additions & 0 deletions src/Lithnet.Miiserver.AutoSync/MAInterface/MAStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public string DisplayState
[DataMember]
public bool HasForeignLock { get; internal set; }

[DataMember]
public bool ThresholdExceeded { get; internal set; }

public void Clear()
{
this.ExecutingRunProfile = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@
<ItemGroup>
<SplashScreen Include="Resources\splashscreen.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Blocked.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Fody.2.0.0\build\netstandard1.4\Fody.targets" Condition="Exists('..\packages\Fody.2.0.0\build\netstandard1.4\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,19 @@ public BitmapImage StatusIcon
{
get
{
if (this.ThresholdExceeded)
{
return App.GetImageResource("Blocked.png");
}

switch (this.DisplayState)
{

case "Disabled":
return App.GetImageResource("Stop.png");

case "Idle":
return App.GetImageResource("dot-medium.png");
return App.GetImageResource("dot-medium.png");

case "Paused":
return App.GetImageResource("Pause.png");
Expand Down Expand Up @@ -79,6 +85,8 @@ public BitmapImage StatusIcon

public string Message { get; private set; }

public bool ThresholdExceeded { get; private set; }

public string ExecutingRunProfile { get; private set; }

[AlsoNotifyFor(nameof(LastRun), nameof(DisplayIcon))]
Expand Down Expand Up @@ -135,7 +143,7 @@ public BitmapImage LockIcon

public void MAStatusChanged(MAStatus status)
{
this.Message = status.Message;
this.Message = status.ThresholdExceeded ? "Threshold exceeded" : status.Message;
this.ExecutingRunProfile = status.ExecutingRunProfile;
this.ExecutionQueue = status.ExecutionQueue;
this.DisplayState = status.DisplayState;
Expand All @@ -144,6 +152,7 @@ public void MAStatusChanged(MAStatus status)
this.HasExclusiveLock = status.HasExclusiveLock;
this.HasSyncLock = status.HasSyncLock;
this.HasForeignLock = status.HasForeignLock;
this.ThresholdExceeded = status.ThresholdExceeded;

this.Disabled = this.ControlState == ControlState.Disabled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
<ColumnDefinition />
</Grid.ColumnDefinitions>

<Label Grid.Row="0" Grid.Column="1" Content="You can force the controller to stop immediately if the following thresholds are exceeded by an import operation"/>
<Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Content="You can force the controller to immediately stop if any of the following thresholds are exceeded by an import operation"/>

<Label Grid.Row="1" Grid.Column="0" Content="Total changes"/>
<controls:NumericUpDown Grid.Row="1"
Expand Down

0 comments on commit f562c85

Please sign in to comment.