Skip to content

Commit

Permalink
small visual feedback on timer adjusting
Browse files Browse the repository at this point in the history
  • Loading branch information
cadaei committed Dec 26, 2019
1 parent bba5b55 commit 8b605b2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
17 changes: 5 additions & 12 deletions ARKBreedingStats/SpeechRecognition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,6 @@ private void Recognizer_SpeechRecognitionRejected(object sender, SpeechRecogniti
Blink(Color.Orange);
}

/// <summary>
/// Changes the color of the microphone icon briefly.
/// </summary>
/// <param name="c"></param>
private async void Blink(Color c)
{
Color original = indicator.ForeColor;
indicator.ForeColor = c;
await Task.Delay(500);
indicator.ForeColor = original;
}

private void Sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
Blink(Color.Green);
Expand All @@ -89,6 +77,11 @@ private void Sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
}*/
}

private void Blink(Color c)
{
Utils.BlinkAsync(indicator, c);
}

private Grammar CreateTamingGrammar(int maxLevel, int levelSteps, List<string> aliases, CultureInfo culture)
{
Choices speciesChoice = new Choices(aliases.ToArray());
Expand Down
24 changes: 24 additions & 0 deletions ARKBreedingStats/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Drawing;
using System.Globalization;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ARKBreedingStats
Expand Down Expand Up @@ -319,5 +320,28 @@ public static bool GetFirstImportExportFolder(out string folder)
}
return false;
}


/// <summary>
/// Changes the color of a control briefly.
/// </summary>
/// <param name="c"></param>
public static async void BlinkAsync(Control ctlr, Color c, int duration = 500, bool foreColor = true)
{
if (foreColor)
{
Color original = ctlr.ForeColor;
ctlr.ForeColor = c;
await Task.Delay(duration);
ctlr.ForeColor = original;
}
else
{
Color original = ctlr.BackColor;
ctlr.BackColor = c;
await Task.Delay(duration);
ctlr.BackColor = original;
}
}
}
}
2 changes: 2 additions & 0 deletions ARKBreedingStats/raising/RaisingControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,8 @@ private void btAdjustAllTimers_Click(object sender, EventArgs e)
}
}
AdjustTimers?.Invoke(offset);
dhmsInputOffsetAllTimers.Timespan = default;
Utils.BlinkAsync(btAdjustAllTimers, Color.LightGreen, 500, false);
}

private void bSaveTimerEdit_Click(object sender, EventArgs e)
Expand Down

0 comments on commit 8b605b2

Please sign in to comment.