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. ajax方法参数详解与$.each()和jquery里面each方法的区别

    JQuery中$.ajax()方法参数详解 url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址. type: 要求为String类型的参数,请求方式(post或get)默认为g ...

  2. uC/OS-II 函数之任务相关函数

    获得更多资料欢迎进入我的网站或者 csdn或者博客园 对于有热心的小伙伴在微博上私信我,说我的uC/OS-II 一些函数简介篇幅有些过于长应该分开介绍.应小伙伴的要求,特此将文章分开进行讲解.上文主要 ...

  3. 使用cookie下次自动登录

    登录时勾选了自动登录处理: 1.加密账号和IP,保存在cookie中,cookie('auto', $value, $time) 2.解密cookie,取出账号和上次IP,判断上次IP==当前IP.账 ...

  4. np.random.normal()

    高斯分布(Gaussian Distribution)的概率密度函数(probability density function): \[ f(x)=\frac1{\sqrt{2\pi}\sigma}\ ...

  5. java 使用idea将工程打成jar并创建成exe文件类型执行

    https://blog.csdn.net/weixin_38310965/article/details/80392767

  6. c++ 用 0x3f3f3f3f 设定最大int值的优点

    在许多算法中都要用到一个常量来表示最大值,例如:寻找一个最小数,就要先设定一个值a,如果比a小,a就等于这个数:再如,最短路径中基本的松弛操作: 0 在c++中可以用memset() 来初始化数组成最 ...

  7. STM32的GPIO工作原理 | 附电路图详细分析

    STM32的GPIO介绍 STM32引脚说明 GPIO是通用输入/输出端口的简称,是STM32可控制的引脚.GPIO的引脚与外部硬件设备连接,可实现与外部通讯.控制外部硬件或者采集外部硬件数据的功能. ...

  8. mysql 5.7 的 /etc/my.cnf

    mysql的my.cnf文件纯净版的.随意享用. # Example MySQL config file for medium systems. # # This is for a system wi ...

  9. linux vi文本编辑器三种模式切换及常用操作

    初学者刚进入vi不要乱点键盘,vi的三种模式和各种命令很容易弄混@@ vi编辑器是Unix系统最初的编辑器.它使用控制台图形模式来模拟文本编辑窗口,允许查看文件中的行.在文件中移动.插入.编辑和替换文 ...

  10. Cloudera Manager集群官方默认的各个组件开启默认顺序(图文详解)

    不多说,直接上干货! 如下是 Cloudera Manager集群官方默认的各个组件开启默认顺序. http://192.168.80.31:7180/cmf/clusters/1/express-a ...