Leadtools.MedicalViewer Requires Medical product license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.10.31
MedicalViewer Constructor
See Also  Example
Leadtools.MedicalViewer Namespace > MedicalViewer Class : MedicalViewer Constructor




Initializes a new instance of the MedicalViewer class.

Overload List

OverloadDescription
MedicalViewer Constructor() Initializes a new instance of the MedicalViewer class.  
MedicalViewer Constructor(Int32,Int32) Initializes a new instance of the MedicalViewer class object with explicit parameters.  

Example

Create the control and add some image

Visual BasicCopy Code
<Test> _
Public Sub MedicalViewerPropertiesExample()
   Dim form As MainForm2 = New MainForm2()
   form.ShowDialog()
End Sub
' MainForm1 will be the owner of the medical viewer control.
Private Class MainForm2 : Inherits Form
   Public _medicalViewer As MedicalViewer

   Public Sub New()
      RasterCodecs.Startup()
      Dim _codecs As RasterCodecs = New RasterCodecs()
      Dim _image As RasterImage

      ' Create the medical viewer and adjust some properties.
      _medicalViewer = New MedicalViewer()
      _medicalViewer.Rows = 2
      _medicalViewer.Columns = 2
      _medicalViewer.Location = New Point(0, 0)
      _medicalViewer.Size = New Size(Me.ClientRectangle.Right, Me.ClientRectangle.Bottom)

      _medicalViewer.ActiveBorderColor = Color.FromArgb(0, 0, 255)
      _medicalViewer.ActiveSubCellBorderColor = Color.FromArgb(0, 255, 0)
      _medicalViewer.AnnotationDefaultCursor = System.Windows.Forms.Cursors.Cross
      _medicalViewer.AnnotationMoveCursor = System.Windows.Forms.Cursors.SizeNWSE
      _medicalViewer.AnnotationSelectCursor = System.Windows.Forms.Cursors.SizeAll
      _medicalViewer.AutoScroll = True
      _medicalViewer.CellBackColor = Color.FromArgb(100, 100, 255)
      _medicalViewer.BorderStyle = MedicalViewerBorderStyle.DashDotDot
      _medicalViewer.CellMaintenance = True
      _medicalViewer.CustomSplitterColor = True
      _medicalViewer.BackColor = Color.FromArgb(70, 70, 180)
      _medicalViewer.MeasurementUnit = MedicalViewerMeasurementUnit.Inches
      _medicalViewer.NonActiveBorderColor = Color.FromArgb(0, 0, 0)
      _medicalViewer.PaintingMethod = MedicalViewerPaintingMethod.Normal
      _medicalViewer.RegionDefaultCursor = System.Windows.Forms.Cursors.Cross
      _medicalViewer.ResizeBoth = System.Windows.Forms.Cursors.SizeAll
      _medicalViewer.ResizeHorizontalCursor = System.Windows.Forms.Cursors.SizeWE
      _medicalViewer.ResizeVerticalCursor = System.Windows.Forms.Cursors.SizeNS

      _medicalViewer.RulerInColor = Color.FromArgb(255, 255, 0)
      _medicalViewer.RulerOutColor = Color.FromArgb(255, 0, 0)
      _medicalViewer.RulerStyle = MedicalViewerRulerStyle.Bordered
      _medicalViewer.ShowCellScroll = False
      _medicalViewer.ShowFreezeText = True
      _medicalViewer.SplitterColor = Color.FromArgb(128, 128, 128)
      _medicalViewer.SplitterStyle = MedicalViewerSplitterStyle.Thick
      _medicalViewer.TextColor = Color.FromArgb(255, 255, 0)
      _medicalViewer.TextQuality = MedicalViewerTextQuality.Draft
      _medicalViewer.TextShadowColor = Color.FromArgb(0, 0, 0)
      _medicalViewer.UseExtraSplitters = False
      _medicalViewer.VisibleRow = 0


      ' add some action that will be used to change the properties of the images inside the control.
      _medicalViewer.AddAction(MedicalViewerActionType.WindowLevel)
      _medicalViewer.AddAction(MedicalViewerActionType.Alpha)
      _medicalViewer.AddAction(MedicalViewerActionType.Scale)
      _medicalViewer.AddAction(MedicalViewerActionType.Offset)
      _medicalViewer.AddAction(MedicalViewerActionType.Stack)

      ' assign the added actions to a mouse button, meaning that when the user click and drag the mouse button, the associted action will be activated.
      _medicalViewer.SetAction(MedicalViewerActionType.WindowLevel, MedicalViewerMouseButtons.Left, MedicalViewerActionFlags.Active Or MedicalViewerActionFlags.RealTime)
      _medicalViewer.SetAction(MedicalViewerActionType.Offset, MedicalViewerMouseButtons.Right, MedicalViewerActionFlags.Active Or MedicalViewerActionFlags.RealTime)
      _medicalViewer.SetAction(MedicalViewerActionType.Scale, MedicalViewerMouseButtons.Middle, MedicalViewerActionFlags.Active Or MedicalViewerActionFlags.RealTime)
      _medicalViewer.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active Or MedicalViewerActionFlags.RealTime)

      ' assign the added actions to a keyboard keys that will work like the mouse.
      Dim medicalKeys As MedicalViewerKeys = New MedicalViewerKeys()
      medicalKeys.MouseDown = Keys.Down
      medicalKeys.MouseUp = Keys.Up
      medicalKeys.MouseLeft = Keys.Left
      medicalKeys.MouseRight = Keys.Right
      _medicalViewer.SetActionKeys(MedicalViewerActionType.Offset, medicalKeys)
      medicalKeys.Modifiers = MedicalViewerModifiers.Ctrl
      _medicalViewer.SetActionKeys(MedicalViewerActionType.WindowLevel, medicalKeys)
      medicalKeys.MouseDown = Keys.PageDown
      medicalKeys.MouseUp = Keys.PageUp
      _medicalViewer.SetActionKeys(MedicalViewerActionType.Stack, medicalKeys)
      medicalKeys.MouseDown = Keys.Subtract
      medicalKeys.MouseUp = Keys.Add
      _medicalViewer.SetActionKeys(MedicalViewerActionType.Scale, medicalKeys)

      ' Go through all the built in actions and remove the actions that have not been assigned to a mouse button, or a key.
      Dim index As Integer = 1
      Do While index < 22
         Dim actionType As MedicalViewerActionType = CType(index, MedicalViewerActionType)
         If _medicalViewer.IsActionAdded(actionType) Then
            Dim mouseButton As MedicalViewerMouseButtons = _medicalViewer.GetActionButton(actionType)
            If mouseButton = MedicalViewerMouseButtons.None Then
               Dim keys As MedicalViewerKeys = _medicalViewer.GetActionKeys(actionType)
               If keys.MouseLeft = System.Windows.Forms.Keys.None AndAlso keys.MouseUp = System.Windows.Forms.Keys.None AndAlso keys.MouseDown = System.Windows.Forms.Keys.None AndAlso keys.MouseRight = System.Windows.Forms.Keys.None Then
                  _medicalViewer.RemoveAction(actionType)
               End If
            End If
         End If
         index += 1
      Loop

      ' Makes the window level applies the effect on all selected cells at the same time.
      Dim flags As MedicalViewerActionFlags = _medicalViewer.GetActionFlags(MedicalViewerActionType.WindowLevel)
      flags = flags Or MedicalViewerActionFlags.Selected
      _medicalViewer.SetAction(MedicalViewerActionType.WindowLevel, MedicalViewerMouseButtons.Left, flags)


      ' Load an image and then add it to the control.
      _image = _codecs.Load("E:\LEAD15\Dist\Images\image2.cmp")
      _medicalViewer.Cells.Add(New MedicalViewerCell(_image, True, 1, 1))

      ' adjust some properties to 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)
      _medicalViewer.Cells(0).SetTag(1, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "Good, Guy")
      _medicalViewer.Cells(0).SetTag(2, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "PID 125-98-445")
      _medicalViewer.Cells(0).SetTag(3, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "DOB 08/02/1929")
      _medicalViewer.Cells(0).SetTag(5, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "03/16/1999")
      _medicalViewer.Cells(0).SetTag(0, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.RulerUnit)
      _medicalViewer.Cells(0).Rows = 2
      _medicalViewer.Cells(0).Columns = 2
      _medicalViewer.Cells(0).Frozen = False
      _medicalViewer.Cells(0).DisplayRulers = MedicalViewerRulers.Both
      _medicalViewer.Cells(0).ApplyOnIndividualSubCell = False
      _medicalViewer.Cells(0).ApplyActionOnMove = True
      _medicalViewer.Cells(0).FitImageToCell = True
      _medicalViewer.Cells(0).Selected = True
      _medicalViewer.Cells(0).ShowTags = True

      ' Load an image and then add it to the control.
      _image = _codecs.Load("E:\LEAD15\Dist\Images\image2.cmp")
      Dim cell As MedicalViewerCell = New MedicalViewerCell()
      cell.Image = _image
      cell.Rows = 2
      cell.Columns = 2
      cell.Frozen = False
      cell.DisplayRulers = MedicalViewerRulers.Both
      cell.ApplyOnIndividualSubCell = False
      cell.ApplyActionOnMove = True
      cell.FitImageToCell = True
      cell.Selected = True
      cell.ShowTags = True
      _medicalViewer.Cells.Add(cell)

      ' adjust some properties to 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)
      _medicalViewer.Cells(1).SetTag(1, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "Good, Guy")
      _medicalViewer.Cells(1).SetTag(2, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "PID 125-98-445")
      _medicalViewer.Cells(1).SetTag(3, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "DOB 08/02/1929")
      _medicalViewer.Cells(1).SetTag(5, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "03/16/1999")
      _medicalViewer.Cells(1).SetTag(0, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.RulerUnit)

      RasterCodecs.Shutdown()
      Controls.Add(_medicalViewer)
   End Sub
End Class
C#Copy Code
public void MedicalViewerPropertiesExample() 

   MainForm2 form = new MainForm2(); 
   form.ShowDialog(); 

 
// MainForm1 will be the owner of the medical viewer control. 
class MainForm2 : Form 

   public MedicalViewer _medicalViewer; 
 
   public MainForm2() 
   { 
      RasterCodecs.Startup(); 
      RasterCodecs _codecs = new RasterCodecs(); 
      RasterImage _image; 
 
      // Create the medical viewer and adjust some properties. 
      _medicalViewer = new MedicalViewer(); 
      _medicalViewer.Rows = 2; 
      _medicalViewer.Columns = 2; 
      _medicalViewer.Location = new Point(0, 0); 
      _medicalViewer.Size = new Size(this.ClientRectangle.Right, this.ClientRectangle.Bottom); 
 
      _medicalViewer.ActiveBorderColor = Color.FromArgb(0, 0, 255); 
      _medicalViewer.ActiveSubCellBorderColor = Color.FromArgb(0, 255, 0); 
      _medicalViewer.AnnotationDefaultCursor = System.Windows.Forms.Cursors.Cross; 
      _medicalViewer.AnnotationMoveCursor = System.Windows.Forms.Cursors.SizeNWSE; 
      _medicalViewer.AnnotationSelectCursor = System.Windows.Forms.Cursors.SizeAll; 
      _medicalViewer.AutoScroll = true; 
      _medicalViewer.CellBackColor = Color.FromArgb(100, 100, 255); 
      _medicalViewer.BorderStyle = MedicalViewerBorderStyle.DashDotDot; 
      _medicalViewer.CellMaintenance = true; 
      _medicalViewer.CustomSplitterColor = true; 
      _medicalViewer.BackColor = Color.FromArgb(70, 70, 180); 
      _medicalViewer.MeasurementUnit = MedicalViewerMeasurementUnit.Inches; 
      _medicalViewer.NonActiveBorderColor = Color.FromArgb(0, 0, 0); 
      _medicalViewer.PaintingMethod = MedicalViewerPaintingMethod.Normal; 
      _medicalViewer.RegionDefaultCursor = System.Windows.Forms.Cursors.Cross; 
      _medicalViewer.ResizeBoth = System.Windows.Forms.Cursors.SizeAll; 
      _medicalViewer.ResizeHorizontalCursor = System.Windows.Forms.Cursors.SizeWE; 
      _medicalViewer.ResizeVerticalCursor = System.Windows.Forms.Cursors.SizeNS; 
 
      _medicalViewer.RulerInColor = Color.FromArgb(255, 255, 0); 
      _medicalViewer.RulerOutColor = Color.FromArgb(255, 0, 0); 
      _medicalViewer.RulerStyle = MedicalViewerRulerStyle.Bordered; 
      _medicalViewer.ShowCellScroll = false; 
      _medicalViewer.ShowFreezeText = true; 
      _medicalViewer.SplitterColor = Color.FromArgb(128, 128, 128); 
      _medicalViewer.SplitterStyle = MedicalViewerSplitterStyle.Thick; 
      _medicalViewer.TextColor = Color.FromArgb(255, 255, 0); 
      _medicalViewer.TextQuality = MedicalViewerTextQuality.Draft; 
      _medicalViewer.TextShadowColor = Color.FromArgb(0, 0, 0); 
      _medicalViewer.UseExtraSplitters = false; 
      _medicalViewer.VisibleRow = 0; 
 
 
      // add some action that will be used to change the properties of the images inside the control. 
      _medicalViewer.AddAction(MedicalViewerActionType.WindowLevel); 
      _medicalViewer.AddAction(MedicalViewerActionType.Alpha); 
      _medicalViewer.AddAction(MedicalViewerActionType.Scale); 
      _medicalViewer.AddAction(MedicalViewerActionType.Offset); 
      _medicalViewer.AddAction(MedicalViewerActionType.Stack); 
 
      // assign the added actions to a mouse button, meaning that when the user click and drag the mouse button, the associted action will be activated. 
      _medicalViewer.SetAction(MedicalViewerActionType.WindowLevel, MedicalViewerMouseButtons.Left, MedicalViewerActionFlags.Active | MedicalViewerActionFlags.RealTime); 
      _medicalViewer.SetAction(MedicalViewerActionType.Offset, MedicalViewerMouseButtons.Right, MedicalViewerActionFlags.Active | MedicalViewerActionFlags.RealTime); 
      _medicalViewer.SetAction(MedicalViewerActionType.Scale, MedicalViewerMouseButtons.Middle, MedicalViewerActionFlags.Active | MedicalViewerActionFlags.RealTime); 
      _medicalViewer.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active | MedicalViewerActionFlags.RealTime); 
 
      // assign the added actions to a keyboard keys that will work like the mouse. 
      MedicalViewerKeys medicalKeys = new MedicalViewerKeys(); 
      medicalKeys.MouseDown = Keys.Down; 
      medicalKeys.MouseUp = Keys.Up; 
      medicalKeys.MouseLeft = Keys.Left; 
      medicalKeys.MouseRight = Keys.Right; 
      _medicalViewer.SetActionKeys(MedicalViewerActionType.Offset, medicalKeys); 
      medicalKeys.Modifiers = MedicalViewerModifiers.Ctrl; 
      _medicalViewer.SetActionKeys(MedicalViewerActionType.WindowLevel, medicalKeys); 
      medicalKeys.MouseDown = Keys.PageDown; 
      medicalKeys.MouseUp = Keys.PageUp; 
      _medicalViewer.SetActionKeys(MedicalViewerActionType.Stack, medicalKeys); 
      medicalKeys.MouseDown = Keys.Subtract; 
      medicalKeys.MouseUp = Keys.Add; 
      _medicalViewer.SetActionKeys(MedicalViewerActionType.Scale, medicalKeys); 
 
      // Go through all the built in actions and remove the actions that have not been assigned to a mouse button, or a key. 
      int index = 1; 
      for (; index < 22; index++) 
      { 
         MedicalViewerActionType actionType = (MedicalViewerActionType)index; 
         if (_medicalViewer.IsActionAdded(actionType)) 
         { 
            MedicalViewerMouseButtons mouseButton = _medicalViewer.GetActionButton(actionType); 
            if (mouseButton == MedicalViewerMouseButtons.None) 
            { 
               MedicalViewerKeys keys = _medicalViewer.GetActionKeys(actionType); 
               if (keys.MouseLeft == Keys.None && keys.MouseUp == Keys.None && keys.MouseDown == Keys.None && keys.MouseRight == Keys.None) 
                  _medicalViewer.RemoveAction(actionType); 
            } 
         } 
      } 
 
      // Makes the window level applies the effect on all selected cells at the same time. 
      MedicalViewerActionFlags flags = _medicalViewer.GetActionFlags(MedicalViewerActionType.WindowLevel); 
      flags |= MedicalViewerActionFlags.Selected; 
      _medicalViewer.SetAction(MedicalViewerActionType.WindowLevel, MedicalViewerMouseButtons.Left, flags); 
 
 
      // Load an image and then add it to the control. 
      _image = _codecs.Load(@"E:\LEAD15\Dist\Images\image2.cmp"); 
      _medicalViewer.Cells.Add(new MedicalViewerCell(_image, true, 1, 1)); 
 
      // adjust some properties to 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); 
      _medicalViewer.Cells[0].SetTag(1, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "Good, Guy"); 
      _medicalViewer.Cells[0].SetTag(2, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "PID 125-98-445"); 
      _medicalViewer.Cells[0].SetTag(3, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "DOB 08/02/1929"); 
      _medicalViewer.Cells[0].SetTag(5, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "03/16/1999"); 
      _medicalViewer.Cells[0].SetTag(0, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.RulerUnit); 
      _medicalViewer.Cells[0].Rows = 2; 
      _medicalViewer.Cells[0].Columns = 2; 
      _medicalViewer.Cells[0].Frozen = false; 
      _medicalViewer.Cells[0].DisplayRulers = MedicalViewerRulers.Both; 
      _medicalViewer.Cells[0].ApplyOnIndividualSubCell = false; 
      _medicalViewer.Cells[0].ApplyActionOnMove = true; 
      _medicalViewer.Cells[0].FitImageToCell = true; 
      _medicalViewer.Cells[0].Selected = true; 
      _medicalViewer.Cells[0].ShowTags = true; 
 
      // Load an image and then add it to the control. 
      _image = _codecs.Load(@"E:\LEAD15\Dist\Images\image2.cmp"); 
      MedicalViewerCell cell = new MedicalViewerCell(); 
      cell.Image = _image; 
      cell.Rows = 2; 
      cell.Columns = 2; 
      cell.Frozen = false; 
      cell.DisplayRulers = MedicalViewerRulers.Both; 
      cell.ApplyOnIndividualSubCell = false; 
      cell.ApplyActionOnMove = true; 
      cell.FitImageToCell = true; 
      cell.Selected = true; 
      cell.ShowTags = true; 
      _medicalViewer.Cells.Add(cell); 
 
      // adjust some properties to 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); 
      _medicalViewer.Cells[1].SetTag(1, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "Good, Guy"); 
      _medicalViewer.Cells[1].SetTag(2, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "PID 125-98-445"); 
      _medicalViewer.Cells[1].SetTag(3, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "DOB 08/02/1929"); 
      _medicalViewer.Cells[1].SetTag(5, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "03/16/1999"); 
      _medicalViewer.Cells[1].SetTag(0, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.RulerUnit); 
 
      RasterCodecs.Shutdown(); 
      Controls.Add(_medicalViewer); 
   } 
}

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Leadtools.MedicalViewer requires a Medical toolkit license and unlock key. For more information, refer to: Raster Pro/Document/Medical Features