📄 numberpickerinput.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace WATestPGB
{
/// <summary>
/// This represents the input form for the NumberPicker control. Using
/// the class allows to better specify the values and do calculations at
/// the same time
/// </summary>
public class NumberPickerInput : System.Windows.Forms.Form
{
private System.Windows.Forms.Button buttonBackspace;
private System.Windows.Forms.Button buttonClear;
private System.Windows.Forms.Button buttonDecimalSeparator;
private System.Windows.Forms.Button button0;
private System.Windows.Forms.Button buttonPlusMinus;
private System.Windows.Forms.Button buttonPlus;
private System.Windows.Forms.Button buttonMinus;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button buttonTimes;
private System.Windows.Forms.Button button6;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button buttonDivide;
private System.Windows.Forms.Button button9;
private System.Windows.Forms.Button button8;
private System.Windows.Forms.Button button7;
private System.Windows.Forms.Button buttonEquals;
/// <summary>
/// A delegate for an arithmetic function taking two double arguments
/// </summary>
private delegate double Function(double a, double b);
/// <summary>
/// Specifies whether the field should be cleared or not
/// </summary>
private bool clear;
/// <summary>
/// A temporary value to be remembered when calculating the arithmetic functions
/// </summary>
private double temporary;
/// <summary>
/// A pointer to the actual textbox used for updating
/// </summary>
private System.Windows.Forms.TextBox result;
/// <summary>
/// A function pointer holding the last function which has been pressed in the calculator window
/// </summary>
private Function f;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
/// <summary>
/// The default constructor for the input form to be used in the
/// NumberPicker control
/// </summary>
public NumberPickerInput(System.Windows.Forms.TextBox result)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
this.buttonDecimalSeparator.Text = System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator;
this.result = result;
this.temporary = 0;
this.clear = false;
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(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.buttonBackspace = new System.Windows.Forms.Button();
this.buttonClear = new System.Windows.Forms.Button();
this.button0 = new System.Windows.Forms.Button();
this.buttonDecimalSeparator = new System.Windows.Forms.Button();
this.buttonPlusMinus = new System.Windows.Forms.Button();
this.buttonPlus = new System.Windows.Forms.Button();
this.buttonMinus = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.buttonTimes = new System.Windows.Forms.Button();
this.button6 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.buttonDivide = new System.Windows.Forms.Button();
this.button9 = new System.Windows.Forms.Button();
this.button8 = new System.Windows.Forms.Button();
this.button7 = new System.Windows.Forms.Button();
this.buttonEquals = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// buttonBackspace
//
this.buttonBackspace.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.buttonBackspace.Location = new System.Drawing.Point(29, 103);
this.buttonBackspace.Name = "buttonBackspace";
this.buttonBackspace.Size = new System.Drawing.Size(38, 25);
this.buttonBackspace.TabIndex = 56;
this.buttonBackspace.Text = "<-";
this.buttonBackspace.Click += new System.EventHandler(this.buttonBackspace_Click);
//
// buttonClear
//
this.buttonClear.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.buttonClear.Location = new System.Drawing.Point(0, 103);
this.buttonClear.Name = "buttonClear";
this.buttonClear.Size = new System.Drawing.Size(28, 25);
this.buttonClear.TabIndex = 55;
this.buttonClear.Text = "C";
this.buttonClear.Click += new System.EventHandler(this.buttonClear_Click);
//
// button0
//
this.button0.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button0.Location = new System.Drawing.Point(0, 78);
this.button0.Name = "button0";
this.button0.Size = new System.Drawing.Size(28, 24);
this.button0.TabIndex = 54;
this.button0.Text = "0";
this.button0.Click += new System.EventHandler(this.button0_Click);
//
// buttonDecimalSeparator
//
this.buttonDecimalSeparator.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.buttonDecimalSeparator.Location = new System.Drawing.Point(29, 78);
this.buttonDecimalSeparator.Name = "buttonDecimalSeparator";
this.buttonDecimalSeparator.Size = new System.Drawing.Size(27, 24);
this.buttonDecimalSeparator.TabIndex = 53;
this.buttonDecimalSeparator.Click += new System.EventHandler(this.buttonDecimalSeparator_Click);
//
// buttonPlusMinus
//
this.buttonPlusMinus.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.buttonPlusMinus.Location = new System.Drawing.Point(58, 78);
this.buttonPlusMinus.Name = "buttonPlusMinus";
this.buttonPlusMinus.Size = new System.Drawing.Size(27, 24);
this.buttonPlusMinus.TabIndex = 52;
this.buttonPlusMinus.Text = "+-";
this.buttonPlusMinus.Click += new System.EventHandler(this.buttonPlusMinus_Click);
//
// buttonPlus
//
this.buttonPlus.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.buttonPlus.Location = new System.Drawing.Point(86, 78);
this.buttonPlus.Name = "buttonPlus";
this.buttonPlus.Size = new System.Drawing.Size(28, 24);
this.buttonPlus.TabIndex = 51;
this.buttonPlus.Text = "+";
this.buttonPlus.Click += new System.EventHandler(this.buttonPlus_Click);
//
// buttonMinus
//
this.buttonMinus.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.buttonMinus.Location = new System.Drawing.Point(86, 52);
this.buttonMinus.Name = "buttonMinus";
this.buttonMinus.Size = new System.Drawing.Size(28, 24);
this.buttonMinus.TabIndex = 50;
this.buttonMinus.Text = "-";
this.buttonMinus.Click += new System.EventHandler(this.buttonMinus_Click);
//
// button3
//
this.button3.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button3.Location = new System.Drawing.Point(58, 52);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(27, 24);
this.button3.TabIndex = 49;
this.button3.Text = "3";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button2
//
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button2.Location = new System.Drawing.Point(29, 52);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(27, 24);
this.button2.TabIndex = 48;
this.button2.Text = "2";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button1
//
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button1.Location = new System.Drawing.Point(0, 52);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(28, 24);
this.button1.TabIndex = 47;
this.button1.Text = "1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// buttonTimes
//
this.buttonTimes.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.buttonTimes.Location = new System.Drawing.Point(86, 26);
this.buttonTimes.Name = "buttonTimes";
this.buttonTimes.Size = new System.Drawing.Size(28, 25);
this.buttonTimes.TabIndex = 46;
this.buttonTimes.Text = "*";
this.buttonTimes.Click += new System.EventHandler(this.buttonTimes_Click);
//
// button6
//
this.button6.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button6.Location = new System.Drawing.Point(58, 26);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(27, 25);
this.button6.TabIndex = 45;
this.button6.Text = "6";
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// button5
//
this.button5.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button5.Location = new System.Drawing.Point(29, 26);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(27, 25);
this.button5.TabIndex = 44;
this.button5.Text = "5";
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// button4
//
this.button4.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button4.Location = new System.Drawing.Point(0, 26);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(28, 25);
this.button4.TabIndex = 43;
this.button4.Text = "4";
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// buttonDivide
//
this.buttonDivide.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.buttonDivide.Location = new System.Drawing.Point(86, 0);
this.buttonDivide.Name = "buttonDivide";
this.buttonDivide.Size = new System.Drawing.Size(28, 25);
this.buttonDivide.TabIndex = 42;
this.buttonDivide.Text = "/";
this.buttonDivide.Click += new System.EventHandler(this.buttonDivide_Click);
//
// button9
//
this.button9.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button9.Location = new System.Drawing.Point(58, 0);
this.button9.Name = "button9";
this.button9.Size = new System.Drawing.Size(27, 25);
this.button9.TabIndex = 41;
this.button9.Text = "9";
this.button9.Click += new System.EventHandler(this.button9_Click);
//
// button8
//
this.button8.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button8.Location = new System.Drawing.Point(29, 0);
this.button8.Name = "button8";
this.button8.Size = new System.Drawing.Size(27, 25);
this.button8.TabIndex = 40;
this.button8.Text = "8";
this.button8.Click += new System.EventHandler(this.button8_Click);
//
// button7
//
this.button7.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button7.Location = new System.Drawing.Point(0, 0);
this.button7.Name = "button7";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -