天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

275 lines
11 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace QMAPP.WinForm.Forms.Common
{
public partial class TouchKey : Form
{
bool b = true; //true大写,false小写
TextBox txt;
ComboBox com;
public TouchKey()
{
InitializeComponent();
}
public TouchKey(TextBox txt)
{
InitializeComponent();
this.txt = txt;
this.Location = GetForm(txt).PointToScreen(new Point(txt.Location.X, txt.Location.Y + txt.Height+10));
}
public TouchKey(ComboBox com)
{
InitializeComponent();
this.com = com;
this.Location = GetForm(com).PointToScreen(new Point(com.Location.X, com.Location.Y + com.Height + 10));
}
private Form GetForm(TextBox t)
{
Control c = t;
while (c is Form == false)
{
c = c.Parent;
}
return (Form)c;
}
private Form GetForm(ComboBox t)
{
Control c = t;
while (c is Form == false)
{
c = c.Parent;
}
return (Form)c;
}
private void Form1_Load(object sender, EventArgs e)
{
lbl_0.Click += new EventHandler(lbl_Click);
lbl_1.Click += new EventHandler(lbl_Click);
lbl_2.Click += new EventHandler(lbl_Click);
lbl_3.Click += new EventHandler(lbl_Click);
lbl_4.Click += new EventHandler(lbl_Click);
lbl_5.Click += new EventHandler(lbl_Click);
lbl_6.Click += new EventHandler(lbl_Click);
lbl_7.Click += new EventHandler(lbl_Click);
lbl_8.Click += new EventHandler(lbl_Click);
lbl_9.Click += new EventHandler(lbl_Click);
lbl_Q.Click += new EventHandler(lbl_Click);
lbl_W.Click += new EventHandler(lbl_Click);
lbl_R.Click += new EventHandler(lbl_Click);
lbl_E.Click += new EventHandler(lbl_Click);
lbl_T.Click += new EventHandler(lbl_Click);
lbl_Y.Click += new EventHandler(lbl_Click);
lbl_U.Click += new EventHandler(lbl_Click);
lbl_I.Click += new EventHandler(lbl_Click);
lbl_O.Click += new EventHandler(lbl_Click);
lbl_P.Click += new EventHandler(lbl_Click);
lbl_A.Click += new EventHandler(lbl_Click);
lbl_S.Click += new EventHandler(lbl_Click);
lbl_D.Click += new EventHandler(lbl_Click);
lbl_F.Click += new EventHandler(lbl_Click);
lbl_G.Click += new EventHandler(lbl_Click);
lbl_H.Click += new EventHandler(lbl_Click);
lbl_J.Click += new EventHandler(lbl_Click);
lbl_K.Click += new EventHandler(lbl_Click);
lbl_L.Click += new EventHandler(lbl_Click);
lbl_Z.Click += new EventHandler(lbl_Click);
lbl_X.Click += new EventHandler(lbl_Click);
lbl_C.Click += new EventHandler(lbl_Click);
lbl_V.Click += new EventHandler(lbl_Click);
lbl_B.Click += new EventHandler(lbl_Click);
lbl_N.Click += new EventHandler(lbl_Click);
lbl_M.Click += new EventHandler(lbl_Click);
label44.Click += new EventHandler(label44_Click);
label9.Click += new EventHandler(label9_Click);
lbl_0.MouseDown += new MouseEventHandler(Down_Click);
lbl_1.MouseDown += new MouseEventHandler(Down_Click);
lbl_2.MouseDown += new MouseEventHandler(Down_Click);
lbl_3.MouseDown += new MouseEventHandler(Down_Click);
lbl_4.MouseDown += new MouseEventHandler(Down_Click);
lbl_5.MouseDown += new MouseEventHandler(Down_Click);
lbl_6.MouseDown += new MouseEventHandler(Down_Click);
lbl_7.MouseDown += new MouseEventHandler(Down_Click);
lbl_8.MouseDown += new MouseEventHandler(Down_Click);
lbl_9.MouseDown += new MouseEventHandler(Down_Click);
lbl_Q.MouseDown += new MouseEventHandler(Down_Click);
lbl_W.MouseDown += new MouseEventHandler(Down_Click);
lbl_R.MouseDown += new MouseEventHandler(Down_Click);
lbl_E.MouseDown += new MouseEventHandler(Down_Click);
lbl_T.MouseDown += new MouseEventHandler(Down_Click);
lbl_Y.MouseDown += new MouseEventHandler(Down_Click);
lbl_U.MouseDown += new MouseEventHandler(Down_Click);
lbl_I.MouseDown += new MouseEventHandler(Down_Click);
lbl_O.MouseDown += new MouseEventHandler(Down_Click);
lbl_P.MouseDown += new MouseEventHandler(Down_Click);
lbl_A.MouseDown += new MouseEventHandler(Down_Click);
lbl_S.MouseDown += new MouseEventHandler(Down_Click);
lbl_D.MouseDown += new MouseEventHandler(Down_Click);
lbl_F.MouseDown += new MouseEventHandler(Down_Click);
lbl_G.MouseDown += new MouseEventHandler(Down_Click);
lbl_H.MouseDown += new MouseEventHandler(Down_Click);
lbl_J.MouseDown += new MouseEventHandler(Down_Click);
lbl_K.MouseDown += new MouseEventHandler(Down_Click);
lbl_L.MouseDown += new MouseEventHandler(Down_Click);
lbl_Z.MouseDown += new MouseEventHandler(Down_Click);
lbl_X.MouseDown += new MouseEventHandler(Down_Click);
lbl_C.MouseDown += new MouseEventHandler(Down_Click);
lbl_V.MouseDown += new MouseEventHandler(Down_Click);
lbl_B.MouseDown += new MouseEventHandler(Down_Click);
lbl_N.MouseDown += new MouseEventHandler(Down_Click);
lbl_M.MouseDown += new MouseEventHandler(Down_Click);
label44.MouseDown += new MouseEventHandler(Down_Click);
label9.MouseDown += new MouseEventHandler(Down_Click);
lbl_0.MouseUp += new MouseEventHandler(Up_Click);
lbl_1.MouseUp += new MouseEventHandler(Up_Click);
lbl_2.MouseUp += new MouseEventHandler(Up_Click);
lbl_3.MouseUp += new MouseEventHandler(Up_Click);
lbl_4.MouseUp += new MouseEventHandler(Up_Click);
lbl_5.MouseUp += new MouseEventHandler(Up_Click);
lbl_6.MouseUp += new MouseEventHandler(Up_Click);
lbl_7.MouseUp += new MouseEventHandler(Up_Click);
lbl_8.MouseUp += new MouseEventHandler(Up_Click);
lbl_9.MouseUp += new MouseEventHandler(Up_Click);
lbl_Q.MouseUp += new MouseEventHandler(Up_Click);
lbl_W.MouseUp += new MouseEventHandler(Up_Click);
lbl_R.MouseUp += new MouseEventHandler(Up_Click);
lbl_E.MouseUp += new MouseEventHandler(Up_Click);
lbl_T.MouseUp += new MouseEventHandler(Up_Click);
lbl_Y.MouseUp += new MouseEventHandler(Up_Click);
lbl_U.MouseUp += new MouseEventHandler(Up_Click);
lbl_I.MouseUp += new MouseEventHandler(Up_Click);
lbl_O.MouseUp += new MouseEventHandler(Up_Click);
lbl_P.MouseUp += new MouseEventHandler(Up_Click);
lbl_A.MouseUp += new MouseEventHandler(Up_Click);
lbl_S.MouseUp += new MouseEventHandler(Up_Click);
lbl_D.MouseUp += new MouseEventHandler(Up_Click);
lbl_F.MouseUp += new MouseEventHandler(Up_Click);
lbl_G.MouseUp += new MouseEventHandler(Up_Click);
lbl_H.MouseUp += new MouseEventHandler(Up_Click);
lbl_J.MouseUp += new MouseEventHandler(Up_Click);
lbl_K.MouseUp += new MouseEventHandler(Up_Click);
lbl_L.MouseUp += new MouseEventHandler(Up_Click);
lbl_Z.MouseUp += new MouseEventHandler(Up_Click);
lbl_X.MouseUp += new MouseEventHandler(Up_Click);
lbl_C.MouseUp += new MouseEventHandler(Up_Click);
lbl_V.MouseUp += new MouseEventHandler(Up_Click);
lbl_B.MouseUp += new MouseEventHandler(Up_Click);
lbl_N.MouseUp += new MouseEventHandler(Up_Click);
lbl_M.MouseUp += new MouseEventHandler(Up_Click);
label44.MouseUp += new MouseEventHandler(Up_Click);
label9.MouseUp += new MouseEventHandler(Up_Click);
}
void label44_Click(object sender, EventArgs e)
{
Label l = (Label)sender;
if (txt != null)
{
if (txt.Text.Length > 0)
{
txt.Text = txt.Text.Substring(0, txt.Text.Length - 1);
}
txt.SelectionStart = txt.Text.Length;
}
if (com != null)
{
if (com.Text.Length > 0)
{
com.Text = com.Text.Substring(0, com.Text.Length - 1);
}
com.SelectionStart = com.Text.Length;
}
}
void lbl_Click(object sender, EventArgs e)
{
Label l = (Label)sender;
if (txt != null)
{
if (b)
{
txt.Text += l.Name.Substring(4, 1);
}
else
{
txt.Text += l.Name.Substring(4, 1).ToLower();
}
txt.SelectionStart = txt.Text.Length;
}
if (com != null)
{
if (b)
{
com.Text += l.Name.Substring(4, 1);
}
else
{
com.Text += l.Name.Substring(4, 1).ToLower();
}
com.SelectionStart = com.Text.Length;
}
}
void Down_Click(object sender, MouseEventArgs e)
{
Label l = (Label)sender;
l.BorderStyle = BorderStyle.Fixed3D;
}
void Up_Click(object sender, MouseEventArgs e)
{
Label l = (Label)sender;
l.BorderStyle = BorderStyle.None;
}
private void label1_Click(object sender, EventArgs e)
{
Close();
}
private void label9_Click(object sender, EventArgs e)
{
if (b == true)
{
b = false;
this.panel1.BackgroundImage = QMAPP.WinForm.Resource1._3;
}
else
{
b = true;
this.panel1.BackgroundImage = QMAPP.WinForm.Resource1._2;
}
}
private Point mPoint = new Point();
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
mPoint.X = e.X;
mPoint.Y = e.Y;
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Point myPosittion = MousePosition;
myPosittion.Offset(-mPoint.X, -mPoint.Y);
Location = myPosittion;
}
}
}
}