![]() |
Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction | Help Version 19.0.7.12
|
[Visual Basic]
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Controls.WinForms
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Core
[C#]
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Controls.WinForms;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
[Visual Basic]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' load an image into our viewer
Dim codecs As New RasterCodecs()
rasterImageViewer1.Image = codecs.Load("C:\Users\Public\Documents\LEADTOOLS Images\Image3.cmp")
' disable the cancel button for now
Button2.Enabled = False
End Sub
[C#]
private void Form1_Load(object sender, System.EventArgs e)
{
// load an image into our viewer
RasterCodecs codecs = new RasterCodecs();
rasterImageViewer1.Image = codecs.Load(@"C:\Users\Public\Documents\LEADTOOLS Images\Image3.cmp");
// disable the cancel button for now
button2.Enabled = false;
}
[Visual Basic]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
canceled = False
ProgressBar1.Value = 0
' disable the median button and enable the cancel button
Button1.Enabled = False
Button2.Enabled = True
Dim command As New MedianCommand(40)
' subscribe to the progress event
AddHandler command.Progress, AddressOf median_Progress
' run the median command
command.Run(RasterImageViewer1.Image)
' enable the median button and disable the cancel button
Button1.Enabled = True
Button2.Enabled = False
ProgressBar1.Value = 0
End Sub
[C#]
private void button1_Click(object sender, System.EventArgs e)
{
canceled = false;
progressBar1.Value = 0;
// disable the median button and enable the cancel button
button1.Enabled = false;
button2.Enabled = true;
MedianCommand command = new MedianCommand(40);
// subscribe to the progress event
command.Progress += new EventHandler<RasterCommandProgressEventArgs>(median_Progress);
// run the median command
command.Run(rasterImageViewer1.Image);
// enable the median button and disable the cancel button
button1.Enabled = true;
button2.Enabled = false;
progressBar1.Value = 0;
}
[Visual Basic]
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
' Cancel the median command
canceled = True
End Sub
[C#]
private void button2_Click(object sender, System.EventArgs e)
{
// Cancel the median command
canceled = true;
}
[Visual Basic]
Private canceled As Boolean
Private Sub median_Progress(ByVal sender As System.Object, ByVal e As RasterCommandProgressEventArgs)
' update the value of the progress bar
ProgressBar1.Value = e.Percent
' determine whether the cancel button has been pressed
If (canceled) Then
e.Cancel = True
End If
Application.DoEvents()
End Sub
[C#]
private bool canceled;
private void median_Progress(object sender, RasterCommandProgressEventArgs e)
{
// update the value of the progress bar
progressBar1.Value = e.Percent;
// determine whether the cancel button has been pressed
if(canceled)
e.Cancel = true;
Application.DoEvents();
}