📄 form1.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace 最后软键盘
{
public partial class log : Form
{
int i = 0;
int j = 0;
int x = 36;
int y = 167;
char[,] keyboard ={
{'1','2','3','4','5','6','7','8','9'},
{'0','a','b','c','d','e','f','g','h'},
{'i','j','k','l','m','n','o','p','q'},
{'r','s','t','u','v','w','x','y','z'}
};
public log()
{
InitializeComponent();
}
private void log_Load(object sender, EventArgs e)
{
textBox1.Focus();
NewDrawing(i ,j);
}
private void log_KeyDown(object sender, KeyEventArgs e)
{
int oi = i;
int oj = j;
switch (e.KeyCode)
{
case Keys.Up:
i = i - 1;
if (i < 0)
i = 3;
break;
case Keys.Down:
i = i + 1;
if (i == 4)
i = 0;
break;
case Keys.Left:
j = j - 1;
if (j < 0)
j = 8;
break;
case Keys.Right:
j = j + 1;
if (j == 9)
j = 0;
break;
case Keys.Enter:
EchoEnter();
break;
}
OldDrawing(oi,oj);
NewDrawing(i, j);
}
//画新框函数
private void NewDrawing(int i ,int j)
{
x = 36 * j+36;
y = 36 * i+167;
Pen mypen = new Pen(Color.Gold ,3);
Graphics grapic = this.CreateGraphics () ;
//grapic.Clear(Color.White);
grapic.DrawRectangle (mypen ,new Rectangle (x,y,30,30));
grapic.Dispose();
mypen.Dispose();
}
//改旧框函数
private void OldDrawing(int i, int j)
{
x = 36 * j + 36;
y = 36 * i + 167;
Pen mypen = new Pen(Color.Gray , 3);
Graphics grapic = this.CreateGraphics();
grapic.DrawRectangle(mypen, new Rectangle(x, y, 30, 30));
grapic.Dispose();
mypen.Dispose();
}
//处理enter事件
private int EchoEnter()
{
if (textBox1.Focused == true)
{
string w = textBox1.Text;
//textBox1.Clear();
textBox1.Text =w+keyboard[i, j].ToString();
}
else if (textBox2.Focused == true)
{
string w = textBox2.Text;
textBox2.Text = w+keyboard[i, j].ToString();
}
else if (button1.Focused == true)
SendMessage();
else if (button2.Focused == true)
this.Close();
return 0;
}
//发送student的用户名和密码给服务器
private void SendMessage()
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -