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




Optional delegate method for additional processing.

Syntax

Visual Basic (Declaration) 
Public Event CustomPaint() As EventHandler(Of MedicalViewerPaintEventArgs)
Visual Basic (Usage)Copy Code
Dim instance As MedicalViewer
Dim handler As EventHandler(Of MedicalViewerPaintEventArgs)
 
AddHandler instance.CustomPaint, handler
C# 
public event EventHandler<MedicalViewerPaintEventArgs> CustomPaint()
Managed Extensions for C++ 
public: __event EventHandler<MedicalViewerPaintEventArgs>* CustomPaint();
C++/CLI 
public:
event EventHandler<MedicalViewerPaintEventArgs>^ CustomPaint();

Example

Add some event to apply some additional painting and processing

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

   Private Sub _medicalViewer_UserActionMouseMove(ByVal sender As Object, ByVal e As MedicalViewerMouseEventArgs)
      ' Increase the gamma of the image as the user dragges the mouse.
      If (e.CellIndex = 0) AndAlso (e.ActionID = 101) AndAlso _mouseDown Then
         e.Images(0).PaintGamma += 100
      End If
   End Sub

   Private Sub _medicalViewer_UserActionMouseUp(ByVal sender As Object, ByVal e As MedicalViewerMouseEventArgs)
      _mouseDown = False
   End Sub

   Private Sub _medicalViewer_UserActionMouseDown(ByVal sender As Object, ByVal e As MedicalViewerMouseEventArgs)
      _mouseDown = True
   End Sub

   Private Sub _medicalViewer_UserActionKeyDown(ByVal sender As Object, ByVal e As MedicalViewerKeyEventArgs)
      If (e.ActionID = 101) AndAlso (e.CellIndex = 0) AndAlso _mouseDown Then
         e.Images(0).PaintGamma -= 10
      End If
   End Sub

   Private Sub _medicalViewer_UserActionKeyUp(ByVal sender As Object, ByVal e As MedicalViewerKeyEventArgs)
      If (e.ActionID = 101) AndAlso (e.CellIndex = 0) AndAlso _mouseDown Then
         e.Images(0).PaintGamma += 10
      End If
   End Sub


   Private Sub _medicalViewer_CustomPaint(ByVal sender As Object, ByVal e As MedicalViewerPaintEventArgs)
      ' draw red ellipse around the first frame of the first cell.
      If (e.CellIndex = 0) AndAlso (e.SubCellIndex = 0) Then
         e.Graphics.DrawEllipse(Pens.Red, e.ClipRectangle)
      End If
   End Sub

   Private Sub _medicalViewer_UserTag(ByVal sender As Object, ByVal e As MedicalViewerUserTagEventArgs)
      ' draw red string at the bottom right edge of the first cell.
      If e.CellIndex = 0 Then
         e.Graphics.DrawString("Owner Draw", New Font(FontFamily.GenericSerif, 15), Brushes.Red, New PointF(e.ClipRectangle.Left, e.ClipRectangle.Top))
      End If
   End Sub

   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 = 1
      _medicalViewer.Columns = 2
      _medicalViewer.Location = New Point(0, 0)
      _medicalViewer.Size = New Size(Me.ClientRectangle.Right, Me.ClientRectangle.Bottom)

      _medicalViewer.AddAction(CType(101, MedicalViewerActionType))
      _medicalViewer.SetAction(CType(101, MedicalViewerActionType), MedicalViewerMouseButtons.Left, MedicalViewerActionFlags.Active Or MedicalViewerActionFlags.RealTime)

      AddHandler _medicalViewer.UserTag, AddressOf _medicalViewer_UserTag
      AddHandler _medicalViewer.CustomPaint, AddressOf _medicalViewer_CustomPaint
      AddHandler _medicalViewer.UserActionMouseDown, AddressOf _medicalViewer_UserActionMouseDown
      AddHandler _medicalViewer.UserActionMouseUp, AddressOf _medicalViewer_UserActionMouseUp
      AddHandler _medicalViewer.UserActionMouseMove, AddressOf _medicalViewer_UserActionMouseMove
      AddHandler _medicalViewer.UserActionKeyUp, AddressOf _medicalViewer_UserActionKeyUp
      AddHandler _medicalViewer.UserActionKeyDown, AddressOf _medicalViewer_UserActionKeyDown

      ' Load an image and then add it to the control.
      _image = _codecs.Load("E:\program files\Lead technologies\Images\image3.dcm")
      _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).SetTag(0, MedicalViewerTagAlignment.BottomRight, MedicalViewerTagType.OwnerDraw)

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

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

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

   private MedicalViewer _medicalViewer; 
   private bool _mouseDown; 
 
   void _medicalViewer_UserActionMouseMove(object sender, MedicalViewerMouseEventArgs e) 
   { 
      // Increase the gamma of the image as the user dragges the mouse. 
      if ((e.CellIndex == 0) && (e.ActionID == 101) && _mouseDown) 
         e.Images[0].PaintGamma += 100; 
   } 
 
   void _medicalViewer_UserActionMouseUp(object sender, MedicalViewerMouseEventArgs e) 
   { 
      _mouseDown = false; 
   } 
 
   void _medicalViewer_UserActionMouseDown(object sender, MedicalViewerMouseEventArgs e) 
   { 
      _mouseDown = true; 
   } 
 
   void _medicalViewer_UserActionKeyDown(object sender, MedicalViewerKeyEventArgs e) 
   { 
      if ((e.ActionID == 101) && (e.CellIndex == 0) && _mouseDown) 
         e.Images[0].PaintGamma -= 10; 
   } 
 
   void _medicalViewer_UserActionKeyUp(object sender, MedicalViewerKeyEventArgs e) 
   { 
      if ((e.ActionID == 101) && (e.CellIndex == 0) && _mouseDown) 
         e.Images[0].PaintGamma += 10; 
   } 
 
   void _medicalViewer_CustomPaint(object sender, MedicalViewerPaintEventArgs e) 
   { 
      // draw red ellipse around the first frame of the first cell. 
      if ((e.CellIndex == 0) && (e.SubCellIndex == 0)) 
         e.Graphics.DrawEllipse(Pens.Red, e.ClipRectangle); 
   } 
 
   void _medicalViewer_UserTag(object sender, MedicalViewerUserTagEventArgs e) 
   { 
      // draw red string at the bottom right edge of the first cell. 
      if (e.CellIndex == 0) 
         e.Graphics.DrawString("Owner Draw", new Font(FontFamily.GenericSerif, 15), Brushes.Red, new PointF(e.ClipRectangle.Left, e.ClipRectangle.Top)); 
   } 
 
   public MainForm3() 
   { 
      RasterCodecs.Startup(); 
      RasterCodecs _codecs = new RasterCodecs(); 
      RasterImage _image; 
 
      // Create the medical viewer and adjust some properties. 
      _medicalViewer = new MedicalViewer(); 
      _medicalViewer.Rows = 1; 
      _medicalViewer.Columns = 2; 
      _medicalViewer.Location = new Point(0, 0); 
      _medicalViewer.Size = new Size(this.ClientRectangle.Right, this.ClientRectangle.Bottom); 
 
      _medicalViewer.AddAction((MedicalViewerActionType)101); 
      _medicalViewer.SetAction((MedicalViewerActionType)101, MedicalViewerMouseButtons.Left, MedicalViewerActionFlags.Active | MedicalViewerActionFlags.RealTime); 
 
      _medicalViewer.UserTag += new EventHandler<MedicalViewerUserTagEventArgs>(_medicalViewer_UserTag); 
      _medicalViewer.CustomPaint += new EventHandler<MedicalViewerPaintEventArgs>(_medicalViewer_CustomPaint); 
      _medicalViewer.UserActionMouseDown += new EventHandler<MedicalViewerMouseEventArgs>(_medicalViewer_UserActionMouseDown); 
      _medicalViewer.UserActionMouseUp += new EventHandler<MedicalViewerMouseEventArgs>(_medicalViewer_UserActionMouseUp); 
      _medicalViewer.UserActionMouseMove += new EventHandler<MedicalViewerMouseEventArgs>(_medicalViewer_UserActionMouseMove); 
      _medicalViewer.UserActionKeyUp += new EventHandler<MedicalViewerKeyEventArgs>(_medicalViewer_UserActionKeyUp); 
      _medicalViewer.UserActionKeyDown += new EventHandler<MedicalViewerKeyEventArgs>(_medicalViewer_UserActionKeyDown); 
 
      // Load an image and then add it to the control. 
      _image = _codecs.Load(@"E:\program files\Lead technologies\Images\image3.dcm"); 
      _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].SetTag(0, MedicalViewerTagAlignment.BottomRight, MedicalViewerTagType.OwnerDraw); 
 
      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