Files
kami_itunes_june/AppleBatch_June/VerificationCodeFrom.cs
2024-07-22 00:43:14 +08:00

243 lines
8.0 KiB
C#

using System;
using System.ComponentModel;
using System.Drawing;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using AppleBatch_June.Model;
namespace AppleBatch_June
{
public class VerificationCodeFrom : Form
{
public VerificationCodeConfig _verificationCode;
private bool isColse;
private bool isrun = true;
private IContainer components;
private Label label1;
private Label label3;
private TextBox textBox1;
private Button btnContity;
private Button button2;
private LinkLabel linkLabel1;
private Label label2;
private Label label4;
public string reustCode { get; set; } = "";
public string AppleId { get; set; }
public VerificationCodeFrom(VerificationCodeConfig verificationCode = null)
{
InitializeComponent();
if (verificationCode != null)
{
_verificationCode = verificationCode;
}
else
{
_verificationCode = new VerificationCodeConfig();
}
}
private void label2_Click(object sender, EventArgs e)
{
}
private void VerificationCodeFrom_Load(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(AppleId))
{
_verificationCode.content = AppleId;
}
label3.Text = _verificationCode.content;
Text = _verificationCode.WinTitle;
label1.Text = _verificationCode.tipMag;
Task.Run(delegate
{
try
{
int i;
for (i = 0; i < 60; i++)
{
if (isrun)
{
if (!base.IsDisposed && base.IsHandleCreated && !isColse)
{
Invoke((Action)delegate
{
button2.Text = "取消操作(" + (60 - i) + ")";
});
}
Thread.Sleep(1000);
}
}
if (isrun && !base.IsDisposed && base.IsHandleCreated && !isColse)
{
Invoke((Action)delegate
{
base.DialogResult = DialogResult.OK;
});
}
}
catch (Exception)
{
}
});
}
private void btnContity_Click(object sender, EventArgs e)
{
if (textBox1.Text.Trim().Length != _verificationCode.verifiLength && _verificationCode.verifiLength != 0)
{
MessageBox.Show("验证码格式不对,请重新输入,需要长度:" + _verificationCode.verifiLength);
return;
}
isColse = true;
reustCode = textBox1.Text.Trim();
base.DialogResult = DialogResult.OK;
}
private void button2_Click(object sender, EventArgs e)
{
reustCode = "";
isColse = true;
base.DialogResult = DialogResult.OK;
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
isrun = false;
button2.Text = "取消登录";
linkLabel1.Enabled = false;
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
label4.Text = textBox1.Text.Length.ToString();
}
protected override void Dispose(bool disposing)
{
if (disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.btnContity = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.label2 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
base.SuspendLayout();
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("微软雅黑", 10.5f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134);
this.label1.Location = new System.Drawing.Point(37, 76);
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(135, 19);
this.label1.TabIndex = 0;
this.label1.Text = "请输入显示的验证码";
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("楷体", 14.25f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134);
this.label3.ForeColor = System.Drawing.Color.Green;
this.label3.Location = new System.Drawing.Point(36, 25);
this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(75, 19);
this.label3.TabIndex = 2;
this.label3.Text = "label3";
this.textBox1.Font = new System.Drawing.Font("黑体", 14.25f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134);
this.textBox1.ForeColor = System.Drawing.Color.Red;
this.textBox1.Location = new System.Drawing.Point(35, 112);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(140, 29);
this.textBox1.TabIndex = 1;
this.textBox1.TextChanged += new System.EventHandler(textBox1_TextChanged);
this.btnContity.Font = new System.Drawing.Font("宋体", 12f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134);
this.btnContity.ForeColor = System.Drawing.Color.Green;
this.btnContity.Location = new System.Drawing.Point(190, 112);
this.btnContity.Name = "btnContity";
this.btnContity.Size = new System.Drawing.Size(98, 30);
this.btnContity.TabIndex = 4;
this.btnContity.Text = "确定";
this.btnContity.UseVisualStyleBackColor = true;
this.btnContity.Click += new System.EventHandler(btnContity_Click);
this.button2.Font = new System.Drawing.Font("宋体", 10.5f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134);
this.button2.ForeColor = System.Drawing.Color.DarkOrange;
this.button2.Location = new System.Drawing.Point(190, 150);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(114, 23);
this.button2.TabIndex = 5;
this.button2.Text = "取消操作";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(button2_Click);
this.linkLabel1.AutoSize = true;
this.linkLabel1.Location = new System.Drawing.Point(312, 155);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Size = new System.Drawing.Size(77, 14);
this.linkLabel1.TabIndex = 6;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "取消倒计时";
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(linkLabel1_LinkClicked);
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(32, 154);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(77, 14);
this.label2.TabIndex = 7;
this.label2.Text = "字符数量:";
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("微软雅黑", 10.5f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134);
this.label4.ForeColor = System.Drawing.Color.Red;
this.label4.Location = new System.Drawing.Point(112, 151);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(18, 19);
this.label4.TabIndex = 8;
this.label4.Text = "0";
base.AcceptButton = this.btnContity;
base.AutoScaleDimensions = new System.Drawing.SizeF(7f, 14f);
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
base.ClientSize = new System.Drawing.Size(414, 182);
base.Controls.Add(this.label4);
base.Controls.Add(this.label2);
base.Controls.Add(this.linkLabel1);
base.Controls.Add(this.button2);
base.Controls.Add(this.btnContity);
base.Controls.Add(this.textBox1);
base.Controls.Add(this.label3);
base.Controls.Add(this.label1);
this.Font = new System.Drawing.Font("宋体", 10.5f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
base.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
base.MaximizeBox = false;
base.MinimizeBox = false;
base.Name = "VerificationCodeFrom";
base.ShowIcon = false;
base.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "需要输入双重验证码";
base.TopMost = true;
base.Load += new System.EventHandler(VerificationCodeFrom_Load);
base.ResumeLayout(false);
base.PerformLayout();
}
}
}