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的更多相关文章

  1. 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 ...

  2. Javascript code for soft keyboard

    <style>     BODY {     SCROLLBAR-FACE-COLOR: #f0f0f6; FONT-SIZE: 9pt; BACKGROUND-ATTACHMENT: f ...

  3. 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 ...

  4. 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. ...

  5. Xamarin.Forms 开发资源集合(复制)

    复制:https://www.cnblogs.com/mschen/p/10199997.html 收集整理了下 Xamarin.Forms 的学习参考资料,分享给大家,稍后会不断补充: UI样式 S ...

  6. Xamarin.Forms 开发资源集合

    收集整理了下 Xamarin.Forms 的学习参考资料,分享给大家,稍后会不断补充: UI样式 Snppts: Xamarin Forms UI Snippets. Prebuilt Templat ...

  7. 揭秘uc浏览器一

    首先,看一下项目完成后的,最终效果是这样的: 一.主界面 二,书签界面 三.主界面 四.操作对话框界面 这几个界面你是否看到了uc浏览器的影子了,其实我说你也可以了,在接下来篇幅中,我将手把手叫大家完 ...

  8. [Android开发学iOS系列] 工具篇: Xcode使用和快捷键

    [Android开发学iOS系列] 工具篇: Xcode使用和快捷键 工欲善其事必先利其器. 编辑 Cmd + N: 新建文件 Option + Cmd + N: 新建文件夹 Cmd + / : 注释 ...

  9. Android中点击隐藏软键盘最佳方法——Android开发之路4

    Android中点击隐藏软键盘最佳方法 实现功能:点击EditText,软键盘出现并且不会隐藏,点击或者触摸EditText以外的其他任何区域,软键盘被隐藏: 1.重写dispatchTouchEve ...

随机推荐

  1. Levenshtein字符串距离算法介绍

    Levenshtein字符串距离算法介绍 文/开发部 Dimmacro KMP完全匹配算法和 Levenshtein相似度匹配算法是模糊查找匹配字符串中最经典的算法,配合近期技术栏目关于算法的探讨,上 ...

  2. spring quartz 的定时器cronExpression表达式写法(转载)

    转载来源:https://zhidao.baidu.com/question/240797777248343764.html====================================== ...

  3. svn命令行的使用

    只是说一下,svn平时工作时常用的命令 1.svn delete 目录 删除svn版本里的相关目录 2.svn add 目录 将本地的目录添加到svn版本信息里 3.svn commit 目录 提交s ...

  4. JAVA数据结构--二叉查找树

    二叉查找树定义 二叉查找树(英语:Binary Search Tree),也称二叉搜索树.有序二叉树(英语:ordered binary tree),排序二叉树(英语:sorted binary tr ...

  5. head first

      1, insert 单引号时,使用/转义 2, 不要用NULL, 查找时使用isNull 来判断. 3, 用and / or 连接两个not 时,要写两个NOT 4,delete from tab ...

  6. Python爬虫常用之登录(三) 使用http请求登录

    前面说了使用浏览器登录较为简单,不需要过多分析,而使用请求登录恰恰就是以分析为主. 开发一个请求登录程序的流程: 分析请求->模拟请求->测试登录->调整参数->测试登录-&g ...

  7. dsad

    dasdas dasdas dasdas dasdas

  8. 关于cmdbuild

    哪位大神用过cmdbuild,网上的资料非常少,而且都是关于如何安装的,就在这少只又少的文章里,居然还都是互抄的,哎!!!

  9. 《数据密集型应用系统设计》读书笔记-ch1可靠、可扩展与可维护的应用系统

    我们以Twitter为例,使用其2012年11月发布的数据.Twitter的两个典型业务操作是: - 发布tweet消息: 用户可以快速推送新消息到所有的关注者,平均大约4.6k request/se ...

  10. python在读取配置文件存入列表中,去掉回车符号

    self.receiver = map(lambda x: x.strip(), receiver_list) # 去掉list中的回车符号