forked from rtigithub/HalconExamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
95 lines (83 loc) · 3.57 KB
/
Form1.cs
File metadata and controls
95 lines (83 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// ***********************************************************************
// Assembly : HSmartWindowControlExample
// Author : Resolution Technology, Inc.
// Created : 05-24-2017
// Last Modified On : 05-24-2017
// ***********************************************************************
// <copyright file="Form1.cs" company="Resolution Technology, Inc.">
// Copyright © 2017
// </copyright>
// <summary></summary>
// ***********************************************************************
using System;
using System.Drawing;
using System.Windows.Forms;
using HalconDotNet;
using Rti.Halcon;
namespace HSmartWindowControlExample
{
/// <summary>
/// Class Form1.
/// </summary>
/// <seealso cref="System.Windows.Forms.Form" />
public partial class Form1 : Form
{
#region Public Constructors
/// <summary>
/// Initializes a new instance of the <see cref="Form1"/> class.
/// </summary>
public Form1()
{
InitializeComponent();
}
#endregion Public Constructors
#region Private Methods
/// <summary>
/// Handles the Click event of the ButtonLoadImageHWindow control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void ButtonLoadImageHWindow_Click(object sender, EventArgs e)
{
openFileDialog1.InitialDirectory = Environment.GetEnvironmentVariable(@"HALCONEXAMPLES") + @"\images";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
HImage halconImage = new HImage(openFileDialog1.FileName);
hSmartWindowControl1.HalconWindow.DispImage(halconImage);
}
}
/// <summary>
/// Handles the Click event of the ButtonLoadImagePictureBox control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void ButtonLoadImagePictureBox_Click(object sender, EventArgs e)
{
openFileDialog1.InitialDirectory = Environment.GetEnvironmentVariable(@"HALCONEXAMPLES") + @"\images";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
pictureBox1.LoadAsync(openFileDialog1.FileName);
}
}
/// <summary>
/// Handles the Load event of the HSmartWindowControl1 control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void HSmartWindowControl1_Load(object sender, EventArgs e)
{
this.MouseWheel += (sender as HSmartWindowControl).HSmartWindowControl_MouseWheel;
}
/// <summary>
/// Handles the LoadCompleted event of the PictureBox1 control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.ComponentModel.AsyncCompletedEventArgs"/> instance containing the event data.</param>
private void PictureBox1_LoadCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
HImage halconImage = (pictureBox1.Image as Bitmap).ToHimage();
hSmartWindowControl1.HalconWindow.DispImage(halconImage);
}
#endregion Private Methods
}
}