←Select platform

GetScaleMode Method

Summary

Gets the scale mode for the specified sub-cell.

Syntax

C#
VB
C++
Public Function GetScaleMode( _ 
   ByVal subCellIndex As Integer _ 
) As Leadtools.Medicalviewer.MedicalViewerScaleMode 

Parameters

subCellIndex
The zero-based index of the sub-cell which is having its scale mode retrieved.

Return Value

An enumerated MedicalViewerScaleMode value that represents the scale mode.

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(Int32) 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 get the scale of a cell or sub-cell use the GetScale(Int32) 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.
Example

C#
VB
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.MedicalViewer 
 
Private Class MedicalViewerForm : Inherits Form 
   Private _medicalViewer As MedicalViewer 
   Private applyEffects As Button 
   Private Sub MedicalViewerForm_SizeChanged(ByVal sender As Object, ByVal e As EventArgs) 
      _medicalViewer.Size = New Size(Me.ClientRectangle.Right - 30, Me.ClientRectangle.Bottom) 
   End Sub 
 
   Public Sub New() 
      Dim _codecs As RasterCodecs = New RasterCodecs() 
      Dim _image As RasterImage 
 
      AddHandler SizeChanged, AddressOf 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(Me.ClientRectangle.Right - 30, Me.ClientRectangle.Bottom) 
 
      ' Load an image and then add it to the control. 
      _image = _codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "xa.dcm")) 
      Dim cell As MedicalViewerMultiCell = 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" 
      AddHandler applyEffects.Click, AddressOf applyEffects_Click 
 
      Controls.Add(_medicalViewer) 
      _medicalViewer.Dock = DockStyle.Fill 
      Controls.Add(applyEffects) 
   End Sub 
 
   Private Sub applyEffects_Click(ByVal sender As Object, ByVal e As EventArgs) 
      Dim medicalViewer As MedicalViewer = CType(_medicalViewer, MedicalViewer) 
      Dim cell As MedicalViewerMultiCell = CType(medicalViewer.Cells(0), MedicalViewerMultiCell) 
      Dim cell1 As MedicalViewerMultiCell = CType(medicalViewer.Cells(1), MedicalViewerMultiCell) 
 
      Dim result As DialogResult = 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 Then 
         medicalViewer.BeginUpdate() 
      End If 
 
      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 
 
 
 
      Dim tagInformation As MedicalViewerTagInformation = 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) 
 
      Dim windowLevelProperties As MedicalViewerWindowLevel = CType(cell.GetActionProperties(MedicalViewerActionType.WindowLevel, 0), MedicalViewerWindowLevel) 
 
      windowLevelProperties.Width = 20 
      windowLevelProperties.Center = 50 
 
      cell.SetActionProperties(MedicalViewerActionType.WindowLevel, windowLevelProperties) 
 
 
      Dim scale As Double = cell.GetScale(0) 
 
      scale *= 2 
 
      cell.SetScale(-1, scale) 
 
      cell1.SetScale(0, scale) 
 
      Dim scaleMode As MedicalViewerScaleMode = cell.GetScaleMode(0) 
 
      If scaleMode = MedicalViewerScaleMode.Normal Then 
         scaleMode = MedicalViewerScaleMode.Fit 
      Else 
         scaleMode = MedicalViewerScaleMode.Normal 
      End If 
 
      cell.SetScaleMode(scaleMode) 
 
      If result = DialogResult.Yes Then 
         medicalViewer.EndUpdate() 
      End If 
 
   End Sub 
 
   Public ReadOnly Property Viewer() As MedicalViewer 
      Get 
         Return _medicalViewer 
      End Get 
   End Property 
End Class 
 
Private Function GetMedicalControl() As MedicalViewerForm 
   Return New MedicalViewerForm() 
End Function 
 
' 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 
<TestMethod()> _ 
Public Sub MedicalViewerTagInformationExample() 
   Dim myForm As MedicalViewerForm = GetMedicalControl() 
   Dim medicalViewer As MedicalViewer = myForm.Viewer 
 
   myForm.ShowDialog() 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" 
End Class 
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:\Users\Public\Documents\LEADTOOLS Images"; 
} 

Requirements

Target Platforms

Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
Leadtools.MedicalViewer Assembly
Click or drag to resize