基本信息
源码名称:C#手写识别程序源码ShouXieShiBiep
源码大小:0.80M
文件格式:.zip
开发语言:C#
更新时间:2018-05-19
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
C#手写识别程序源码ShouXieShiBie_
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; using Microsoft.Ink; using System.Collections.Specialized; using System.Runtime.InteropServices; namespace 手写识别 { public partial class Form1 : Form { InkCollector ic; RecognizerContext rct; string FullCACText; public Form1() { InitializeComponent(); } [DllImport("user32.dll")] public static extern int SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong); [DllImport("user32.dll", SetLastError = true)] public static extern UInt32 GetWindowLong(IntPtr hWnd, int nIndex); private void Form1_Load(object sender, EventArgs e) { ic = new InkCollector(ink_here.Handle); ic.Stroke = new InkCollectorStrokeEventHandler(ic_Stroke); ic.Enabled = true; ink_(); this.rct.RecognitionWithAlternates = new RecognizerContextRecognitionWithAlternatesEventHandler(rct_RecognitionWithAlternates); rct.Strokes = ic.Ink.Strokes; //// style of window? //int GWL_EXSTYLE = (-20); //// get - retrieves information about a specified window //GetWindowLong(this.Handle, GWL_EXSTYLE); //// set - changes the attribute of a specified window - I think this stops it being focused on //SetWindowLong(this.Handle, GWL_EXSTYLE, (IntPtr)(0x8000000)); } void rct_RecognitionWithAlternates(object sender, RecognizerContextRecognitionWithAlternatesEventArgs e) { string ResultString = ""; RecognitionAlternates alts; if (e.RecognitionStatus == RecognitionStatus.NoError) { alts = e.Result.GetAlternatesFromSelection(); foreach (RecognitionAlternate alt in alts) { ResultString = ResultString alt.ToString() " "; } } FullCACText = ResultString.Trim(); Control.CheckForIllegalCrossThreadCalls = false; textBox1.Text = FullCACText; Control.CheckForIllegalCrossThreadCalls = true; } void ic_Stroke(object sender, InkCollectorStrokeEventArgs e) { rct.StopBackgroundRecognition(); rct.Strokes.Add(e.Stroke); rct.CharacterAutoCompletion = RecognizerCharacterAutoCompletionMode.Full; rct.BackgroundRecognizeWithAlternates(0); } private void ink_() { Recognizers recos = new Recognizers(); Recognizer chineseReco = recos.GetDefaultRecognizer(); rct = chineseReco.CreateRecognizerContext(); } private void button3_Click(object sender, EventArgs e) { colorDialog1.FullOpen = true; colorDialog1.ShowDialog(); ic.DefaultDrawingAttributes.Color = colorDialog1.Color; } private void button2_Click(object sender, EventArgs e) { if (!ic.CollectingInk) { Strokes strokesToDelete = ic.Ink.Strokes; rct.StopBackgroundRecognition(); ic.Ink.DeleteStrokes(strokesToDelete); rct.Strokes = ic.Ink.Strokes; ic.Ink.DeleteStrokes();//清除手写区域笔画; ink_here.Refresh();//刷新手写区域 textBox1.Text = ""; } } private void button1_Click(object sender, EventArgs e) { Ink ink = ic.Ink; string str = ic.Ink.Strokes.ToString(); textBox1.SelectedText = ic.Ink.Strokes.ToString(); } private void button4_Click(object sender, EventArgs e) { System.Windows.Forms.SendKeys.SendWait("{s}{h}{i}"); } private void textBox1_TextChanged(object sender, EventArgs e) { } private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { System.Windows.Forms.SendKeys.SendWait("{" e.KeyChar "}"); } } }