Gets the
Rectangle that represent the part of the cell/sub-cell that is occupied by the image.
Syntax
Visual Basic (Declaration) | |
---|
Public Overloads 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
Rectangle that represents the part of the cell/sub-cell that is occupied by the image.
Example
Visual Basic | Copy Code |
---|
Public Sub GetDisplayedClippedImageRectangle()
Dim form As GetDispalyedClippedImageRectangleMainForm = New GetDispalyedClippedImageRectangleMainForm()
form.ShowDialog()
End Sub
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()
RasterCodecs.Startup()
Dim _codecs As RasterCodecs = New RasterCodecs()
Dim _image As RasterImage
_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)
_medicalViewer.AddAction(MedicalViewerActionType.Scale)
_medicalViewer.AddAction(MedicalViewerActionType.Offset)
_medicalViewer.SetAction(MedicalViewerActionType.Offset, MedicalViewerMouseButtons.Right, MedicalViewerActionFlags.Active Or MedicalViewerActionFlags.RealTime)
_medicalViewer.SetAction(MedicalViewerActionType.Scale, MedicalViewerMouseButtons.Middle, MedicalViewerActionFlags.Active Or MedicalViewerActionFlags.RealTime)
_image = _codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path & "image2.cmp")
_medicalViewer.Cells.Add(New MedicalViewerCell(_image, True, 1, 1))
_image = _codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path & "image2.cmp")
Dim cell As MedicalViewerCell = New MedicalViewerCell()
_medicalViewer.Cells.Add(cell)
RasterCodecs.Shutdown()
Controls.Add(_medicalViewer)
_medicalViewer.Cells(0).SetTag(1, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.UserData)
AddHandler _medicalViewer.UIChanged, AddressOf Viewer_UIChanged
End Sub
Private Sub Viewer_UIChanged(ByVal sender As Object, ByVal e As MedicalViewerUIChangedEventArgs)
If e.ActionType = MedicalViewerActionType.Offset OrElse e.ActionType = MedicalViewerActionType.Scale Then
Dim theClippedRectangle As Rectangle = _medicalViewer.Cells(0).GetDisplayedClippedImageRectangle()
Dim ImageRectangle As Rectangle = _medicalViewer.Cells(0).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.ToString() & "% of the whole image", MedicalViewerTagType.UserData)
_medicalViewer.Cells(e.CellIndex).EditTag(1, MedicalViewerTagAlignment.BottomLeft, info)
End If
End Sub
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.Startup(); 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); // add some action that will be used to change the properties of the images inside the control. _medicalViewer.AddAction(MedicalViewerActionType.Scale); _medicalViewer.AddAction(MedicalViewerActionType.Offset); // 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.Offset, MedicalViewerMouseButtons.Right, MedicalViewerActionFlags.Active | MedicalViewerActionFlags.RealTime); _medicalViewer.SetAction(MedicalViewerActionType.Scale, MedicalViewerMouseButtons.Middle, MedicalViewerActionFlags.Active | MedicalViewerActionFlags.RealTime); // Load an image and then add it to the control. _image = _codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "image2.cmp"); _medicalViewer.Cells.Add(new MedicalViewerCell(_image, true, 1, 1)); // Load an image and then add it to the control. _image = _codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "image2.cmp"); MedicalViewerCell cell = new MedicalViewerCell(); _medicalViewer.Cells.Add(cell); RasterCodecs.Shutdown(); Controls.Add(_medicalViewer); _medicalViewer.Cells[0].SetTag(1, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.UserData); _medicalViewer.UIChanged += new EventHandler<MedicalViewerUIChangedEventArgs>(Viewer_UIChanged); } void Viewer_UIChanged(object sender, MedicalViewerUIChangedEventArgs e) { if (e.ActionType == MedicalViewerActionType.Offset || e.ActionType == MedicalViewerActionType.Scale) { Rectangle theClippedRectangle = _medicalViewer.Cells[0].GetDisplayedClippedImageRectangle(); Rectangle ImageRectangle = _medicalViewer.Cells[0].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.ToString() + "% of the whole image", MedicalViewerTagType.UserData); _medicalViewer.Cells[e.CellIndex].EditTag(1, MedicalViewerTagAlignment.BottomLeft, info); } } } |
Remarks
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