Implement capturing TOTP QR code information from a screen screenshot.
Fix the bug where the program does not exit correctly.
This commit is contained in:
parent
0a15d66f2b
commit
160ca50f7a
2
OTP/Form1.Designer.cs
generated
2
OTP/Form1.Designer.cs
generated
@ -124,6 +124,7 @@
|
|||||||
this.circularProgressBar1.TabIndex = 6;
|
this.circularProgressBar1.TabIndex = 6;
|
||||||
this.circularProgressBar1.Text = "time";
|
this.circularProgressBar1.Text = "time";
|
||||||
this.circularProgressBar1.TextMargin = new System.Windows.Forms.Padding(21, 2, 0, 0);
|
this.circularProgressBar1.TextMargin = new System.Windows.Forms.Padding(21, 2, 0, 0);
|
||||||
|
this.circularProgressBar1.Value = 30;
|
||||||
//
|
//
|
||||||
// button3
|
// button3
|
||||||
//
|
//
|
||||||
@ -169,6 +170,7 @@
|
|||||||
this.Controls.Add(this.circularProgressBar1);
|
this.Controls.Add(this.circularProgressBar1);
|
||||||
this.Name = "Form1";
|
this.Name = "Form1";
|
||||||
this.Text = "Main Window";
|
this.Text = "Main Window";
|
||||||
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
|
13
OTP/Form1.cs
13
OTP/Form1.cs
@ -82,5 +82,18 @@ namespace OTP
|
|||||||
// 隐藏当前的 Form1 实例
|
// 隐藏当前的 Form1 实例
|
||||||
this.Hide();
|
this.Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult result = MessageBox.Show("Do you want to exit the application?", "Confirm Exit",
|
||||||
|
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||||
|
|
||||||
|
if (result == DialogResult.No)
|
||||||
|
{
|
||||||
|
e.Cancel = true; // 取消关闭事件,阻止关闭
|
||||||
|
}
|
||||||
|
// 如果用户选择 Yes,什么都不需要做,窗体会继续关闭
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
OTP/Form2.Designer.cs
generated
1
OTP/Form2.Designer.cs
generated
@ -112,6 +112,7 @@
|
|||||||
this.Controls.Add(this.panel1);
|
this.Controls.Add(this.panel1);
|
||||||
this.Name = "Form2";
|
this.Name = "Form2";
|
||||||
this.Text = "Data Manage";
|
this.Text = "Data Manage";
|
||||||
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form2_FormClosing);
|
||||||
this.panel1.ResumeLayout(false);
|
this.panel1.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
11
OTP/Form2.cs
11
OTP/Form2.cs
@ -60,5 +60,16 @@ namespace OTP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
Form1 form1 = Application.OpenForms["Form1"] as Form1;
|
||||||
|
if (form1 != null)
|
||||||
|
{
|
||||||
|
form1.Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
97
OTP/Form3.Designer.cs
generated
97
OTP/Form3.Designer.cs
generated
@ -37,12 +37,18 @@
|
|||||||
this.button3 = new System.Windows.Forms.Button();
|
this.button3 = new System.Windows.Forms.Button();
|
||||||
this.button4 = new System.Windows.Forms.Button();
|
this.button4 = new System.Windows.Forms.Button();
|
||||||
this.button5 = new System.Windows.Forms.Button();
|
this.button5 = new System.Windows.Forms.Button();
|
||||||
|
this.button6 = new System.Windows.Forms.Button();
|
||||||
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
|
this.label4 = new System.Windows.Forms.Label();
|
||||||
|
this.label5 = new System.Windows.Forms.Label();
|
||||||
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||||
|
this.groupBox1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// label1
|
// label1
|
||||||
//
|
//
|
||||||
this.label1.AutoSize = true;
|
this.label1.AutoSize = true;
|
||||||
this.label1.Location = new System.Drawing.Point(26, 9);
|
this.label1.Location = new System.Drawing.Point(26, 13);
|
||||||
this.label1.Name = "label1";
|
this.label1.Name = "label1";
|
||||||
this.label1.Size = new System.Drawing.Size(27, 13);
|
this.label1.Size = new System.Drawing.Size(27, 13);
|
||||||
this.label1.TabIndex = 0;
|
this.label1.TabIndex = 0;
|
||||||
@ -50,7 +56,7 @@
|
|||||||
//
|
//
|
||||||
// textBox1
|
// textBox1
|
||||||
//
|
//
|
||||||
this.textBox1.Location = new System.Drawing.Point(72, 6);
|
this.textBox1.Location = new System.Drawing.Point(72, 10);
|
||||||
this.textBox1.Name = "textBox1";
|
this.textBox1.Name = "textBox1";
|
||||||
this.textBox1.Size = new System.Drawing.Size(202, 20);
|
this.textBox1.Size = new System.Drawing.Size(202, 20);
|
||||||
this.textBox1.TabIndex = 1;
|
this.textBox1.TabIndex = 1;
|
||||||
@ -58,7 +64,7 @@
|
|||||||
// label2
|
// label2
|
||||||
//
|
//
|
||||||
this.label2.AutoSize = true;
|
this.label2.AutoSize = true;
|
||||||
this.label2.Location = new System.Drawing.Point(12, 37);
|
this.label2.Location = new System.Drawing.Point(12, 41);
|
||||||
this.label2.Name = "label2";
|
this.label2.Name = "label2";
|
||||||
this.label2.Size = new System.Drawing.Size(54, 13);
|
this.label2.Size = new System.Drawing.Size(54, 13);
|
||||||
this.label2.TabIndex = 2;
|
this.label2.TabIndex = 2;
|
||||||
@ -66,25 +72,27 @@
|
|||||||
//
|
//
|
||||||
// textBox2
|
// textBox2
|
||||||
//
|
//
|
||||||
this.textBox2.Location = new System.Drawing.Point(72, 34);
|
this.textBox2.Location = new System.Drawing.Point(72, 38);
|
||||||
this.textBox2.Name = "textBox2";
|
this.textBox2.Name = "textBox2";
|
||||||
this.textBox2.Size = new System.Drawing.Size(202, 20);
|
this.textBox2.Size = new System.Drawing.Size(202, 20);
|
||||||
this.textBox2.TabIndex = 3;
|
this.textBox2.TabIndex = 3;
|
||||||
//
|
//
|
||||||
// button1
|
// button1
|
||||||
//
|
//
|
||||||
this.button1.Location = new System.Drawing.Point(92, 62);
|
this.button1.Location = new System.Drawing.Point(72, 68);
|
||||||
this.button1.Name = "button1";
|
this.button1.Name = "button1";
|
||||||
this.button1.Size = new System.Drawing.Size(75, 23);
|
this.button1.Size = new System.Drawing.Size(100, 45);
|
||||||
this.button1.TabIndex = 4;
|
this.button1.TabIndex = 4;
|
||||||
this.button1.Text = "Add";
|
this.button1.Text = "Add";
|
||||||
this.button1.UseVisualStyleBackColor = true;
|
this.button1.UseVisualStyleBackColor = true;
|
||||||
|
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||||
//
|
//
|
||||||
// button2
|
// button2
|
||||||
//
|
//
|
||||||
this.button2.Location = new System.Drawing.Point(183, 62);
|
this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||||
|
this.button2.Location = new System.Drawing.Point(174, 68);
|
||||||
this.button2.Name = "button2";
|
this.button2.Name = "button2";
|
||||||
this.button2.Size = new System.Drawing.Size(75, 23);
|
this.button2.Size = new System.Drawing.Size(100, 45);
|
||||||
this.button2.TabIndex = 5;
|
this.button2.TabIndex = 5;
|
||||||
this.button2.Text = "Cancel";
|
this.button2.Text = "Cancel";
|
||||||
this.button2.UseVisualStyleBackColor = true;
|
this.button2.UseVisualStyleBackColor = true;
|
||||||
@ -93,35 +101,86 @@
|
|||||||
//
|
//
|
||||||
this.button3.Location = new System.Drawing.Point(292, 4);
|
this.button3.Location = new System.Drawing.Point(292, 4);
|
||||||
this.button3.Name = "button3";
|
this.button3.Name = "button3";
|
||||||
this.button3.Size = new System.Drawing.Size(117, 23);
|
this.button3.Size = new System.Drawing.Size(176, 23);
|
||||||
this.button3.TabIndex = 6;
|
this.button3.TabIndex = 6;
|
||||||
this.button3.Text = "Screenshot Scan";
|
this.button3.Text = "Scan QR Code from Screenshot";
|
||||||
this.button3.UseVisualStyleBackColor = true;
|
this.button3.UseVisualStyleBackColor = true;
|
||||||
|
this.button3.Click += new System.EventHandler(this.button3_Click);
|
||||||
//
|
//
|
||||||
// button4
|
// button4
|
||||||
//
|
//
|
||||||
this.button4.Location = new System.Drawing.Point(292, 33);
|
this.button4.Location = new System.Drawing.Point(292, 33);
|
||||||
this.button4.Name = "button4";
|
this.button4.Name = "button4";
|
||||||
this.button4.Size = new System.Drawing.Size(117, 23);
|
this.button4.Size = new System.Drawing.Size(176, 23);
|
||||||
this.button4.TabIndex = 7;
|
this.button4.TabIndex = 7;
|
||||||
this.button4.Text = "Camera Scan";
|
this.button4.Text = "Scan QR Code from Image File";
|
||||||
this.button4.UseVisualStyleBackColor = true;
|
this.button4.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// button5
|
// button5
|
||||||
//
|
//
|
||||||
this.button5.Location = new System.Drawing.Point(292, 62);
|
this.button5.Location = new System.Drawing.Point(292, 62);
|
||||||
this.button5.Name = "button5";
|
this.button5.Name = "button5";
|
||||||
this.button5.Size = new System.Drawing.Size(117, 23);
|
this.button5.Size = new System.Drawing.Size(176, 23);
|
||||||
this.button5.TabIndex = 8;
|
this.button5.TabIndex = 8;
|
||||||
this.button5.Text = "Import from Clipboard";
|
this.button5.Text = "Scan QR Code with Camera";
|
||||||
this.button5.UseVisualStyleBackColor = true;
|
this.button5.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
|
// button6
|
||||||
|
//
|
||||||
|
this.button6.Location = new System.Drawing.Point(292, 91);
|
||||||
|
this.button6.Name = "button6";
|
||||||
|
this.button6.Size = new System.Drawing.Size(176, 23);
|
||||||
|
this.button6.TabIndex = 9;
|
||||||
|
this.button6.Text = "Import from Clipboard";
|
||||||
|
this.button6.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
this.label3.AutoSize = true;
|
||||||
|
this.label3.Location = new System.Drawing.Point(24, 33);
|
||||||
|
this.label3.Name = "label3";
|
||||||
|
this.label3.Size = new System.Drawing.Size(33, 13);
|
||||||
|
this.label3.TabIndex = 11;
|
||||||
|
this.label3.Text = "None";
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
this.label4.AutoSize = true;
|
||||||
|
this.label4.Location = new System.Drawing.Point(24, 59);
|
||||||
|
this.label4.Name = "label4";
|
||||||
|
this.label4.Size = new System.Drawing.Size(37, 13);
|
||||||
|
this.label4.TabIndex = 12;
|
||||||
|
this.label4.Text = "Status";
|
||||||
|
//
|
||||||
|
// label5
|
||||||
|
//
|
||||||
|
this.label5.AutoSize = true;
|
||||||
|
this.label5.Location = new System.Drawing.Point(24, 86);
|
||||||
|
this.label5.Name = "label5";
|
||||||
|
this.label5.Size = new System.Drawing.Size(25, 13);
|
||||||
|
this.label5.TabIndex = 13;
|
||||||
|
this.label5.Text = "Info";
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
this.groupBox1.Controls.Add(this.label4);
|
||||||
|
this.groupBox1.Controls.Add(this.label5);
|
||||||
|
this.groupBox1.Controls.Add(this.label3);
|
||||||
|
this.groupBox1.Location = new System.Drawing.Point(15, 148);
|
||||||
|
this.groupBox1.Name = "groupBox1";
|
||||||
|
this.groupBox1.Size = new System.Drawing.Size(453, 243);
|
||||||
|
this.groupBox1.TabIndex = 14;
|
||||||
|
this.groupBox1.TabStop = false;
|
||||||
|
this.groupBox1.Text = "Debug Info";
|
||||||
|
//
|
||||||
// Form3
|
// Form3
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.CancelButton = this.button2;
|
this.CancelButton = this.button2;
|
||||||
this.ClientSize = new System.Drawing.Size(418, 96);
|
this.ClientSize = new System.Drawing.Size(488, 403);
|
||||||
|
this.Controls.Add(this.groupBox1);
|
||||||
|
this.Controls.Add(this.button6);
|
||||||
this.Controls.Add(this.button5);
|
this.Controls.Add(this.button5);
|
||||||
this.Controls.Add(this.button4);
|
this.Controls.Add(this.button4);
|
||||||
this.Controls.Add(this.button3);
|
this.Controls.Add(this.button3);
|
||||||
@ -138,6 +197,9 @@
|
|||||||
this.ShowIcon = false;
|
this.ShowIcon = false;
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||||
this.Text = "New Record";
|
this.Text = "New Record";
|
||||||
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form3_FormClosing);
|
||||||
|
this.groupBox1.ResumeLayout(false);
|
||||||
|
this.groupBox1.PerformLayout();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
@ -154,5 +216,10 @@
|
|||||||
private System.Windows.Forms.Button button3;
|
private System.Windows.Forms.Button button3;
|
||||||
private System.Windows.Forms.Button button4;
|
private System.Windows.Forms.Button button4;
|
||||||
private System.Windows.Forms.Button button5;
|
private System.Windows.Forms.Button button5;
|
||||||
|
private System.Windows.Forms.Button button6;
|
||||||
|
private System.Windows.Forms.Label label3;
|
||||||
|
private System.Windows.Forms.Label label4;
|
||||||
|
private System.Windows.Forms.Label label5;
|
||||||
|
private System.Windows.Forms.GroupBox groupBox1;
|
||||||
}
|
}
|
||||||
}
|
}
|
121
OTP/Form3.cs
121
OTP/Form3.cs
@ -1,22 +1,141 @@
|
|||||||
using System;
|
using ScreenCapturerNS;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
using System.Data.SQLite;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using ZXing;
|
||||||
|
|
||||||
namespace OTP
|
namespace OTP
|
||||||
{
|
{
|
||||||
public partial class Form3 : Form
|
public partial class Form3 : Form
|
||||||
{
|
{
|
||||||
|
private string connectionString = "Data Source=key.db;Version=3;";
|
||||||
|
private bool isCapturing = false; // 添加标识截图状态的成员变量
|
||||||
|
|
||||||
public Form3()
|
public Form3()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Form3_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
StopCapturing(); // 关闭窗口时停止截图
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button1_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string title = textBox1.Text;
|
||||||
|
string secretKey = textBox2.Text;
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(title) && !string.IsNullOrWhiteSpace(secretKey))
|
||||||
|
{
|
||||||
|
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
|
||||||
|
{
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
using (SQLiteCommand command = new SQLiteCommand("INSERT INTO TotpData (Title, SecretKey) VALUES (@Title, @SecretKey)", connection))
|
||||||
|
{
|
||||||
|
command.Parameters.AddWithValue("@Title", title);
|
||||||
|
command.Parameters.AddWithValue("@SecretKey", secretKey);
|
||||||
|
command.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.DialogResult = DialogResult.OK;
|
||||||
|
MessageBox.Show("Record added successfully.");
|
||||||
|
|
||||||
|
// 关闭当前的 Form3 实例
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Please enter both title and secret key.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"An error occurred: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button3_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (isCapturing)
|
||||||
|
{
|
||||||
|
label5.Text = "Stopped";
|
||||||
|
StopCapturing(); // 停止截图
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
label3.Text = "None";
|
||||||
|
label5.Text = "Running";
|
||||||
|
label4.Text = "No QR code found.";
|
||||||
|
StartCapturing(); // 开始截图
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StartCapturing()
|
||||||
|
{
|
||||||
|
isCapturing = true; // 设置截图状态为正在截图
|
||||||
|
ScreenCapturer.StartCapture((Bitmap bitmap) => {
|
||||||
|
// 进行二维码扫描
|
||||||
|
ScanQRCode(bitmap);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StopCapturing()
|
||||||
|
{
|
||||||
|
isCapturing = false; // 设置截图状态为未截图
|
||||||
|
ScreenCapturer.StopCapture(); // 停止截图
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void ScanQRCode(Bitmap bitmap)
|
||||||
|
{
|
||||||
|
// 创建二维码读取器实例
|
||||||
|
BarcodeReader barcodeReader = new BarcodeReader();
|
||||||
|
|
||||||
|
// 尝试解码二维码
|
||||||
|
Result result = barcodeReader.Decode(bitmap);
|
||||||
|
if (result != null)
|
||||||
|
{
|
||||||
|
// 扫描成功,显示扫描结果
|
||||||
|
string decodedText = result.Text;
|
||||||
|
this.Invoke((MethodInvoker)(() => label3.Text = decodedText));
|
||||||
|
|
||||||
|
// 判断是否符合期望的格式
|
||||||
|
if (decodedText.StartsWith("otpauth://totp/") && decodedText.Contains("?secret="))
|
||||||
|
{
|
||||||
|
StopCapturing();
|
||||||
|
this.Invoke((MethodInvoker)(() => label5.Text = "Stopped"));
|
||||||
|
string[] parts = decodedText.Split(new char[] { '/', '=', '&','?' });
|
||||||
|
if (parts.Length >= 6)
|
||||||
|
{
|
||||||
|
string title = parts[3]; // 获取 title 部分
|
||||||
|
string secretKey = parts[5]; // 获取 secretKey 部分
|
||||||
|
|
||||||
|
// 在窗体上显示 title 和 secretKey
|
||||||
|
this.Invoke((MethodInvoker)(() => textBox1.Text = title));
|
||||||
|
this.Invoke((MethodInvoker)(() => textBox2.Text = secretKey));
|
||||||
|
this.Invoke((MethodInvoker)(() => label4.Text = "Success"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.Invoke((MethodInvoker)(() => label4.Text = "Invalid QR code format."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.Invoke((MethodInvoker)(() => label4.Text = "QR code format not recognized."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
73
OTP/Form4.Designer.cs
generated
Normal file
73
OTP/Form4.Designer.cs
generated
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
namespace OTP
|
||||||
|
{
|
||||||
|
partial class Form4
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.button1 = new System.Windows.Forms.Button();
|
||||||
|
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// button1
|
||||||
|
//
|
||||||
|
this.button1.Location = new System.Drawing.Point(713, 160);
|
||||||
|
this.button1.Name = "button1";
|
||||||
|
this.button1.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.button1.TabIndex = 0;
|
||||||
|
this.button1.Text = "button1";
|
||||||
|
this.button1.UseVisualStyleBackColor = true;
|
||||||
|
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||||
|
//
|
||||||
|
// pictureBox1
|
||||||
|
//
|
||||||
|
this.pictureBox1.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.pictureBox1.Name = "pictureBox1";
|
||||||
|
this.pictureBox1.Size = new System.Drawing.Size(695, 426);
|
||||||
|
this.pictureBox1.TabIndex = 1;
|
||||||
|
this.pictureBox1.TabStop = false;
|
||||||
|
//
|
||||||
|
// Form4
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Controls.Add(this.pictureBox1);
|
||||||
|
this.Controls.Add(this.button1);
|
||||||
|
this.Name = "Form4";
|
||||||
|
this.Text = "Form4";
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Button button1;
|
||||||
|
private System.Windows.Forms.PictureBox pictureBox1;
|
||||||
|
}
|
||||||
|
}
|
31
OTP/Form4.cs
Normal file
31
OTP/Form4.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using ScreenCapturerNS;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace OTP
|
||||||
|
{
|
||||||
|
public partial class Form4 : Form
|
||||||
|
{
|
||||||
|
public Form4()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button1_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
ScreenCapturer.StartCapture((Bitmap bitmap) => {
|
||||||
|
// 处理截图 (bitmap) 这里
|
||||||
|
// 例如,你可以将截图显示在某个 PictureBox 控件中
|
||||||
|
pictureBox1.Image = bitmap;
|
||||||
|
ScreenCapturer.StopCapture();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
OTP/Form4.resx
Normal file
120
OTP/Form4.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
@ -48,6 +48,18 @@
|
|||||||
<Reference Include="Otp.NET, Version=1.3.0.0, Culture=neutral, PublicKeyToken=38a48df817e173a6, processorArchitecture=MSIL">
|
<Reference Include="Otp.NET, Version=1.3.0.0, Culture=neutral, PublicKeyToken=38a48df817e173a6, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Otp.NET.1.3.0\lib\net45\Otp.NET.dll</HintPath>
|
<HintPath>..\packages\Otp.NET.1.3.0\lib\net45\Otp.NET.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="ScreenCapturer, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\ScreenCapturer.3.0.1\lib\netstandard2.0\ScreenCapturer.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="SharpDX, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\SharpDX.4.2.0\lib\net45\SharpDX.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="SharpDX.Direct3D11, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\SharpDX.Direct3D11.4.2.0\lib\net45\SharpDX.Direct3D11.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="SharpDX.DXGI, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\SharpDX.DXGI.4.2.0\lib\net45\SharpDX.DXGI.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
@ -60,6 +72,9 @@
|
|||||||
<Reference Include="System.Data.SQLite.Linq, Version=1.0.118.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
|
<Reference Include="System.Data.SQLite.Linq, Version=1.0.118.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\System.Data.SQLite.Linq.1.0.118.0\lib\net46\System.Data.SQLite.Linq.dll</HintPath>
|
<HintPath>..\packages\System.Data.SQLite.Linq.1.0.118.0\lib\net46\System.Data.SQLite.Linq.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="System.Drawing.Common, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Drawing.Common.7.0.0\lib\net462\System.Drawing.Common.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
<Reference Include="System.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\System.IO.4.3.0\lib\net462\System.IO.dll</HintPath>
|
<HintPath>..\packages\System.IO.4.3.0\lib\net462\System.IO.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
@ -77,6 +92,12 @@
|
|||||||
<Reference Include="WinFormAnimation, Version=1.6.0.4, Culture=neutral, PublicKeyToken=310fd07b25df79b3, processorArchitecture=MSIL">
|
<Reference Include="WinFormAnimation, Version=1.6.0.4, Culture=neutral, PublicKeyToken=310fd07b25df79b3, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\WinFormAnimation.1.6.0.4\lib\net40\WinFormAnimation.dll</HintPath>
|
<HintPath>..\packages\WinFormAnimation.1.6.0.4\lib\net40\WinFormAnimation.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="zxing, Version=0.16.9.0, Culture=neutral, PublicKeyToken=4e88037ac681fe60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\ZXing.Net.0.16.9\lib\net48\zxing.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="zxing.presentation, Version=0.16.9.0, Culture=neutral, PublicKeyToken=4e88037ac681fe60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\ZXing.Net.0.16.9\lib\net48\zxing.presentation.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Form1.cs">
|
<Compile Include="Form1.cs">
|
||||||
@ -97,6 +118,12 @@
|
|||||||
<Compile Include="Form3.Designer.cs">
|
<Compile Include="Form3.Designer.cs">
|
||||||
<DependentUpon>Form3.cs</DependentUpon>
|
<DependentUpon>Form3.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Form4.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Form4.Designer.cs">
|
||||||
|
<DependentUpon>Form4.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<EmbeddedResource Include="Form1.resx">
|
<EmbeddedResource Include="Form1.resx">
|
||||||
@ -108,6 +135,9 @@
|
|||||||
<EmbeddedResource Include="Form3.resx">
|
<EmbeddedResource Include="Form3.resx">
|
||||||
<DependentUpon>Form3.cs</DependentUpon>
|
<DependentUpon>Form3.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="Form4.resx">
|
||||||
|
<DependentUpon>Form4.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
@ -3,11 +3,17 @@
|
|||||||
<package id="CircularProgressBar" version="2.8.0.16" targetFramework="net481" />
|
<package id="CircularProgressBar" version="2.8.0.16" targetFramework="net481" />
|
||||||
<package id="EntityFramework" version="6.4.4" targetFramework="net481" />
|
<package id="EntityFramework" version="6.4.4" targetFramework="net481" />
|
||||||
<package id="Otp.NET" version="1.3.0" targetFramework="net481" />
|
<package id="Otp.NET" version="1.3.0" targetFramework="net481" />
|
||||||
|
<package id="ScreenCapturer" version="3.0.1" targetFramework="net481" />
|
||||||
|
<package id="SharpDX" version="4.2.0" targetFramework="net481" />
|
||||||
|
<package id="SharpDX.Direct3D11" version="4.2.0" targetFramework="net481" />
|
||||||
|
<package id="SharpDX.DXGI" version="4.2.0" targetFramework="net481" />
|
||||||
<package id="Stub.System.Data.SQLite.Core.NetFramework" version="1.0.118.0" targetFramework="net481" />
|
<package id="Stub.System.Data.SQLite.Core.NetFramework" version="1.0.118.0" targetFramework="net481" />
|
||||||
<package id="System.Data.SQLite" version="1.0.118.0" targetFramework="net481" />
|
<package id="System.Data.SQLite" version="1.0.118.0" targetFramework="net481" />
|
||||||
<package id="System.Data.SQLite.Core" version="1.0.118.0" targetFramework="net481" />
|
<package id="System.Data.SQLite.Core" version="1.0.118.0" targetFramework="net481" />
|
||||||
<package id="System.Data.SQLite.EF6" version="1.0.118.0" targetFramework="net481" />
|
<package id="System.Data.SQLite.EF6" version="1.0.118.0" targetFramework="net481" />
|
||||||
<package id="System.Data.SQLite.Linq" version="1.0.118.0" targetFramework="net481" />
|
<package id="System.Data.SQLite.Linq" version="1.0.118.0" targetFramework="net481" />
|
||||||
|
<package id="System.Drawing.Common" version="7.0.0" targetFramework="net481" />
|
||||||
<package id="System.IO" version="4.3.0" targetFramework="net481" />
|
<package id="System.IO" version="4.3.0" targetFramework="net481" />
|
||||||
<package id="WinFormAnimation" version="1.6.0.4" targetFramework="net481" />
|
<package id="WinFormAnimation" version="1.6.0.4" targetFramework="net481" />
|
||||||
|
<package id="ZXing.Net" version="0.16.9" targetFramework="net481" />
|
||||||
</packages>
|
</packages>
|
Loading…
Reference in New Issue
Block a user