-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Time Tools (get tick, set tick, and ntp reset)
- Loading branch information
1 parent
f14db72
commit a1cecf6
Showing
7 changed files
with
399 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using RaidCrawler.Core.Connection; | ||
using RaidCrawler.Core.Discord; | ||
|
||
namespace RaidCrawler.WinForms.SubForms | ||
{ | ||
public partial class TickModifier : Form | ||
{ | ||
readonly ConnectionWrapperAsync ConnectionWrapper; | ||
readonly NotificationHandler Webhook; | ||
readonly CancellationToken Token; | ||
public TickModifier(ulong tick, ConnectionWrapperAsync connectionWrapper, NotificationHandler webhook, CancellationToken token) | ||
{ | ||
InitializeComponent(); | ||
TB_Tick.Text = tick.ToString(); | ||
ConnectionWrapper = connectionWrapper; | ||
Webhook = webhook; | ||
Token = token; | ||
} | ||
|
||
private async void B_Read_Click(object sender, EventArgs e) | ||
{ | ||
try | ||
{ | ||
var tick = await ConnectionWrapper.GetCurrentTime(Token).ConfigureAwait(false); | ||
|
||
if (InvokeRequired) | ||
Invoke(() => TB_Tick.Text = tick.ToString()); | ||
else | ||
TB_Tick.Text = tick.ToString(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
await this.DisplayMessageBox(Webhook, $"Could not read the date: {ex.Message}", Token).ConfigureAwait(false); | ||
} | ||
} | ||
|
||
private async void B_NTP_Click(object sender, EventArgs e) | ||
{ | ||
try | ||
{ | ||
await ConnectionWrapper.ResetTimeNTP(Token).ConfigureAwait(false); | ||
B_Read_Click(sender, e); | ||
} | ||
catch (Exception ex) | ||
{ | ||
await this.DisplayMessageBox(Webhook, $"Could not reset the date: {ex.Message}", Token).ConfigureAwait(false); | ||
} | ||
} | ||
|
||
private async void B_Write_Click(object sender, EventArgs e) | ||
{ | ||
try | ||
{ | ||
var success = ulong.TryParse(TB_Tick.Text, out var time); | ||
if (success) | ||
{ | ||
await ConnectionWrapper.SetCurrentTime(time, Token).ConfigureAwait(false); | ||
} | ||
else | ||
{ | ||
await this.DisplayMessageBox(Webhook, $"Could not write the date: {TB_Tick.Text} could not be parsed as a ulong!", Token).ConfigureAwait(false); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
await this.DisplayMessageBox(Webhook, $"Could not write the date: {ex.Message}", Token).ConfigureAwait(false); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.