本文介绍了WPF手写.NET 4.5 Windows 8:缺少IAWinFX.dll等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在具有.Net 4.5的Windows 8.1计算机上将文本识别与WPF InkCanvas控件一起使用。

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

注意:** WPF InkCanvas控件Windows 8.1 * *,不是Windows窗体,也不是Windows Apps!

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

根据帮助,它应该很容易:

According to the help it should be quite easy:

但是,当我进入本段时,我会陷入困境。

However when I get to this paragraph I get stuck.

我的计算机上没有这些文件。我在Windows 7 Pro PC上尝试过,但仍然找不到。

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

从搜索stackoverflow和其他地方来看,其他人似乎也遇到了类似的问题,并且似乎还提供了几种不同版本的上墨/手写识别。例如,将其放在Windows 8 Store App中似乎应该很容易。但是我的问题特别是关于根据MSDN文档使用.NET 4.5的WPF程序!

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!

推荐答案

和你一样,我有一个解决方案。您声明的MSDN手写识别链接根本不起作用,这是因为它依赖于InkAnalyzer类,该类仅在XP计算机上安装Tablet PC v1.7 SDK时才可用(不会在Windows上安装) 8)。

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

已经说过,安装Tablet PC v1.7 SDK 确实会安装Microsoft.Ink.dll,您可以使用执行手写识别。唯一的缺点是,您必须将WPF InkCanvas笔划保存到Microsoft.Ink.InkCollector笔划中。

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.

解决方案如下:

1)安装

2)遵循指南,除了 buttonClick实现

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

3)通过浏览并选择以下dll,添加对WPF应用程序的引用:C:\Program Files(x86)\Microsoft Tablet PC Platform SDK\ Include\Microsoft.Ink.dll

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)在MainWindow.xaml.cs文件的顶部添加 using Microsoft.Ink语句,然后添加将以下代码添加到您的buttonClick方法:

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());
                }
            }
        }
    }

它!!!我想补充一个重要说明。如果您尝试在Windows 10或更高版本上进行手写识别,而又不必编写台式WPF应用程序,那么我强烈建议您使用DirectInk技术。我已经在Windows 10 RC上对其进行了测试,并且使用起来更加简单。不幸的是,它只能与他们的通用应用程序(地铁)一起使用,而不能与桌面应用程序(WPF)一起使用。

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

这篇关于WPF手写.NET 4.5 Windows 8:缺少IAWinFX.dll等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 11:46