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 ...
随机推荐
- UITableViewCell笔记
默认的四种cell的类型 原网站 还有这个带图的 据我自己试验,只有value2不自带imageview 不同的accessoryType 可以看到,一个tabelviewcell的contentvi ...
- MVC 提交List 集合 注意对应的参数名称
public void AddMovieInfos(List<MoviesInfo> movies) { foreach (var item in movies) { dal.Add(it ...
- [原创] 项目 watch EMFILE 报错处理过程
目录 事件 处理过程 参考资料 小知识点 单进程文件句柄限制 系统总文件句柄限制 inotify 文件系统事件监控 事件 公司XX游戏 S114服启动失败(使用 pomelo - node.js 框架 ...
- springboot设置日志级别时报错
配置springboot日志,输出级别为info,运行时报错: Caused by: org.springframework.boot.context.properties.bind.BindExce ...
- [JSOI2018]机器人
[Luogu4558] [LOJ2550] \(19.3.25\) JSOI2018简要题解 - FallDream 规律就是 对于\(n=m\)我们每一条左下到右上的对角线上的点的走法都是一样的且每 ...
- 高阶篇:5)仿真研究Simulation studies
本章目的:了解仿真,初步学会怎么应用仿真. 1.仿真的定义 仿真------就是用模型(物理模型或数学模型)代替实际系统进行实验和研究. 把实际系统建立成物理模型或数学模型进行研究,然后把对模型实 ...
- 知了课堂 Python Flask零基础 笔记整理
目录 起步 安装Python2.7: Python虚拟环境介绍与安装: pip安装flask: 认识url: URL详解 web服务器和应用服务器以及web应用框架: Flask 第一个flask程序 ...
- linux系统管理(1)之 内核编译选项查看
三个方法 proc文件系统 ubunut debain 红帽等 proc文件系统 /proc/config.gz This file shows you the compile-time config ...
- vue-tree 组织架构图/树形图自动生成(含添加、删除、修改)
项目中用代码生成组织架构图 有新增,编辑,删除的功能 生成树形图的组件git-hub地址: https://github.com/tower1229/Vue-Tree-Char ...
- jsp、Servlet的面试题
3. 谈谈Servlet的生命周期 当接收到请求的时候,容器察看对应的Servlet对象是否存在,如果不存在,需要加载Servetl,实例化Servlet,调用init方法进行初始化.如果已经存在,根 ...