GetScale Method

Summary
Gets the scale of the image.
Syntax
C#
C++/CLI
public double GetScale() 
            public: 
double GetScale();  

Return Value

The scale value.

Remarks

Currently, there are two ways to fit the image to cell. One is by setting the FitImageToCell property to true. The other way is by using the SetScale and GetScale methods. In order to be able to use them, make sure that FitImageToCell is set to false.

To set the scale of a cell or sub-cell use the SetScale method.

To set the properties of the scale action use the SetActionProperties method.

To retrieve the properties of the scale action use the GetActionProperties method.

To set the scale mode of a cell or sub-cell use the SetScaleMode method.

To get the scale mode of a cell or sub-cell use the MedicalViewerMultiCell.GetScaleMode method.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.MedicalViewer; 
 
class MedicalViewerForm : Form 
{ 
   private MedicalViewer _medicalViewer; 
   private Button applyEffects; 
 
   void MedicalViewerForm_SizeChanged(object sender, EventArgs e) 
   { 
      _medicalViewer.Size = new Size(this.ClientRectangle.Right - 30, this.ClientRectangle.Bottom); 
   } 
 
   public MedicalViewerForm() 
   { 
      RasterCodecs _codecs = new RasterCodecs(); 
      RasterImage _image; 
 
      this.SizeChanged += new EventHandler(MedicalViewerForm_SizeChanged); 
 
      // Create the medical viewer and adjust the size and the location. 
      _medicalViewer = new MedicalViewer(1, 2); 
      _medicalViewer.Location = new Point(30, 0); 
      _medicalViewer.Size = new Size(this.ClientRectangle.Right - 30, this.ClientRectangle.Bottom); 
 
      // Load an image and then add it to the control. 
      _image = _codecs.Load(Path.Combine(LEAD_VARS.ImagesDir,"xa.dcm")); 
      MedicalViewerMultiCell cell = new MedicalViewerMultiCell(_image, true, 1, 1); 
      _medicalViewer.Cells.Add(cell); 
 
      // add some actions that will be used to change the properties of the images inside the control. 
      cell.AddAction(MedicalViewerActionType.WindowLevel); 
      cell.AddAction(MedicalViewerActionType.Alpha); 
      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.WindowLevel, MedicalViewerMouseButtons.Left, MedicalViewerActionFlags.Active); 
      cell.SetAction(MedicalViewerActionType.Alpha, MedicalViewerMouseButtons.Middle, MedicalViewerActionFlags.Active); 
      cell.SetAction(MedicalViewerActionType.Offset, MedicalViewerMouseButtons.Right, MedicalViewerActionFlags.Active); 
 
      // adjust some properties of 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); 
 
      // Load another image and then add it to the control. 
      _image = _codecs.Load(Path.Combine(LEAD_VARS.ImagesDir,"mr.dcm")); 
      _medicalViewer.Cells.Add(new MedicalViewerMultiCell(_image, true, 2, 2)); 
 
      // adjust some properties of 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); 
 
 
      applyEffects = new Button(); 
      applyEffects.Location = new Point(0, 0); 
      applyEffects.Size = new Size(30, 15); 
      applyEffects.Text = "Apply Effects"; 
      applyEffects.Click += new EventHandler(applyEffects_Click); 
 
      Controls.Add(_medicalViewer); 
      _medicalViewer.Dock = DockStyle.Fill; 
      Controls.Add(applyEffects); 
   } 
 
   void applyEffects_Click(object sender, EventArgs e) 
   { 
      MedicalViewer medicalViewer = (MedicalViewer)_medicalViewer; 
      MedicalViewerMultiCell cell = (MedicalViewerMultiCell)(medicalViewer.Cells[0]); 
      MedicalViewerMultiCell cell1 = (MedicalViewerMultiCell)(medicalViewer.Cells[1]); 
 
      DialogResult result = MessageBox.Show(@"This demo will do some effects on the Medical viewer, Do you want to use the begin and update update?", "Begin Update And End Update Demo", MessageBoxButtons.YesNo); 
 
      if (result == DialogResult.Yes) 
         medicalViewer.BeginUpdate(); 
 
      cell.SetTag( 8, 0,  MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.UserData, "Sub Cell Tag 1"); 
      cell.SetTag( 0, 8,  MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.UserData, "Sub Cell Tag 2"); 
      cell1.SetTag( 1, 9,  MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.UserData, "Sub Cell Tag 3"); 
      cell1.SetTag( 2, 10, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.UserData, "Sub Cell Tag 4"); 
      cell1.SetTag( 3, 11, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.UserData, "Sub Cell Tag 5"); 
 
      cell.Rows = 3; 
      cell.Columns = 3; 
      cell.FitImageToCell = false; 
 
 
 
      MedicalViewerTagInformation tagInformation = new MedicalViewerTagInformation(); 
 
      tagInformation.Alignment = MedicalViewerTagAlignment.BottomLeft; 
      tagInformation.Position = 3; 
      tagInformation.Text = "Edit Text 1"; 
 
 
      cell.EditTag(8, 0, MedicalViewerTagAlignment.TopLeft, tagInformation); 
 
 
      tagInformation = new MedicalViewerTagInformation(); 
      tagInformation.Type = MedicalViewerTagType.Scale; 
 
      cell.EditTag(8, 0, MedicalViewerTagAlignment.BottomLeft, tagInformation); 
 
 
      cell.DeleteTag(0, 8, MedicalViewerTagAlignment.TopLeft); 
 
      // Shift the second row, one row down 
      tagInformation = cell.GetTag(2, 10, MedicalViewerTagAlignment.TopLeft); 
             
      tagInformation.Position += 1; 
 
      cell.EditTag(2, 10, MedicalViewerTagAlignment.TopLeft, tagInformation); 
 
      // Shift the second row, one row down 
      tagInformation = cell.GetTag(2, MedicalViewerTagAlignment.TopLeft); 
 
      tagInformation.Text = "Edited sub-cell Tag1"; 
      cell.EditTag(2, MedicalViewerTagAlignment.TopLeft, tagInformation); 
 
      cell.DeleteTag(4, MedicalViewerTagAlignment.TopLeft); 
 
      MedicalViewerWindowLevel windowLevelProperties = (MedicalViewerWindowLevel)cell.GetActionProperties(MedicalViewerActionType.WindowLevel, 0); 
 
      windowLevelProperties.Width = 20; 
      windowLevelProperties.Center = 50; 
 
      cell.SetActionProperties(MedicalViewerActionType.WindowLevel, windowLevelProperties); 
 
 
      double scale = cell.GetScale(0); 
 
      scale *= 2; 
 
      cell.SetScale(-1, scale); 
 
      cell1.SetScale(0, scale); 
 
      MedicalViewerScaleMode scaleMode = cell.GetScaleMode(0); 
 
      if (scaleMode == MedicalViewerScaleMode.Normal) 
         scaleMode = MedicalViewerScaleMode.Fit; 
      else 
         scaleMode = MedicalViewerScaleMode.Normal; 
 
      cell.SetScaleMode(scaleMode); 
 
      if (result == DialogResult.Yes) 
         medicalViewer.EndUpdate(); 
 
   } 
 
   public MedicalViewer Viewer 
   { 
      get { return _medicalViewer; } 
   } 
} 
 
MedicalViewerForm GetMedicalControl() 
{ 
   return new MedicalViewerForm(); 
} 
 
// This example creates a medical viewer control and two cells. when you click on the button it will ask you whether to apply some effects on the cell with or without using BeginUpdate/EndUpdate. Run this sample twice and see the difference 
public void MedicalViewerTagInformationExample() 
{ 
   MedicalViewerForm myForm = GetMedicalControl(); 
   MedicalViewer medicalViewer = myForm.Viewer; 
 
   myForm.ShowDialog(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.MedicalViewer Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.