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. 可变参数中size_t遇见的问题

    在修改php扩展Trie时,出现了一个小bug PHP_FUNCTION(trie_filter_load) { Trie *trie; char *path; int path_len; if (z ...

  2. ionic 学习 一

    ionic 依赖angular.在学之前,我对angular进行了一下入门. 最近在看ionic,想做一些笔记,所以,写下这个随笔,有什么不对的请多多指教,刚开始学,后面还会学Apache Cordo ...

  3. Requests库请求网站

    安装requests库 pip install requests 1.使用GET方式抓取数据: import requests #导入requests库 url="http://www.cn ...

  4. js-查找字符串中出现次数最多的字符

    假设有一个字符串,下面让我们一起来查找出现次数最多的字符 var str = 'asdfssaaasasasasaa'; 首先,我们定义一个Object用来存放拆分的字符串,然后遍历字符串. 判断ob ...

  5. day0201

    #1.使用while循环输入 1 2 3 4 5 6 8 9 10'''count = 0while count < 10: count += 1 # count = count + 1 if ...

  6. Jmeter将JDBC Request查询结果作为下一个接口参数方法(转载)

    现在有一个需求,从数据库tieba_info表查出rank小于某个值的username和count(*),然后把所有查出来的username和count(*)作为参数值,用于下一个接口. tieba_ ...

  7. train loss与test loss结果分析

    train loss 不断下降,test loss不断下降,说明网络仍在学习; train loss 不断下降,test loss趋于不变,说明网络过拟合; train loss 趋于不变,test ...

  8. 苹果Air A1466进入系统黑屏

    现象:苹果Air A1466笔记本安装Windows 7系统后,安装官网对应型号的bootcamp后,重启机器,在Windows滚动条完成后随即进入黑屏状态,安全模式能够进入,在安全模式下卸载删除显卡 ...

  9. 矩阵&&高斯消元

    矩阵运算: \(A\times B\)叫做\(A\)左乘\(B\),或者\(B\)右乘\(A\). 行列式性质: \(1.\)交换矩阵的两行(列),行列式取相反数. \(2.\)某一行元素都\(\ti ...

  10. Math.round、Math.floor、Math.ceil 区别

    1.Math.round() 按照四舍五入的方式返回值 例如:Math.round(9.5)=10    Math.round(9.4)=9 2.Math.floor()返回最小整数 例如:Math. ...