GetDisplayedClippedImageRectangle Method (original) (raw)

Summary

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

Syntax

public Rectangle GetDisplayedClippedImageRectangle() 

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

using Leadtools; using Leadtools.Codecs; using Leadtools.MedicalViewer; 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 actions 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 clicks and drags the mouse button, the associated action will be activated. cell.SetAction(MedicalViewerActionType.Offset, MedicalViewerMouseButtons.Right, MedicalViewerActionFlags.Active); cell.SetAction(MedicalViewerActionType.Scale, MedicalViewerMouseButtons.Middle, MedicalViewerActionFlags.Active); 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:\LEADTOOLS22\Resources\Images"; }