@@ -312,14 +312,7 @@ Public Sub DisplayCanvasCoordinates(ByVal xCoord As Double, ByVal yCoord As Doub
312312 'The position displayed changes based on the current measurement unit (px, in, cm)
313313 Else
314314 If PDImages.IsImageActive() Then
315- Select Case m_UnitOfMeasurement
316- Case mu_Pixels
317- lblCoordinates(0 ).Caption = "(" & Int(xCoord) & "," & Int(yCoord) & ")"
318- Case mu_Inches, mu_Centimeters
319- lblCoordinates(0 ).Caption = "(" & Format$(Units.ConvertPixelToOtherUnit(m_UnitOfMeasurement, xCoord, PDImages.GetActiveImage.GetDPI()), "0.0##" ) & "," & Format$(Units.ConvertPixelToOtherUnit(m_UnitOfMeasurement, yCoord, PDImages.GetActiveImage.GetDPI()), "0.0##" ) & ")"
320- Case mu_Millimeters, mu_Points, mu_Picas
321- lblCoordinates(0 ).Caption = "(" & Format$(Units.ConvertPixelToOtherUnit(m_UnitOfMeasurement, xCoord, PDImages.GetActiveImage.GetDPI()), "0.0#" ) & "," & Format$(Units.ConvertPixelToOtherUnit(m_UnitOfMeasurement, yCoord, PDImages.GetActiveImage.GetDPI()), "0.0#" ) & ")"
322- End Select
315+ lblCoordinates(0 ).Caption = "(" & Units.GetValueFormattedForUnit_FromPixel(m_UnitOfMeasurement, xCoord, PDImages.GetActiveImage.GetDPI(), PDImages.GetActiveImage.Width, False ) & "," & Units.GetValueFormattedForUnit_FromPixel(m_UnitOfMeasurement, yCoord, PDImages.GetActiveImage.GetDPI(), PDImages.GetActiveImage.Height, False ) & ")"
323316 End If
324317 End If
325318
@@ -348,32 +341,23 @@ Public Sub DisplayImageSize(ByRef srcImage As pdImage, Optional ByVal clearSize
348341 'When size IS displayed, we must also refresh the status bar (now that it dynamically aligns its contents)
349342 Else
350343
344+ Const TEXT_BETWEEN_DIMENSIONS As String = " x "
345+
351346 Dim unitWidth As Double , unitHeight As Double
352347 Dim sizeString As String
353348
354- 'Convert pixel measurements to the current unit
355- If (m_UnitOfMeasurement <> mu_Pixels) Then
349+ 'Convert pixel measurements to the current unit, then convert those to a string.
350+ ' (Different measurements support different significant digits in the size readout.)
351+ If (m_UnitOfMeasurement = mu_Pixels) Or (m_UnitOfMeasurement = mu_Percent) Then
352+ unitWidth = CStr(srcImage.Width)
353+ unitHeight = CStr(srcImage.Height)
354+ sizeString = Units.GetValueFormattedForUnit_FromPixel(mu_Pixels, unitWidth) & TEXT_BETWEEN_DIMENSIONS & Units.GetValueFormattedForUnit_FromPixel(mu_Pixels, unitHeight)
355+ Else
356356 unitWidth = ConvertPixelToOtherUnit(m_UnitOfMeasurement, srcImage.Width, srcImage.GetDPI(), srcImage.Width)
357357 unitHeight = ConvertPixelToOtherUnit(m_UnitOfMeasurement, srcImage.Height, srcImage.GetDPI(), srcImage.Height)
358+ sizeString = Units.GetValueFormattedForUnit_FromPixel(m_UnitOfMeasurement, unitWidth, srcImage.GetDPI(), srcImage.Width) & TEXT_BETWEEN_DIMENSIONS & Units.GetValueFormattedForUnit_FromPixel(m_UnitOfMeasurement, unitHeight, srcImage.GetDPI(), srcImage.Height)
358359 End If
359360
360- 'Different measurements support different significant digits in the size readout
361- Select Case m_UnitOfMeasurement
362-
363- Case mu_Pixels
364- sizeString = srcImage.Width & " x " & srcImage.Height
365-
366- Case mu_Inches
367- sizeString = Format$(unitWidth, "0.0##" ) & " x " & Format$(unitHeight, "0.0##" )
368-
369- Case mu_Centimeters, mu_Millimeters
370- sizeString = Format$(unitWidth, "0.0#" ) & " x " & Format$(unitHeight, "0.0#" )
371-
372- Case mu_Points, mu_Picas
373- sizeString = Format$(unitWidth, "0.0" ) & " x " & Format$(unitHeight, "0.0" )
374-
375- End Select
376-
377361 lblImgSize.Caption = sizeString
378362 ReflowStatusBar True
379363
@@ -407,12 +391,12 @@ Public Sub PopulateSizeUnits()
407391 cmbSizeUnit.Clear
408392
409393 Dim i As Long
410- For i = 1 To Units.GetNumOfAvailableUnits()
411- cmbSizeUnit.AddItem Units.GetNameOfUnit(i, True ), i - 1
394+ For i = 0 To Units.GetNumOfAvailableUnits()
395+ cmbSizeUnit.AddItem Units.GetNameOfUnit(i, True ), i
412396 Next i
413397
414398
415- cmbSizeUnit.ListIndex = 0
399+ cmbSizeUnit.ListIndex = 1
416400 cmbSizeUnit.SetAutomaticRedraws True , True
417401
418402End Sub
@@ -486,20 +470,9 @@ Public Sub SetSelectionState(ByVal newSelectionState As Boolean)
486470 Dim cString As pdString
487471 Set cString = New pdString
488472
489- Select Case m_UnitOfMeasurement
490- Case mu_Pixels
491- cString.Append Int(selectRect.Width + 0.5 )
492- cString.Append LOWERCASE_X
493- cString.Append Int(selectRect.Height + 0.5 )
494- Case mu_Inches, mu_Centimeters
495- cString.Append Format$(Units.ConvertPixelToOtherUnit(m_UnitOfMeasurement, selectRect.Width, PDImages.GetActiveImage.GetDPI()), "0.0##" )
496- cString.Append LOWERCASE_X
497- cString.Append Format$(Units.ConvertPixelToOtherUnit(m_UnitOfMeasurement, selectRect.Height, PDImages.GetActiveImage.GetDPI()), "0.0##" )
498- Case mu_Millimeters, mu_Points, mu_Picas
499- cString.Append Format$(Units.ConvertPixelToOtherUnit(m_UnitOfMeasurement, selectRect.Width, PDImages.GetActiveImage.GetDPI()), "0.0#" )
500- cString.Append LOWERCASE_X
501- cString.Append Format$(Units.ConvertPixelToOtherUnit(m_UnitOfMeasurement, selectRect.Height, PDImages.GetActiveImage.GetDPI()), "0.0#" )
502- End Select
473+ cString.Append Units.GetValueFormattedForUnit_FromPixel(m_UnitOfMeasurement, selectRect.Width, PDImages.GetActiveImage.GetDPI(), PDImages.GetActiveImage.Width, False )
474+ cString.Append LOWERCASE_X
475+ cString.Append Units.GetValueFormattedForUnit_FromPixel(m_UnitOfMeasurement, selectRect.Height, PDImages.GetActiveImage.GetDPI(), PDImages.GetActiveImage.Height, False )
503476
504477 'Also append the selection's aspect ratio, in the form X : 1
505478 If (selectRect.Height <> 0 !) Then
@@ -536,10 +509,10 @@ Public Sub SetSelectionState(ByVal newSelectionState As Boolean)
536509End Sub
537510
538511Private Sub cmbSizeUnit_Click ()
539- m_UnitOfMeasurement = cmbSizeUnit.ListIndex + 1
512+ m_UnitOfMeasurement = cmbSizeUnit.ListIndex
540513 If PDImages.IsImageActive() Then
541514 Me.DisplayImageSize PDImages.GetActiveImage()
542- FormMain.MainCanvas(0 ).NotifyRulerUnitChange cmbSizeUnit.ListIndex + 1
515+ FormMain.MainCanvas(0 ).NotifyRulerUnitChange cmbSizeUnit.ListIndex
543516 If (g_CurrentTool = ND_MEASURE) Then Tools_Measure.NotifyUnitChange
544517 If (g_CurrentTool = NAV_MOVE) Then Viewport.Stage4_FlipBufferAndDrawUI PDImages.GetActiveImage, FormMain.MainCanvas(0 )
545518 End If
0 commit comments