WPF 手写 .NET 4.5 Windows 8:缺少 IAWinFX.dll 和其他 [英] WPF Handwriting .NET 4.5 Windows 8: Missing IAWinFX.dll and others

查看:14
本文介绍了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 应用程序!

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

根据帮助应该很容易:

MSDN:手写识别

然而,当我读到这一段时,我就卡住了.

However when I get to this paragraph I get stuck.

添加对 WPF Ink Analysis 程序集、IAWinFX.dll、IACore.dll 和 IALoader.dll 的引用,可在 Program FilesReference AssembliesMicrosoftTablet PCv1.7 中找到.将代码隐藏文件的内容替换为以下代码.

Add a reference to the WPF Ink Analysis assemblies, IAWinFX.dll, IACore.dll, and IALoader.dll, which can be found in Program FilesReference AssembliesMicrosoftTablet PCv1.7. Replace the contents of the code behind file with the following code.

我的电脑上没有这些文件.我在我的 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 应用程序应该很容易.但我的问题是根据 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) 安装 Windows XP Tablet PC SDK v1.7

2) 遵循 MSDN 手写识别指南,除了按钮点击实现.

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 SDKIncludeMicrosoft.Ink.dll

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

4) 在 MainWindow.xaml.cs 文件的顶部添加使用 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 上对其进行了测试,使用起来要容易得多.遗憾的是,它仅适用于他们的通用应用 (Metro),而不适用于桌面应用 (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 和其他的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆