Skip to content

Commit

Permalink
the code can be copied
Browse files Browse the repository at this point in the history
  • Loading branch information
Taurus Xin committed Jul 20, 2020
1 parent cfeed7e commit 578e091
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 24 deletions.
49 changes: 28 additions & 21 deletions MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 23 additions & 3 deletions MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ private void Initialize(object sender, EventArgs e)

if (!File.Exists("config.json"))
{
label1.Text = "Config first!";
linkLabel1.Text = "Config first!";
linkLabel1.Enabled = false;
timer1.Enabled = false;
Utils.FileWrite(Application.StartupPath + "\\config.json", Json.stringify(new SharedSecret()));
return;
Expand All @@ -69,8 +70,9 @@ private void Initialize(object sender, EventArgs e)
catch (Exception)
{
code = "Secret invalid!";
this.label1.Text = code;
this.linkLabel1.Text = code;
timer1.Enabled = false;
linkLabel1.Enabled = false;
progressBar1.Value = 0;
return;
}
Expand All @@ -84,7 +86,25 @@ private void RefreshCode()
{
long timestamp = Utils.GetSystemUnixTime();
code = SteamAuth.GenerateSteamGuardCodeForTime(secret.SharedSecretString, timestamp);
this.label1.Text = code;
this.linkLabel1.Text = code;
}

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
string tmp = linkLabel1.Text;
Clipboard.SetText(tmp);
linkLabel1.Text = "Copied!";
Delay(1000);
linkLabel1.Text = tmp;
}

private static void Delay(int milliSecond)
{
int start = Environment.TickCount;
while (Math.Abs(Environment.TickCount - start) < milliSecond)//毫秒
{
Application.DoEvents();//可执行某无聊的操作
}
}
}
}

0 comments on commit 578e091

Please sign in to comment.