原創|使用教程|編輯:黃竹雯|2017-11-22 11:19:17.000|閱讀 616 次
概述:本教程將按照步驟分享如何使用LEADTOOLS圖像標注控件在界面上對圖像進行標注。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
using System.Windows.Forms;
using Leadtools;
using Leadtools.Codecs;
using Leadtools.WinForms;
using Leadtools.Annotations;
RasterImageViewer viewer = new RasterImageViewer();
RasterImage img;
AnnAutomationManager annger;
AnnAutomation automation;
private void initControl() { Support.SetLicense(); viewer.Dock = DockStyle.Fill; panel1.Controls.Add(viewer); viewer.HorizontalAlignMode = RasterPaintAlignMode.Center; viewer.VerticalAlignMode = RasterPaintAlignMode.Center; loadImage("qwe.jpg"); if (viewer.Image != null) { // create and setup the automation manager annger = new AnnAutomationManager(); // Instruct the manager to create the default (all) automation objects. annger.CreateDefaultObjects(); // create the toolbar and add it to the form annger.CreateToolBar(); Controls.Add(annger.ToolBar); // setup the automation (will create the container as well) automation = new AnnAutomation(annger, viewer); // add an event handler for changes to the current designer automation.CurrentDesignerChanged += new EventHandler(automation_CurrentDesignerChanged); // setup this automation as the active one automation.Active = true; } toolStripComboBox1.SelectedIndex = 0; }
private void loadImage(string filename)
{
img = new RasterCodecs().Load(filename);
viewer.Image = img;
}
private void automation_CurrentDesignerChanged(object sender, EventArgs e)
{
AnnAutomation automation = sender as AnnAutomation;
AnnButtonRunDesigner buttonRunDesigner = automation.CurrentDesigner as AnnButtonRunDesigner;
if (buttonRunDesigner != null)
buttonRunDesigner.Run += new EventHandler<AnnRunDesignerEventArgs>(buttonRunDesigner_Run);
}
private void buttonRunDesigner_Run(object sender, AnnRunDesignerEventArgs e)
{
if (e.OperationStatus == AnnDesignerOperationStatus.End)
{
AnnButtonObject btn = e.Object as AnnButtonObject;
MessageBox.Show(string.Format("Button with text = {0} was clicked!", btn.Text));
}
}
private void loadImage(string filename)
{
img = new RasterCodecs().Load(filename);
viewer.Image = img;
}
private void toolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
annger.UserMode = (toolStripComboBox1.SelectedIndex == 0) ? AnnUserMode.Design : AnnUserMode.Run;
}
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn