📄 confirm.cs
字号:
namespace SerialPorts
{
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
public class Confirm : Form
{
// Methods
public Confirm()
{
this.components = null;
this.status = false;
this.InitializeComponent();
}
private void CmdCancel_Click(object sender, EventArgs e)
{
this.status = false;
base.Close();
}
private void CmdConfirm_Click(object sender, EventArgs e)
{
this.status = true;
base.Close();
}
public bool Display(string str)
{
this.Message.Text = str;
base.Select();
base.ShowDialog();
return this.status;
}
public bool Display(string str, int yesno)
{
this.CmdCancel.Text = "No";
this.CmdConfirm.Text = "Yes";
this.Message.Text = str;
base.Select();
base.ShowDialog();
return this.status;
}
public bool Display(string hdr, string str)
{
this.Text = hdr;
this.Message.Text = str;
base.Select();
base.ShowDialog();
return this.status;
}
public bool Display(string hdr, string str, int yesno)
{
this.Text = hdr;
this.CmdCancel.Text = "&No";
this.CmdConfirm.Text = "&Yes";
this.Message.Text = str;
base.Select();
base.ShowDialog();
return this.status;
}
protected override void Dispose(bool disposing)
{
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.Message = new Label();
this.CmdConfirm = new Button();
this.CmdCancel = new Button();
base.SuspendLayout();
this.Message.BackColor = SystemColors.Info;
this.Message.BorderStyle = BorderStyle.Fixed3D;
this.Message.Font = new Font("Microsoft Sans Serif", 8f, FontStyle.Regular, GraphicsUnit.Point, 0);
this.Message.ForeColor = SystemColors.ControlText;
this.Message.Location = new Point(0, 0);
this.Message.Name = "Message";
this.Message.Size = new Size(280, 0x4b);
this.Message.TabIndex = 0;
this.Message.TextAlign = ContentAlignment.MiddleCenter;
this.CmdConfirm.Font = new Font("Microsoft Sans Serif", 8f, FontStyle.Regular, GraphicsUnit.Point, 0);
this.CmdConfirm.Location = new Point(0x20, 90);
this.CmdConfirm.Name = "CmdConfirm";
this.CmdConfirm.Size = new Size(0x60, 0x25);
this.CmdConfirm.TabIndex = 1;
this.CmdConfirm.Text = "\u786e\u5b9a(&Confirm)";
this.CmdConfirm.Click += new EventHandler(this.CmdConfirm_Click);
this.CmdConfirm.KeyUp += new KeyEventHandler(this.KeyPressHandler);
this.CmdCancel.Font = new Font("Microsoft Sans Serif", 8f, FontStyle.Regular, GraphicsUnit.Point, 0);
this.CmdCancel.Location = new Point(0x98, 90);
this.CmdCancel.Name = "CmdCancel";
this.CmdCancel.Size = new Size(0x60, 0x25);
this.CmdCancel.TabIndex = 2;
this.CmdCancel.Text = "\u5173 \u95ed(C&ancel)";
this.CmdCancel.Click += new EventHandler(this.CmdCancel_Click);
this.CmdCancel.KeyUp += new KeyEventHandler(this.KeyPressHandler);
this.AutoScaleBaseSize = new Size(6, 14);
base.ClientSize = new Size(280, 130);
base.ControlBox = false;
base.Controls.Add(this.CmdCancel);
base.Controls.Add(this.CmdConfirm);
base.Controls.Add(this.Message);
base.FormBorderStyle = FormBorderStyle.Fixed3D;
base.MaximizeBox = false;
base.MinimizeBox = false;
base.Name = "Confirm";
base.StartPosition = FormStartPosition.CenterScreen;
this.Text = "\u8bbe\u7f6e";
base.KeyUp += new KeyEventHandler(this.KeyPressHandler);
base.ResumeLayout(false);
}
private void KeyPressHandler(object sender, KeyEventArgs e)
{
int num1 = e.KeyValue;
if ((num1 == 0x43) || (num1 == 0x59))
{
this.status = true;
}
if ((num1 == 0x61) || (num1 == 0x4e))
{
this.status = false;
}
base.Close();
}
// Fields
private Button CmdCancel;
private Button CmdConfirm;
private Container components;
private Label Message;
private bool status;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -