Create a soft keyboard
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; namespace keyboardDemo
{
public partial class Form1 : Form
{ /// <summary>
/// 涂聚文
/// 软键盘http://code.msdn.microsoft.com/CSSoftKeyboard-0a86f914
/// </summary>
public Form1()
{
InitializeComponent();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Form1_Load(object sender, EventArgs e)
{ }
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
Form2 f = new Form2();
f.Press += MiniKeyboardHandler;
f.ShowDialog();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MiniKeyboardHandler(object sender, MiniKeyboardArgs e)
{
if (this.textBox1.Text == "←backpspace")
{
if (this.textBox1.Text.Length != )
{ } }
else
{
textBox1.Text += e.KeyCode;
string s = this.textBox1.Text;
if (s.Contains("←backpspace"))//去除一个字符串
{
s = s.Replace("←backpspace", "");
if (s.Length > )
{
s = s.Substring(, s.Length - );
this.textBox1.Text = s;
}
else
{
this.textBox1.Text = s;
}
} } }
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; namespace keyboardDemo
{
public partial class Form2 : Form
{
bool isShift = true;
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public delegate void MiniKeyboardHandler(object sender, MiniKeyboardArgs e);
/// <summary>
///
/// </summary>
public event MiniKeyboardHandler Press; /// <summary>
///
/// </summary>
private void BindEvent()
{
foreach (Control ctl in this.Controls)
{
if (ctl is Button)
ctl.Click += MinikeyboardPress;
}
}
/// <summary>
///
/// </summary>
public Form2()
{
InitializeComponent();
BindEvent();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Form2_Load(object sender, EventArgs e)
{ }
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MinikeyboardPress(object sender, EventArgs e)
{
//大小写
if (((Button)sender).Text == "Shift")
{
if (isShift == true)
{
isShift = false;
string s = this.button1.Text;
s = s.ToUpper();
this.button1.Text = s;
}
else
{
isShift = true;
string s = this.button1.Text;
s = s.ToLower();
this.button1.Text = s;
}
}
else
{
OnMiniKeyboardHandle(new MiniKeyboardArgs(((Button)sender).Text));
} }
/// <summary>
///
/// </summary>
/// <param name="e"></param>
private void OnMiniKeyboardHandle(MiniKeyboardArgs e)
{
MiniKeyboardHandler temp = Press;
if (temp != null)
temp(this, e);
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button6_Click(object sender, EventArgs e)
{
//if (isShift == true)
//{
// isShift = false;
// this.button1.Text.ToUpper();
//}
//else
//{
// isShift = true;
//}
}
} /// <summary>
///
/// </summary>
public class MiniKeyboardArgs : EventArgs
{
public string KeyCode { get; private set; } public MiniKeyboardArgs(string code)
{
if (code == "←backpspace")
{
if (code.Length != )
{
KeyCode = code;
}
else
{
KeyCode = code;
//KeyCode = "";Caps Lock
}
}
else if (code == "Shift")
{
KeyCode = ""; }
else if (code == "Caps Lock")
{
KeyCode = ""; }
else
{
KeyCode = code;
}
}
} }
/// <summary>
///
/// </summary>
public Form1()
{
InitializeComponent();
//在TEXTBOX控件中加一个按钮控件,如QQ软键盘一样的图标
this.textBox1.Controls.Add(DropButton);
DropButton.Location = new Point(this.textBox1.Width - , ); }
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Form1_Load(object sender, EventArgs e)
{ }
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DropButton_Click(object sender, EventArgs e)
{
//MessageBox.Show("erro");
Form2 f = new Form2();
f.StartPosition = FormStartPosition.Manual;//窗体位置设置
f.Location = new Point(this.Location.X / + this.textBox1.Location.X + , this.Location.Y / + this.textBox1.Height + this.Height / +);//位置设置
f.Press += MiniKeyboardHandler;
f.ShowDialog(); }
Create a soft keyboard的更多相关文章
- mkdir: cannot create directory ‘/soft/hadoop-2.7.3/logs’: Permission denied问题
启动hadoop时,报错“mkdir: cannot create directory ‘/soft/hadoop-2.7.3/logs’: Permission denied” 注:/soft/ha ...
- Javascript code for soft keyboard
<style> BODY { SCROLLBAR-FACE-COLOR: #f0f0f6; FONT-SIZE: 9pt; BACKGROUND-ATTACHMENT: f ...
- Linux / UNIX create soft link with ln command
How to: Linux / UNIX create soft link with ln command by NIXCRAFT on SEPTEMBER 25, 2007 · 42 COMMENT ...
- Difference between a Hard Link and Soft (Symbolic) Link
Within the Unix/Linux file system, linking lets you create file shortcuts to link one or more files. ...
- Xamarin.Forms 开发资源集合(复制)
复制:https://www.cnblogs.com/mschen/p/10199997.html 收集整理了下 Xamarin.Forms 的学习参考资料,分享给大家,稍后会不断补充: UI样式 S ...
- Xamarin.Forms 开发资源集合
收集整理了下 Xamarin.Forms 的学习参考资料,分享给大家,稍后会不断补充: UI样式 Snppts: Xamarin Forms UI Snippets. Prebuilt Templat ...
- 揭秘uc浏览器一
首先,看一下项目完成后的,最终效果是这样的: 一.主界面 二,书签界面 三.主界面 四.操作对话框界面 这几个界面你是否看到了uc浏览器的影子了,其实我说你也可以了,在接下来篇幅中,我将手把手叫大家完 ...
- [Android开发学iOS系列] 工具篇: Xcode使用和快捷键
[Android开发学iOS系列] 工具篇: Xcode使用和快捷键 工欲善其事必先利其器. 编辑 Cmd + N: 新建文件 Option + Cmd + N: 新建文件夹 Cmd + / : 注释 ...
- Android中点击隐藏软键盘最佳方法——Android开发之路4
Android中点击隐藏软键盘最佳方法 实现功能:点击EditText,软键盘出现并且不会隐藏,点击或者触摸EditText以外的其他任何区域,软键盘被隐藏: 1.重写dispatchTouchEve ...
随机推荐
- inception_web
1) wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py 2) python ez_setup.py --insecur ...
- 来自Ch大学时期的第一份随笔!
首先,还是挺开心的!因为在大学时间总算可以脱离一点高中时期的感觉,不用再上交纸质作业(这也是我为什么要选计算机专业的原因).其次就是,大学生活总算开始有一些不一样了!学习了近两年程序语言的我们,总算可 ...
- Linux/Windows 平台最容易安装 Composer教程
我们采用的是全局安装方式,这样的话,就能够在命令行窗口中直接执行 composer 命令了. Mac 或 Linux 系统: 打开命令行窗口并执行如下命令将前面下载的 composer.phar 文件 ...
- node.js调试方法
第一种方式:node内置的调试器 在程序中添加debugger,然后在启动node程序时,使用debug模式启动 1.node debug my_event.js 2.使用node文档中各种命令,进行 ...
- 【Leetcode】Binary Tree Traversal
把三个二叉树遍历的题放在一起了. 递归写法太简单,就不再实现了,每题实现了两种非递归算法. 一种是利用栈,时间和空间复杂度都是O(n). 另一种是借助线索二叉树,也叫Morris遍历,充分利用树中节点 ...
- train loss与test loss结果分析
train loss 不断下降,test loss不断下降,说明网络仍在学习; train loss 不断下降,test loss趋于不变,说明网络过拟合; train loss 趋于不变,test ...
- 自动化测试接口PYTHON
在开发测试中经常会遇到接口迭代和代码重构,一个无关紧要的改动往往会引起整个项目的运行.现有的接口测试中往往只是针对单一接口的测试,可是业务的连贯性是非常紧密的,比如:用户从登陆,获取商品信息,下单 ...
- ionic3 引入第三方库(jquery)
安装 npm install jquery npm install @types/jquery 在需要的ts文件中引入,一定要在最顶端 import * as $ from '../../../nod ...
- vue相关问题在工作中的问题及ui组件及html样式搭建相关网站下载资源
https://youzan.github.io/vant/#/zh-CN/nav-bar http://www.builive.com/docs/api/index.html bui框架BUI ...
- java练习题:现给出二组字符串,比较他们看是否相等
import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import jav ...