本教程展示了如何使用自动注释的特点LEADTOOLS SDK在WinForms c#应用程序。
概述 | |
---|---|
总结 | 本教程涵盖了在c# WinForms应用程序自动注释功能。 |
完成时间 | 30分钟 |
Visual Studio项目 | 下载教程项目(9 KB) |
平台 | WinForms c#应用程序 |
IDE | Visual Studio 2017中,2019年 |
开发许可 | 下载LEADTOOLS |
试试用另一种语言 |
|
在工作之前绘制和编辑注释图像——WinForms c#教程中,熟悉的基本步骤,创建一个项目通过审查添加引用和设置一个许可证教程。
从项目中创建的副本添加引用和设置一个许可证教程。如果你没有这个项目,按照这个教程中的步骤创建它。
的引用需要取决于项目的目的。引用可以通过添加一个或另一个下面的两种方法(但不是全部)。对于这个项目,还需要以下引用:
如果使用NuGet引用,本教程需要以下NuGet包:
Leadtools.Annotations.WinForms
Leadtools.Viewer.Controls.WinForms
如果使用本地DLL的引用,下面的DLL是必要的。
dll位于< INSTALL_DIR > \ LEADTOOLS22 \ Bin \ Dotnet4 \ x64
:
Leadtools.Annotations.Automation.dll
Leadtools.Annotations.Designers.dll
Leadtools.Annotations.Engine.dll
Leadtools.Annotations.Rendering.WinForms.dll
Leadtools.Annotations.WinForms.dll
Leadtools.Codecs.Bmp.dll
Leadtools.Codecs.dll
Leadtools.Codecs.Fax.dll
Leadtools.Codecs.Png.dll
Leadtools.Codecs.Tif.dll
Leadtools.Controls.WinForms.dll
Leadtools.dll
Leadtools.Drawing.dll
对于一个完整的列表的应用程序所需的DLL文件,请参考文件包含在您的应用程序。
许可解锁项目需要的特性。它必须设置工具箱函数被调用之前。详情,包括教程为不同的平台,请参考设置一个运行时许可。
有两种类型的运行时许可证:
请注意
添加LEADTOOLS nuget和本地引用,设置一个许可证中会详细介绍添加引用和设置一个许可证教程。
与项目创建、添加引用,许可,可以开始编码。
去Form1.cs
在解决方案资源管理器。单击事件图标属性窗口。然后,双击负载创建一个事件处理程序。
将下面的代码添加到使用
块和全局变量。
/ /使用块
使用系统;
使用System.Windows.Forms;
使用Leadtools;
使用Leadtools.Controls;
使用Leadtools.Codecs;
使用Leadtools.Annotations.Automation;
使用Leadtools.Annotations.WinForms;
/ /添加全局变量
私人imageview观众;
私人ImageViewerAutomationControl automationControl;
私人AnnAutomationManager AnnAutomationManager;
私人AnnAutomation自动化;
添加以下代码内部Form1_Load
事件处理程序。
私人无效Form1_Load (对象发送方的EventArgs e)
{
/ /初始化图像查看器对象
观众=新imageview ();
查看器。码头= DockStyle.Fill;
/ /初始化图像查看器的自动化控制
automationControl =新ImageViewerAutomationControl ();
automationControl。imageview =观众;
/ /初始化一个新的RasterCodecs对象
RasterCodecs编解码器=新RasterCodecs ();
/ /主图像加载到观众
查看器。形象= codecs.Load (@“C: \ LEADTOOLS22 \资源\ \ ocr1.tif图像”);
/ /初始化图像浏览器的交互模式
AutomationInteractiveMode AutomationInteractiveMode =新AutomationInteractiveMode ();
automationInteractiveMode。AutomationControl = AutomationControl;
/ /添加图像浏览器的交互模式
viewer.InteractiveModes.BeginUpdate ();
viewer.InteractiveModes.Add (automationInteractiveMode);
viewer.InteractiveModes.EndUpdate ();
如果(查看器。形象! =零)
{
/ /创建并设置自动化管理器
annAutomationManager =新AnnAutomationManager ();
annAutomationManager。RestrictDesigners =真正的;
/ /指导经理创建所有默认自动化对象。
annAutomationManager.CreateDefaultObjects ();
/ /初始化经理助手并创建工具栏
/ /工具栏和图片查看器添加到控件
AutomationManagerHelper managerHelper =新AutomationManagerHelper (annAutomationManager);
managerHelper.CreateToolBar ();
Controls.Add (managerHelper.ToolBar);
Controls.Add(观众);
/ /设置自动化(它将创建容器)
自动化=新AnnAutomation (annAutomationManager automationControl);
/ /设置这个自动化的活跃
自动化。活跃的=真正的;
/ /容器的大小设置为图像查看器的大小
automation.Container。大小= automation.Container.Mapper.SizeToContainerCoordinates (LeadSizeD.Create (viewer.Image。ImageWidth viewer.Image.ImageHeight));
}
}
本教程使用这样本图像从LEADTOOLS图片
文件夹:< INSTALL_DIR > \ LEADTOOLS22 \ \图片资源
。
按运行项目F5,或通过选择调试- >开始调试。
如果步骤正确之后,应用程序运行和示例图像加载到查看器。可以选择工具栏上的任何注释,用来画的形象。下图显示了一个示例的一部分图像查看器,与注释工具栏顶部的查看器。
本教程演示了如何使用ImageViewerAutomationControl
,AnnAutomationManager
,AnnAutomation
,AutomationInteractiveMode
类。