MedicalViewerSynchronizationType Enumeration

Summary
Represents the enumeration that is used to set the synchronization type for the cells in the viewer.
Syntax
C#
VB
C++
public enum MedicalViewerSynchronizationType 
  
Public Enum MedicalViewerSynchronizationType  
   Inherits System.Enum 
   Implements System.IComparable, System.IConvertible, System.IFormattable  
            public enum class MedicalViewerSynchronizationType : public System.Enum, System.IComparable, System.IConvertible, System.IFormattable   
Members
ValueMemberDescription
0None No synchronization.
1Automatic The cells will be synchronized if the they have the same MedicalViewerCell.SynchronizationID value.
Remarks

Currently, only the automatic synchronization is available. The cells must be added to the same MedicalViewer if the user want to synchronize them together. To add the cells to the Medical Viewer, use the collection MedicalViewer.Cells.

To enable this feature, please do the following:

  1. Set the MedicalViewer.SynchronizationType to MedicalViewerSynchronizationType.Automatic.
  2. Each cell has a MedicalViewerCell.SynchronizationID property that receives a string which is used to help the toolkit identify which cells to synchronize. To synchronize two cells, pass the same value to SynchronizationID in both cells. You can pass the StudyUID to synchronize the cells from the same study.
  3. Set the image position for each frame using MedicalViewerCell.SetImagePosition method. This is required in order the Medical Viewer be able to match the series with the same image position together.
  4. Set the image orientation using MedicalViewerCell.ImageOrientation for each cell to synchronize.
Example
C#
VB
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 MedicalViewerSyncrhonizationForm : Form 
{ 
   private MedicalViewer _medicalViewer; 
   private MedicalViewerSeriesManager _seriesManager; 
   private MedicalViewerSeriesManager _seriesManager512; 
          
 
   void MedicalViewerLocalizer_SizeChanged(object sender, EventArgs e) 
   { 
      _medicalViewer.Size = new Size(this.ClientRectangle.Right, this.ClientRectangle.Bottom); 
   } 
 
   public MedicalViewerSyncrhonizationForm(MedicalViewerSeriesManager output, MedicalViewerSeriesManager output512) 
   { 
      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; 
      _seriesManager512 = output512; 
 
 
      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.Tag = 0; 
      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); 
 
      // 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.WindowLevel, 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; 
      cell.SynchronizationID = "Test"; 
 
      // this tag to identify the cell. 
 
 
 
 
 
      // Load the second cell with 512 frame 
 
      cell = new MedicalViewerMultiCell(null, true, 1, 1); 
      count = output512.Stacks[0].Items.Count; 
      imageInformation = new MedicalViewerImageInformation[count]; 
 
      for (index = 0; index < count; index++) 
      { 
         codecsInformation = _codecs.GetInformation((string)(output512.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.Tag = 1; 
      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); 
 
      // 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.WindowLevel, 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[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); 
 
      cell.PixelSpacing = output512.Stacks[0].PixelSpacing; 
 
      for (index = 0; index < count; index++) 
      { 
         cell.SetImagePosition(index, output512.Stacks[0].Items[index].ImagePosition, (index == count - 1)); 
      } 
      cell.ImageOrientation = output512.Stacks[0].Items[0].ImageOrientationArray; 
      cell.FrameOfReferenceUID = output512.Stacks[0].Items[0].FrameOfReferenceUID; 
      cell.SynchronizationID = "Test"; 
 
 
 
      Controls.Add(_medicalViewer); 
      _medicalViewer.Dock = DockStyle.Fill; 
      _medicalViewer.SynchronizationType = MedicalViewerSynchronizationType.Automatic; 
      DicomEngine.Shutdown(); 
 
 
 
   } 
 
   void MedicalViewerLocalizer_FormClosing(object sender, FormClosingEventArgs e) 
   { 
   } 
 
   void cell_FramesRequested(object sender, MedicalViewerRequestedFramesInformationEventArgs e) 
   { 
      MedicalViewerMultiCell cell = (MedicalViewerMultiCell)(sender); 
 
      MedicalViewerSeriesManager output = (int)cell.Tag == 0 ? _seriesManager : _seriesManager512; 
 
      RasterCodecs _codecs = new RasterCodecs(); 
      int i; 
      RasterImage image; 
      string fileName; 
 
      if (e.RequestedFramesIndexes.Length > 0) 
      { 
         fileName = (string)(output.Stacks[0].Items[e.RequestedFramesIndexes[0]].Data); 
         image = _codecs.Load(fileName); 
      } 
      else 
         return; 
 
      for (i = 1; i < e.RequestedFramesIndexes.Length; i++) 
      { 
         fileName = (string)(output.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; } 
   } 
} 
 
MedicalViewerSyncrhonizationForm GetMedicalViewerSyncrhonizationForm() 
{ 
   MedicalViewerSeriesManagerFrom form = new MedicalViewerSeriesManagerFrom(); 
   MedicalViewerSeriesManager output = form.LoadJamesHead(); 
   MedicalViewerSeriesManager output512 = form.LoadJamesHead512(); 
 
   return new MedicalViewerSyncrhonizationForm(output, output512); 
} 
 
// 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 MedicalViewerSynchronizationExample() 
{ 
   MedicalViewerSyncrhonizationForm myForm = GetMedicalViewerSyncrhonizationForm(); 
   MedicalViewer medicalViewer = myForm.Viewer; 
 
   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 MedicalViewerSyncrhonizationForm : Inherits Form 
   Private _medicalViewer As MedicalViewer 
   Private _seriesManager As MedicalViewerSeriesManager 
   Private _seriesManager512 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, ByVal output512 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 
      _seriesManager512 = output512 
 
 
      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 
 
      cell.Tag = 0 
      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) 
 
      ' 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.WindowLevel, 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 
      cell.SynchronizationID = "Test" 
 
      ' this tag to identify the cell. 
 
 
 
 
 
      ' Load the second cell with 512 frame 
 
      cell = New MedicalViewerMultiCell(Nothing, True, 1, 1) 
      count = output512.Stacks(0).Items.Count 
      imageInformation = New MedicalViewerImageInformation(count - 1) {} 
 
      index = 0 
      Do While index < count 
         codecsInformation = _codecs.GetInformation(CStr(output512.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 
 
      cell.Tag = 1 
      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) 
 
      ' 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.WindowLevel, 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(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) 
 
      cell.PixelSpacing = output512.Stacks(0).PixelSpacing 
 
      index = 0 
      Do While index < count 
         cell.SetImagePosition(index, output512.Stacks(0).Items(index).ImagePosition, (index = count - 1)) 
         index += 1 
      Loop 
      cell.ImageOrientation = output512.Stacks(0).Items(0).ImageOrientationArray 
      cell.FrameOfReferenceUID = output512.Stacks(0).Items(0).FrameOfReferenceUID 
      cell.SynchronizationID = "Test" 
 
 
 
      Controls.Add(_medicalViewer) 
      _medicalViewer.Dock = DockStyle.Fill 
      _medicalViewer.SynchronizationType = MedicalViewerSynchronizationType.Automatic 
      DicomEngine.Shutdown() 
 
 
 
   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 output As MedicalViewerSeriesManager 
      If CInt(cell.Tag) = 0 Then 
         output = _seriesManager 
      Else 
         output = _seriesManager512 
      End If 
 
      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(output.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(output.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 GetMedicalViewerSyncrhonizationForm() As MedicalViewerSyncrhonizationForm 
   Dim form As MedicalViewerSeriesManagerFrom = New MedicalViewerSeriesManagerFrom() 
   Dim output As MedicalViewerSeriesManager = form.LoadJamesHead() 
   Dim output512 As MedicalViewerSeriesManager = form.LoadJamesHead512() 
 
   Return New MedicalViewerSyncrhonizationForm(output, output512) 
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 MedicalViewerSynchronizationExample() 
   Dim myForm As MedicalViewerSyncrhonizationForm = GetMedicalViewerSyncrhonizationForm() 
   Dim medicalViewer As MedicalViewer = myForm.Viewer 
 
   myForm.ShowDialog() 
End Sub 
Requirements

Target Platforms

Help Version 21.0.2021.6.30
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.MedicalViewer Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.