LEADTOOLS Medical (Leadtools.MedicalViewer assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.31
GetDisplayedClippedImageRectangle Method
See Also 
Leadtools.MedicalViewer Namespace > MedicalViewerCell Class : GetDisplayedClippedImageRectangle Method



The GetDisplayedClippedImageRectangle Method is available as an add-on to the LEADTOOLS Medical Imaging toolkits.

(Read only) Gets the System.Drawing.Rectangle that represent the part of the cell or sub-cell that is occupied by the image.

Syntax

Visual Basic (Declaration) 
Public Function GetDisplayedClippedImageRectangle() As Rectangle
Visual Basic (Usage)Copy Code
Dim instance As MedicalViewerCell
Dim value As Rectangle
 
value = instance.GetDisplayedClippedImageRectangle()
C# 
public Rectangle GetDisplayedClippedImageRectangle()
C++/CLI 
public:
Rectangle GetDisplayedClippedImageRectangle(); 

Return Value

A System.Drawing.Rectangle that represents the part of the cell or sub-cell that is occupied by the image.

Example

Visual BasicCopy Code
Public Sub GetDisplayedClippedImageRectangle()
      Dim form As GetDispalyedClippedImageRectangleMainForm = New GetDispalyedClippedImageRectangleMainForm()
      form.ShowDialog()
   End Sub

   ' GetDispalyedClippedImageRectangleMainForm will be the owner of the medical viewer control.
   Private Class GetDispalyedClippedImageRectangleMainForm : Inherits Form
      Public _medicalViewer As MedicalViewer

      Private Sub MedicalViewerForm_SizeChanged(ByVal sender As Object, ByVal e As EventArgs)
         _medicalViewer.Size = New Size(Me.ClientRectangle.Right, Me.ClientRectangle.Bottom)
      End Sub

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

         ' Load an image and then add it to the control.
         _image = _codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "image2.cmp"))

         Dim cell As MedicalViewerMultiCell = New MedicalViewerMultiCell(_image, True, 1, 1)

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

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

         cell.SetTag(1, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.UserData)
         AddHandler cell.UIChanged, AddressOf Viewer_UIChanged

         _medicalViewer.Cells.Add(cell)

         Controls.Add(_medicalViewer)
         _medicalViewer.Dock = DockStyle.Fill
      End Sub

      Private Sub Viewer_UIChanged(ByVal sender As Object, ByVal e As MedicalViewerUIChangedEventArgs)
         Dim cell As MedicalViewerMultiCell = CType(sender, MedicalViewerMultiCell)
         If e.ActionType = MedicalViewerActionType.Offset OrElse e.ActionType = MedicalViewerActionType.Scale Then
            Dim theClippedRectangle As Rectangle = cell.GetDisplayedClippedImageRectangle()
            Dim ImageRectangle As Rectangle = cell.GetDisplayedImageRectangle()

            Dim Ratio As Integer = (theClippedRectangle.Width * theClippedRectangle.Height) * 1000 \ (ImageRectangle.Width * ImageRectangle.Height)

            Dim doubleRatio As Double = Ratio / 1000.0

            Dim info As MedicalViewerTagInformation = New MedicalViewerTagInformation(1, MedicalViewerTagAlignment.BottomLeft, "Area of the image visible is " & (doubleRatio * 100).ToString() & "% of the whole image", MedicalViewerTagType.UserData)
            _medicalViewer.Cells(e.CellIndex).EditTag(1, MedicalViewerTagAlignment.BottomLeft, info)
         End If
      End Sub
   End Class

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
C#Copy Code
public void GetDisplayedClippedImageRectangle()
   {
      GetDispalyedClippedImageRectangleMainForm form = new GetDispalyedClippedImageRectangleMainForm();
      form.ShowDialog();
   }

   // GetDispalyedClippedImageRectangleMainForm will be the owner of the medical viewer control.
    class GetDispalyedClippedImageRectangleMainForm : Form
   {
      public MedicalViewer _medicalViewer;

      void MedicalViewerForm_SizeChanged(object sender, EventArgs e)
      {
         _medicalViewer.Size = new Size(this.ClientRectangle.Right, this.ClientRectangle.Bottom);
      }

      public GetDispalyedClippedImageRectangleMainForm()
      {
         RasterCodecs _codecs = new RasterCodecs();
         RasterImage _image;

         // Create the medical viewer and adjust some properties.
         _medicalViewer = new MedicalViewer();
         _medicalViewer.Rows = 2;
         _medicalViewer.Columns = 1;
         _medicalViewer.Location = new Point(0, 0);
         _medicalViewer.Size = new Size(this.ClientRectangle.Right, this.ClientRectangle.Bottom);

         // Load an image and then add it to the control.
         _image = _codecs.Load(Path.Combine(LEAD_VARS.ImagesDir,"image2.cmp"));

         MedicalViewerMultiCell cell = new MedicalViewerMultiCell(_image, true, 1, 1);

         // add some action that will be used to change the properties of the images inside the control.
         cell.AddAction(MedicalViewerActionType.Scale);
         cell.AddAction(MedicalViewerActionType.Offset);

         // assign the added actions to a mouse button, meaning that when the user click and drag the mouse button, the associated action will be activated.
         cell.SetAction(MedicalViewerActionType.Offset, MedicalViewerMouseButtons.Right, MedicalViewerActionFlags.Active | MedicalViewerActionFlags.RealTime);
         cell.SetAction(MedicalViewerActionType.Scale, MedicalViewerMouseButtons.Middle, MedicalViewerActionFlags.Active | MedicalViewerActionFlags.RealTime);

         cell.SetTag(1, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.UserData);
         cell.UIChanged += new EventHandler<MedicalViewerUIChangedEventArgs>(Viewer_UIChanged);

         _medicalViewer.Cells.Add(cell);

         Controls.Add(_medicalViewer);
         _medicalViewer.Dock = DockStyle.Fill;
      }

      void Viewer_UIChanged(object sender, MedicalViewerUIChangedEventArgs e)
      {
         MedicalViewerMultiCell cell = (MedicalViewerMultiCell)sender;
          if (e.ActionType == MedicalViewerActionType.Offset || e.ActionType == MedicalViewerActionType.Scale)
          {
              Rectangle theClippedRectangle = cell.GetDisplayedClippedImageRectangle();
              Rectangle ImageRectangle = cell.GetDisplayedImageRectangle();

              int Ratio = (theClippedRectangle.Width * theClippedRectangle.Height) * 1000 / (ImageRectangle.Width * ImageRectangle.Height);

              double doubleRatio = Ratio / 1000.0;

              MedicalViewerTagInformation info = new MedicalViewerTagInformation(1, MedicalViewerTagAlignment.BottomLeft, "Area of the image visible is " + (doubleRatio * 100).ToString()  + "% of the whole image", MedicalViewerTagType.UserData);
              _medicalViewer.Cells[e.CellIndex].EditTag(1, MedicalViewerTagAlignment.BottomLeft, info);
          }
      }
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}

Remarks

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7

See Also

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