Private Class MedicalViewerForm : Inherits Form
Private _medicalViewer As MedicalViewer
Private applyEffects As Button
Private Sub MedicalViewerForm_SizeChanged(ByVal sender As Object, ByVal e As EventArgs)
_medicalViewer.Size = New Size(Me.ClientRectangle.Right - 30, Me.ClientRectangle.Bottom)
End Sub
Public Sub New()
RasterCodecs.Startup()
Dim _codecs As RasterCodecs = New RasterCodecs()
Dim _image As RasterImage
AddHandler SizeChanged, AddressOf MedicalViewerForm_SizeChanged
_medicalViewer = New MedicalViewer(1, 2)
_medicalViewer.Location = New Point(30, 0)
_medicalViewer.Size = New Size(Me.ClientRectangle.Right - 30, Me.ClientRectangle.Bottom)
_medicalViewer.AddAction(MedicalViewerActionType.WindowLevel)
_medicalViewer.AddAction(MedicalViewerActionType.Alpha)
_medicalViewer.AddAction(MedicalViewerActionType.Offset)
_medicalViewer.SetAction(MedicalViewerActionType.WindowLevel, MedicalViewerMouseButtons.Left, MedicalViewerActionFlags.Active Or MedicalViewerActionFlags.RealTime)
_medicalViewer.SetAction(MedicalViewerActionType.Alpha, MedicalViewerMouseButtons.Middle, MedicalViewerActionFlags.Active Or MedicalViewerActionFlags.RealTime)
_medicalViewer.SetAction(MedicalViewerActionType.Offset, MedicalViewerMouseButtons.Right, MedicalViewerActionFlags.Active Or MedicalViewerActionFlags.RealTime)
_image = _codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "xa.dcm")
_medicalViewer.Cells.Add(New MedicalViewerCell(_image, True, 1, 1))
_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)
_image = _codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "mr.dcm")
_medicalViewer.Cells.Add(New MedicalViewerCell(_image, True, 2, 2))
_medicalViewer.Cells(1).SetTag(2, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.UserData, "EX. ID 230-36-5448")
_medicalViewer.Cells(1).SetTag(4, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame)
_medicalViewer.Cells(1).SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Scale)
_medicalViewer.Cells(1).SetTag(2, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.WindowLevelData)
_medicalViewer.Cells(1).SetTag(1, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.FieldOfView)
RasterCodecs.Shutdown()
applyEffects = New Button()
applyEffects.Location = New Point(0, 0)
applyEffects.Size = New Size(30, 15)
applyEffects.Text = "Apply Effects"
AddHandler applyEffects.Click, AddressOf applyEffects_Click
Controls.Add(_medicalViewer)
Controls.Add(applyEffects)
End Sub
Private Sub applyEffects_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim medicalViewer As MedicalViewer = CType(_medicalViewer, MedicalViewer)
Dim result As System.Windows.Forms.DialogResult = MessageBox.Show("This demo will do some effects on the Medical viewer, Do you want to use the begin and update update?", "Begin Update And End Update Demo", MessageBoxButtons.YesNo)
If result = System.Windows.Forms.DialogResult.Yes Then
medicalViewer.BeginUpdate()
End If
medicalViewer.Cells(0).SetTag(8, 0, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.UserData, "Sub Cell Tag 1")
medicalViewer.Cells(0).SetTag(0, 8, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.UserData, "Sub Cell Tag 2")
medicalViewer.Cells(1).SetTag(1, 9, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.UserData, "Sub Cell Tag 3")
medicalViewer.Cells(1).SetTag(2, 10, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.UserData, "Sub Cell Tag 4")
medicalViewer.Cells(1).SetTag(3, 11, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.UserData, "Sub Cell Tag 5")
medicalViewer.Cells(0).Rows = 3
medicalViewer.Cells(0).Columns = 3
medicalViewer.Cells(0).FitImageToCell = False
Dim tagInformation As MedicalViewerTagInformation = New MedicalViewerTagInformation()
tagInformation.Alignment = MedicalViewerTagAlignment.BottomLeft
tagInformation.Position = 3
tagInformation.Text = "Edit Text 1"
medicalViewer.Cells(0).EditTag(8, 0, MedicalViewerTagAlignment.TopLeft, tagInformation)
tagInformation = New MedicalViewerTagInformation()
tagInformation.Type = MedicalViewerTagType.Scale
medicalViewer.Cells(0).EditTag(8, 0, MedicalViewerTagAlignment.BottomLeft, tagInformation)
medicalViewer.Cells(0).DeleteTag(0, 8, MedicalViewerTagAlignment.TopLeft)
tagInformation = medicalViewer.Cells(0).GetTag(2, 10, MedicalViewerTagAlignment.TopLeft)
tagInformation.Position += 1
medicalViewer.Cells(0).EditTag(2, 10, MedicalViewerTagAlignment.TopLeft, tagInformation)
tagInformation = medicalViewer.Cells(0).GetTag(2, MedicalViewerTagAlignment.TopLeft)
tagInformation.Text = "Edited sub-cell Tag1"
medicalViewer.Cells(0).EditTag(2, MedicalViewerTagAlignment.TopLeft, tagInformation)
medicalViewer.Cells(0).DeleteTag(4, MedicalViewerTagAlignment.TopLeft)
Dim windowLevelProperties As MedicalViewerWindowLevel = CType(medicalViewer.GetActionProperties(MedicalViewerActionType.WindowLevel, 0, 0), MedicalViewerWindowLevel)
windowLevelProperties.Width = 20
windowLevelProperties.Center = 50
medicalViewer.SetActionProperties(MedicalViewerActionType.WindowLevel, windowLevelProperties)
Dim scale As Double = medicalViewer.Cells(0).GetScale(0)
scale *= 2
medicalViewer.Cells(0).SetScale(-1, scale)
medicalViewer.Cells(1).SetScale(0, scale)
Dim scaleMode As MedicalViewerScaleMode = medicalViewer.Cells(0).GetScaleMode(0)
If scaleMode = Leadtools.MedicalViewer.MedicalViewerScaleMode.Normal Then
scaleMode = MedicalViewerScaleMode.Fit
Else
scaleMode = MedicalViewerScaleMode.Normal
End If
medicalViewer.Cells(0).SetScaleMode(scaleMode)
If result = System.Windows.Forms.DialogResult.Yes Then
medicalViewer.EndUpdate()
End If
End Sub
Public ReadOnly Property Viewer() As MedicalViewer
Get
Return _medicalViewer
End Get
End Property
End Class
Private Function GetMedicalControl() As MedicalViewerForm
Return New MedicalViewerForm()
End Function
<Test> _
Public Sub MedicalViewerTagInformationExample()
Dim myForm As MedicalViewerForm = GetMedicalControl()
Dim medicalViewer As MedicalViewer = myForm.Viewer
myForm.ShowDialog()
End Sub |