WPF Handwriting .NET 4.5 Windows 8: Missing IAWinFX.dll and others

走远了吗. 提交于 2019-12-01 06:30:48

问题


I am trying to use text recognition with the WPF InkCanvas control on a Windows 8.1 computer with .Net 4.5.

Note: **WPF InkCanvas control Windows 8.1 **, not Windows Forms, nor Windows Apps!

According to the help it should be quite easy:

MSDN: Handwriting Recognition

However when I get to this paragraph I get stuck.

Add a reference to the WPF Ink Analysis assemblies, IAWinFX.dll, IACore.dll, and IALoader.dll, which can be found in \Program Files\Reference Assemblies\Microsoft\Tablet PC\v1.7. Replace the contents of the code behind file with the following code.

I do not have these files on my computer. I tried on my Windows 7 Pro PC and can still not find them.

From searching stackoverflow and elsewhere it seems that other people have had similar issues, and there also seem to be several different versions of inking/handwriting recognition available. For instance it appears that putting it in a Windows 8 Store App should be quite easy. But my question is specifically about a WPF program with .NET 4.5 as per the MSDN documentation!


回答1:


I just went down the exact same path as you, and I have a solution. The MSDN Handwriting Recognition link that you stated simply doesn't work, and it is because it relies on the InkAnalyzer class which is only available if you install the Tablet PC v1.7 SDK on an XP machine (it won't install on Windows 8).

Having said that, installing the Tablet PC v1.7 SDK does install the Microsoft.Ink.dll, which you can use to perform handwriting recognition. The only downside is that you will have to take your WPF InkCanvas strokes and save them into the Microsoft.Ink.InkCollector strokes.

The solution is as follows:

1) Install the Windows XP Tablet PC SDK v1.7

2) Follow all of the same source code as outlined by the MSDN Handwriting Recognition guidance, except for the buttonClick implementation.

3) Add a reference to your WPF Application by browsing and selecting this dll: C:\Program Files (x86)\Microsoft Tablet PC Platform SDK\Include\Microsoft.Ink.dll

4) Add a 'using Microsoft.Ink' statement to the top of your MainWindow.xaml.cs file, and then add the following code to your buttonClick method:

    private void buttonClick(object sender, RoutedEventArgs e)
    {
        using (MemoryStream ms = new MemoryStream())
        {
            theInkCanvas.Strokes.Save(ms);
            var myInkCollector = new InkCollector();
            var ink = new Ink();
            ink.Load(ms.ToArray());

            using (RecognizerContext myRecoContext = new RecognizerContext())
            {
                RecognitionStatus status;
                myRecoContext.Strokes = ink.Strokes;
                var recoResult = myRecoContext.Recognize(out status);

                if (status == RecognitionStatus.NoError)
                {
                    textBox1.Text = recoResult.TopString;
                    theInkCanvas.Strokes.Clear();
                }
                else
                {
                    MessageBox.Show("ERROR: " + status.ToString());
                }
            }
        }
    }

That's it!!! One important note that I'd like to add. If you are trying to do handwriting recognition on Windows 10 or later, and you're not hindered by having to write a desktop WPF app, I highly recommend the usage of their DirectInk technology. I've tested it on a Windows 10 RC and it is much much easier to use. Unfortunately, it only works with their Universal Apps (Metro) and not Desktop Apps (WPF).




回答2:


Please try the below sample for windows 8. https://code.msdn.microsoft.com/windowsapps/InkPen-sample-in-CSharp-189ce853/sourcecode?fileId=60841&pathId=233613099



来源:https://stackoverflow.com/questions/27502373/wpf-handwriting-net-4-5-windows-8-missing-iawinfx-dll-and-others

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!