iink SDK on Device

Answered

在winform中如何使用

我需要在winform中实现识别功能,但是我根据wpf的demo进行配置,始终无法正确运行

每次运行到这里就报错

image

以下是我的测试代码

            engine = Engine.Create(MyScript.Certificate.MyCertificate.Bytes);

            string[] confDirs = new string[1];

            confDirs[0] = "conf";

            engine.Configuration.SetStringArray("configuration-manager.search-path", confDirs);

 

            var localFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

            var tempFolder = Path.Combine(localFolder, "MyScript", "tmp");

            engine.Configuration.SetString("content-package.temp-folder", tempFolder);

            engine.Configuration.SetString("text.configuration.name", "text");

            engine.Configuration.SetString("lang", "en_US");

 

            renderer = engine.CreateRenderer(150, 150, new RenderTargets());

            renderer.AddListener(new RendererListener());

 

            var toolController = engine.CreateToolController();

            toolController.SetToolForType(PointerType.PEN, PointerTool.PEN);

 

            // Create an editor

            var editor = engine.CreateEditor(renderer, toolController);

 

            editor.SetViewSize(615, 1412);

            editor.SetFontMetricsProvider(new FontMetricsProvider(150, 150, 1));

 

            // Create a new package

            string pk = MakeUntitledFilename();

            ContentPackage package;

            try

            {

                package = engine.CreatePackage(pk);

            }

            catch (Exception)

            {

 

                package = engine.OpenPackage(pk);

            }

 

 

            // Create a new part

            var part = package.CreatePart("Text");

 

            // Associate editor with the new part

            editor.Part = part;




Best Answer

Dear User,

thank you for contacting us.

On our side, we do not have any experience with Winforms. Based on a quick internet search, it seems Winforms can only work with 32 bit libraries, while our Windows iink is 64 bit only. This may be the reason you are facing this behavior.

Nevertheless, based on what can be found on Microsoft website, it is likely that Winforms can be integrated in WPF. You may give a try: https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/walkthrough-hosting-a-windows-forms-control-in-wpf-by-using-xaml

Let us know if this works.

Best regards,

Olivier

1 Comment

Answer

Dear User,

thank you for contacting us.

On our side, we do not have any experience with Winforms. Based on a quick internet search, it seems Winforms can only work with 32 bit libraries, while our Windows iink is 64 bit only. This may be the reason you are facing this behavior.

Nevertheless, based on what can be found on Microsoft website, it is likely that Winforms can be integrated in WPF. You may give a try: https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/walkthrough-hosting-a-windows-forms-control-in-wpf-by-using-xaml

Let us know if this works.

Best regards,

Olivier