public event EventHandler<MedicalViewerMPRPolygonEventsArgs> MPRPolygonCreated
Public Event MPRPolygonCreated As EventHandler(Of MedicalViewerMPRPolygonEventsArgs)
public:
event EventHandler<MedicalViewerMPRPolygonEventsArgs^>^ MPRPolygonCreated
The event handler receives an argument of type MedicalViewerMPRPolygonEventsArgs containing data related to this event. The following MedicalViewerMPRPolygonEventsArgs properties provide information specific to this event.
Property | Description |
---|---|
Polygon | Gets the MPR polygon that the user just created. |
using Leadtools;
using Leadtools.Dicom;
using Leadtools.Medical3D;
using Leadtools.Codecs;
using Leadtools.MedicalViewer;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.Annotations.Engine;
using Leadtools.Annotations.Designers;
class MedicalViewerPolygonCreatedForm : Form
{
private MedicalViewer _medicalViewer;
private MedicalViewerSeriesManager _seriesManager;
void MedicalViewerLocalizer_SizeChanged(object sender, EventArgs e)
{
_medicalViewer.Size = new Size(this.ClientRectangle.Right, this.ClientRectangle.Bottom);
}
public MedicalViewerPolygonCreatedForm(MedicalViewerSeriesManager output)
{
DicomEngine.Startup();
RasterCodecs _codecs = new RasterCodecs();
this.SizeChanged += new EventHandler(MedicalViewerLocalizer_SizeChanged);
// Create the medical viewer and adjust the size and the location.
_medicalViewer = new MedicalViewer(1, 2);
_medicalViewer.Location = new Point(0, 0);
_medicalViewer.Size = new Size(this.ClientRectangle.Right, this.ClientRectangle.Bottom);
_seriesManager = output;
MedicalViewerMultiCell cell = new MedicalViewerMultiCell(null, true, 1, 1);
int index;
int count = output.Stacks[0].Items.Count;
CodecsImageInfo codecsInformation;
MedicalViewerImageInformation[] imageInformation = new MedicalViewerImageInformation[count];
for (index = 0; index < count; index++)
{
codecsInformation = _codecs.GetInformation((string)(output.Stacks[0].Items[index].Data), true);
imageInformation[index] = new MedicalViewerImageInformation();
imageInformation[index].ImageHeight = codecsInformation.Width;
imageInformation[index].ImageWidth = codecsInformation.Width;
imageInformation[index].XResolution = codecsInformation.XResolution;
imageInformation[index].YResolution = codecsInformation.YResolution;
}
cell.FramesRequested += new EventHandler<MedicalViewerRequestedFramesInformationEventArgs>(cell_FramesRequested);
FormClosing += new FormClosingEventHandler(MedicalViewerLocalizer_FormClosing);
cell.EnableLowMemoryUsage(2, count, imageInformation);
_medicalViewer.Cells.Add(cell);
// add some actions that will be used to change the properties of the images inside the control.
cell.AddAction(MedicalViewerActionType.WindowLevel);
cell.AddAction(MedicalViewerActionType.Alpha);
cell.AddAction(MedicalViewerActionType.Offset);
cell.AddAction(MedicalViewerActionType.PanoramicPolygon);
// assign the added actions to a mouse button, meaning that when the user clicks and drags the mouse button, the associated action will be activated.
cell.SetAction(MedicalViewerActionType.PanoramicPolygon, MedicalViewerMouseButtons.Left, MedicalViewerActionFlags.Active);
cell.SetAction(MedicalViewerActionType.Alpha, MedicalViewerMouseButtons.Middle, MedicalViewerActionFlags.Active);
cell.SetAction(MedicalViewerActionType.Offset, MedicalViewerMouseButtons.Right, MedicalViewerActionFlags.Active);
cell.ReferenceLine.Enabled = true;
cell.ReferenceLine.Color = Color.Yellow;
cell.ShowCellBoundaries = true;
// adjust some properties of the cell and add some tags.
_medicalViewer.Cells[0].SetTag(2, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.UserData, "EX. ID 230-36-5448");
_medicalViewer.Cells[0].SetTag(4, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame);
_medicalViewer.Cells[0].SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Scale);
_medicalViewer.Cells[0].SetTag(2, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.WindowLevelData);
_medicalViewer.Cells[0].SetTag(1, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.FieldOfView);
cell.PixelSpacing = output.Stacks[0].PixelSpacing;
for (index = 0; index < count; index++)
{
cell.SetImagePosition(index, output.Stacks[0].Items[index].ImagePosition, (index == count - 1));
}
cell.ImageOrientation = output.Stacks[0].Items[0].ImageOrientationArray;
cell.FrameOfReferenceUID = output.Stacks[0].Items[0].FrameOfReferenceUID;
int width = cell.VirtualImage[cell.ActiveSubCell].Image.Width;
int height = cell.VirtualImage[cell.ActiveSubCell].Image.Height;
Controls.Add(_medicalViewer);
_medicalViewer.Dock = DockStyle.Fill;
DicomEngine.Shutdown();
cell.MPRPolygonCreated += new EventHandler<MedicalViewerMPRPolygonEventsArgs>(cell_MPRPolygonCreated);
cell.PanoramicDataRequested += new EventHandler<MedicalViewerPanoramicDataRequestedEventArgs>(cell_PanoramicDataRequested);
cell.MPRPolygonClicked += new EventHandler<MedicalViewerMPRPolygonClickedEventsArgs>(cell_MPRPolygonClicked);
cell.Data3DRequested += new EventHandler<MedicalViewerData3DRequestedEventArgs>(cell_Data3DRequested);
cell.AutoDisposeInternalData = true;
}
void cell_Data3DRequested(object sender, MedicalViewerData3DRequestedEventArgs e)
{
e.Succeed = Medical3DEngine.Provide3DInformation(e);
}
void cell_MPRPolygonCreated(object sender, MedicalViewerMPRPolygonEventsArgs e)
{
MedicalViewerMultiCell cellSource = (MedicalViewerMultiCell)sender;
MedicalViewerPanoramicCell cell = new MedicalViewerPanoramicCell(e.Polygon);
cell.AddAction(MedicalViewerActionType.WindowLevel);
cell.AddAction(MedicalViewerActionType.Scale);
cell.AddAction(MedicalViewerActionType.Offset);
cell.AddAction(MedicalViewerActionType.Stack);
cell.SetAction(MedicalViewerActionType.Offset, MedicalViewerMouseButtons.Right, MedicalViewerActionFlags.AllCells | MedicalViewerActionFlags.RealTime);
cell.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active);
cell.SetAction(MedicalViewerActionType.Scale, MedicalViewerMouseButtons.Middle, MedicalViewerActionFlags.Active);
_medicalViewer.Cells.Add(cell);
MedicalViewerParaxialCutCell paraxialCell = new MedicalViewerParaxialCutCell(e.Polygon, 0);
paraxialCell.ParaxialDistance = 20;
paraxialCell.ParaxialLength = 200;
_medicalViewer.Cells.Add(paraxialCell);
cellSource.SetAction(MedicalViewerActionType.WindowLevel, MedicalViewerMouseButtons.Left, MedicalViewerActionFlags.Active);
}
void cell_MPRPolygonClicked(object sender, MedicalViewerMPRPolygonClickedEventsArgs e)
{
// get the cell that contaisn the polygon clicked by the user.
MedicalViewerMultiCell cell = (MedicalViewerMultiCell)sender;
// get paraxial cell.
MedicalViewerParaxialCutCell paraxialCell = (MedicalViewerParaxialCutCell)_medicalViewer.Cells[2];
// if the user clicks on other polygon lines, the paraxial cut will be assigned to that line
if ((e.Button == MouseButtons.Left) && e.Type == MedicalViewerMPRPolygonHitTest.Body)
{
paraxialCell.PolygonLineIndex = e.Index;
}
}
void cell_PanoramicDataRequested(object sender, MedicalViewerPanoramicDataRequestedEventArgs e)
{
MedicalViewerMultiCell cell = (MedicalViewerMultiCell)sender;
RasterCodecs _codecs = new RasterCodecs();
String fileName = (string)(_seriesManager.Stacks[0].Items[e.FrameIndex].Data);
e.Frame = _codecs.Load(fileName);
}
void MedicalViewerLocalizer_FormClosing(object sender, FormClosingEventArgs e)
{
}
void cell_FramesRequested(object sender, MedicalViewerRequestedFramesInformationEventArgs e)
{
MedicalViewerMultiCell cell = (MedicalViewerMultiCell)(sender);
RasterCodecs _codecs = new RasterCodecs();
int i;
RasterImage image;
string fileName;
if (e.RequestedFramesIndexes.Length > 0)
{
fileName = (string)(_seriesManager.Stacks[0].Items[e.RequestedFramesIndexes[0]].Data);
image = _codecs.Load(fileName);
}
else
return;
for (i = 1; i < e.RequestedFramesIndexes.Length; i++)
{
fileName = (string)(_seriesManager.Stacks[0].Items[e.RequestedFramesIndexes[i]].Data);
image.AddPage(_codecs.Load(fileName));
}
cell.SetRequestedImage(image, e.RequestedFramesIndexes, MedicalViewerSetImageOptions.Insert);
}
public MedicalViewer Viewer
{
get { return _medicalViewer; }
}
}
MedicalViewerPolygonCreatedForm GetMedicalViewerPolygonCreatedForm()
{
MedicalViewerSeriesManagerFrom form = new MedicalViewerSeriesManagerFrom();
MedicalViewerSeriesManager output = form.LoadJamesHead();
return new MedicalViewerPolygonCreatedForm(output);
}
// This example changes the default window level value by decrease the width by 100. Then resets the images based on the new value.
public void MedicalViewerPolygonCreatedExample()
{
MedicalViewerPolygonCreatedForm myForm = GetMedicalViewerPolygonCreatedForm();
MedicalViewer medicalViewer = myForm.Viewer;
MessageBox.Show("Click to draw a polygon using the left mouse click, each click will create a new point, when done double-click");
myForm.ShowDialog();
}
Imports Leadtools
Imports Leadtools.Dicom
Imports Leadtools.Medical3D
Imports Leadtools.Codecs
Imports Leadtools.MedicalViewer
Imports Leadtools.Annotations.Engine
Imports Leadtools.Annotations.Designers
Imports Leadtools.ImageProcessing.Core
Private Class MedicalViewerPolygonCreatedForm : Inherits Form
Private _medicalViewer As MedicalViewer
Private _seriesManager As MedicalViewerSeriesManager
Private Sub MedicalViewer_SizeChanged(ByVal sender As Object, ByVal e As EventArgs)
_medicalViewer.Size = New Size(Me.ClientRectangle.Right, Me.ClientRectangle.Bottom)
End Sub
Public Sub New(ByVal output As MedicalViewerSeriesManager)
DicomEngine.Startup()
Dim _codecs As RasterCodecs = New RasterCodecs()
AddHandler SizeChanged, AddressOf MedicalViewer_SizeChanged
' Create the medical viewer and adjust the size and the location.
_medicalViewer = New MedicalViewer(1, 2)
_medicalViewer.Location = New Point(0, 0)
_medicalViewer.Size = New Size(Me.ClientRectangle.Right, Me.ClientRectangle.Bottom)
_seriesManager = output
Dim cell As MedicalViewerMultiCell = New MedicalViewerMultiCell(Nothing, True, 1, 1)
Dim index As Integer
Dim count As Integer = output.Stacks(0).Items.Count
Dim codecsInformation As CodecsImageInfo
Dim imageInformation As MedicalViewerImageInformation() = New MedicalViewerImageInformation(count - 1) {}
index = 0
Do While index < count
codecsInformation = _codecs.GetInformation(CStr(output.Stacks(0).Items(index).Data), True)
imageInformation(index) = New MedicalViewerImageInformation()
imageInformation(index).ImageHeight = codecsInformation.Width
imageInformation(index).ImageWidth = codecsInformation.Width
imageInformation(index).XResolution = codecsInformation.XResolution
imageInformation(index).YResolution = codecsInformation.YResolution
index += 1
Loop
AddHandler cell.FramesRequested, AddressOf cell_FramesRequested
AddHandler FormClosing, AddressOf MedicalViewerLocalizer_FormClosing
cell.EnableLowMemoryUsage(2, count, imageInformation)
_medicalViewer.Cells.Add(cell)
' add some actions that will be used to change the properties of the images inside the control.
cell.AddAction(MedicalViewerActionType.WindowLevel)
cell.AddAction(MedicalViewerActionType.Alpha)
cell.AddAction(MedicalViewerActionType.Offset)
cell.AddAction(MedicalViewerActionType.PanoramicPolygon)
' assign the added actions to a mouse button, meaning that when the user clicks and drags the mouse button, the associated action will be activated.
cell.SetAction(MedicalViewerActionType.PanoramicPolygon, MedicalViewerMouseButtons.Left, MedicalViewerActionFlags.Active)
cell.SetAction(MedicalViewerActionType.Alpha, MedicalViewerMouseButtons.Middle, MedicalViewerActionFlags.Active)
cell.SetAction(MedicalViewerActionType.Offset, MedicalViewerMouseButtons.Right, MedicalViewerActionFlags.Active)
cell.ReferenceLine.Enabled = True
cell.ReferenceLine.Color = Color.Yellow
cell.ShowCellBoundaries = True
' adjust some properties of the cell and add some tags.
_medicalViewer.Cells(0).SetTag(2, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.UserData, "EX. ID 230-36-5448")
_medicalViewer.Cells(0).SetTag(4, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame)
_medicalViewer.Cells(0).SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Scale)
_medicalViewer.Cells(0).SetTag(2, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.WindowLevelData)
_medicalViewer.Cells(0).SetTag(1, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.FieldOfView)
cell.PixelSpacing = output.Stacks(0).PixelSpacing
index = 0
Do While index < count
cell.SetImagePosition(index, output.Stacks(0).Items(index).ImagePosition, (index = count - 1))
index += 1
Loop
cell.ImageOrientation = output.Stacks(0).Items(0).ImageOrientationArray
cell.FrameOfReferenceUID = output.Stacks(0).Items(0).FrameOfReferenceUID
Dim width As Integer = cell.VirtualImage(cell.ActiveSubCell).Image.Width
Dim height As Integer = cell.VirtualImage(cell.ActiveSubCell).Image.Height
Controls.Add(_medicalViewer)
_medicalViewer.Dock = DockStyle.Fill
DicomEngine.Shutdown()
AddHandler cell.MPRPolygonCreated, AddressOf cell_MPRPolygonCreated
AddHandler cell.PanoramicDataRequested, AddressOf cell_PanoramicDataRequested
AddHandler cell.MPRPolygonClicked, AddressOf cell_MPRPolygonClicked
AddHandler cell.Data3DRequested, AddressOf cell_Data3DRequested
cell.AutoDisposeInternalData = True
End Sub
Private Sub cell_Data3DRequested(ByVal sender As Object, ByVal e As MedicalViewerData3DRequestedEventArgs)
e.Succeed = Medical3DEngine.Provide3DInformation(e)
End Sub
Private Sub cell_MPRPolygonCreated(ByVal sender As Object, ByVal e As MedicalViewerMPRPolygonEventsArgs)
Dim cellSource As MedicalViewerMultiCell = CType(sender, MedicalViewerMultiCell)
Dim cell As MedicalViewerPanoramicCell = New MedicalViewerPanoramicCell(e.Polygon)
cell.AddAction(MedicalViewerActionType.WindowLevel)
cell.AddAction(MedicalViewerActionType.Scale)
cell.AddAction(MedicalViewerActionType.Offset)
cell.AddAction(MedicalViewerActionType.Stack)
cell.SetAction(MedicalViewerActionType.Offset, MedicalViewerMouseButtons.Right, MedicalViewerActionFlags.AllCells Or MedicalViewerActionFlags.RealTime)
cell.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active)
cell.SetAction(MedicalViewerActionType.Scale, MedicalViewerMouseButtons.Middle, MedicalViewerActionFlags.Active)
_medicalViewer.Cells.Add(cell)
Dim paraxialCell As MedicalViewerParaxialCutCell = New MedicalViewerParaxialCutCell(e.Polygon, 0)
paraxialCell.ParaxialDistance = 20
paraxialCell.ParaxialLength = 200
_medicalViewer.Cells.Add(paraxialCell)
cellSource.SetAction(MedicalViewerActionType.WindowLevel, MedicalViewerMouseButtons.Left, MedicalViewerActionFlags.Active)
End Sub
Private Sub cell_MPRPolygonClicked(ByVal sender As Object, ByVal e As MedicalViewerMPRPolygonClickedEventsArgs)
' get the cell that contains the polygon clicked by the user.
Dim cell As MedicalViewerMultiCell = CType(sender, MedicalViewerMultiCell)
' get paraxial cell.
Dim paraxialCell As MedicalViewerParaxialCutCell = CType(_medicalViewer.Cells(2), MedicalViewerParaxialCutCell)
' if the user clicks on other polygon lines, the paraxial cut will be assigned to that line
If (e.Button = MouseButtons.Left) AndAlso e.Type = MedicalViewerMPRPolygonHitTest.Body Then
paraxialCell.PolygonLineIndex = e.Index
End If
End Sub
Private Sub cell_PanoramicDataRequested(ByVal sender As Object, ByVal e As MedicalViewerPanoramicDataRequestedEventArgs)
Dim cell As MedicalViewerMultiCell = CType(sender, MedicalViewerMultiCell)
Dim _codecs As RasterCodecs = New RasterCodecs()
Dim fileName As String = CStr(_seriesManager.Stacks(0).Items(e.FrameIndex).Data)
e.Frame = _codecs.Load(fileName)
End Sub
Private Sub MedicalViewerLocalizer_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs)
End Sub
Private Sub cell_FramesRequested(ByVal sender As Object, ByVal e As MedicalViewerRequestedFramesInformationEventArgs)
Dim cell As MedicalViewerMultiCell = CType(sender, MedicalViewerMultiCell)
Dim _codecs As RasterCodecs = New RasterCodecs()
Dim i As Integer
Dim image As RasterImage
Dim fileName As String
If e.RequestedFramesIndexes.Length > 0 Then
fileName = CStr(_seriesManager.Stacks(0).Items(e.RequestedFramesIndexes(0)).Data)
image = _codecs.Load(fileName)
Else
Return
End If
i = 1
Do While i < e.RequestedFramesIndexes.Length
fileName = CStr(_seriesManager.Stacks(0).Items(e.RequestedFramesIndexes(i)).Data)
image.AddPage(_codecs.Load(fileName))
i += 1
Loop
cell.SetRequestedImage(image, e.RequestedFramesIndexes, MedicalViewerSetImageOptions.Insert)
End Sub
Public ReadOnly Property Viewer() As MedicalViewer
Get
Return _medicalViewer
End Get
End Property
End Class
Private Function GetMedicalViewerPolygonCreatedForm() As MedicalViewerPolygonCreatedForm
Dim form As MedicalViewerSeriesManagerFrom = New MedicalViewerSeriesManagerFrom()
Dim output As MedicalViewerSeriesManager = form.LoadJamesHead()
Return New MedicalViewerPolygonCreatedForm(output)
End Function
' This example changes the default window level value by decrease the width by 100. Then resets the images based on the new value.
<TestMethod()> _
Public Sub MedicalViewerPolygonCreatedExample()
Dim myForm As MedicalViewerPolygonCreatedForm = GetMedicalViewerPolygonCreatedForm()
Dim medicalViewer As MedicalViewer = myForm.Viewer
MessageBox.Show("Click to draw a polygon using the left mouse click, each click will create a new point, when done double-click")
myForm.ShowDialog()
End Sub
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.