From 6d07a533d76a6c5a4c6f578b317b8272b886a489 Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Wed, 2 Aug 2023 22:29:04 -0400 Subject: [PATCH] rearrange & shorten some statusbar items --- Program.cs | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/Program.cs b/Program.cs index 0a1f021..eb70131 100644 --- a/Program.cs +++ b/Program.cs @@ -179,6 +179,7 @@ public class Photo { public DateTime DateTimeOriginal; public string CameraModel = ""; public string LensModel = ""; + public string ShortLensModel = ""; public string FocalLength = ""; public string FNumber = ""; public string ExposureTime = ""; @@ -343,6 +344,7 @@ public class Photo { IExifValue? lensModel; if (exifs.TryGetValue(ExifTag.LensModel, out lensModel)) { LensModel = lensModel.Value ?? ""; + ShortLensModel = GetShortLensModel(LensModel); } IExifValue? focalLength; @@ -411,6 +413,23 @@ public class Photo { } } + public string GetShortLensModel(string lensModel) { + // Example Canon RF lens names: + // RF16mm F2.8 STM + // RF24-105mm F4-7.1 IS STM + // RF35mm F1.8 MACRO IS STM + // RF100-400mm F5.6-8 IS USM + string[] tokens = lensModel.Split(' '); + string result = ""; + foreach (string token in tokens) { + if (token == "STM" || token == "IS" || token == "USM") { + continue; + } + result += token + " "; + } + return result.Trim(); + } + public Texture Texture() { LastTouch = touchCounter++; if (texture == placeholder && image != null) { @@ -427,8 +446,9 @@ public class Photo { public string Description() { string date = DateTimeOriginal.ToString("yyyy-MM-dd HH:mm:ss"); - string shootingInfo = $"{date} {FocalLength}, {FNumber} at {ExposureTime}, {IsoSpeed}"; - return String.Format("{0,-60} {1,-50} {2}", shootingInfo, $"{CameraModel} {LensModel}", Filename); + return String.Format( + "{0,6} {1,-5} {2,-7} {3,-10} {4} {5,-20} {6}", + FocalLength, FNumber, ExposureTime, IsoSpeed, date, ShortLensModel, Filename); } } @@ -890,8 +910,9 @@ public class Game : GameWindow { // Load photos from a directory. // string[] files = Directory.GetFiles(@"c:\users\colin\desktop\photos-test\"); - // string[] files = Directory.GetFiles(@"c:\users\colin\pictures\photos\2023\07\14\"); - string[] files = Directory.GetFiles(@"G:\DCIM\100EOSR6\"); + string[] files = Directory.GetFiles(@"c:\users\colin\pictures\photos\2023\07\14\"); + // string[] files = Directory.GetFiles(@"c:\users\colin\pictures\photos\2023\07\23\"); + // string[] files = Directory.GetFiles(@"G:\DCIM\100EOSR6\"); // string[] files = Directory.GetFiles(@"c:\users\colin\desktop\totte-output\2023\07\31"); // string[] files = Directory.GetFiles(@"C:\Users\colin\Pictures\photos\2018\06\23"); // string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\Germany all\104D7000"); @@ -1107,15 +1128,16 @@ public class Game : GameWindow { DrawFilledBox(geometry.StatusBox, Color4.Black); // First line. int y = geometry.StatusBox.Min.Y + statusPadding; - DrawText(activePhoto.Description(), geometry.StatusBox.Min.X, y); + DrawText(String.Format("{0,4}/{1,-4}", photoIndex + 1, photos.Count), geometry.StatusBox.Min.X, y); + DrawText(activePhoto.Description(), geometry.StatusBox.Min.X + 88, y); + // Second line. y += 20; - DrawText(String.Format("{0,4}/{1,-4}", photoIndex + 1, photos.Count), geometry.StatusBox.Min.X + 72, y); DrawText(String.Format("FPS: {0,2}", fpsCounter.Fps), geometry.StatusBox.Max.X - 66, y); if (activePhoto.Loaded) { DrawText($"{(scale * 100):F1}%", geometry.StatusBox.Min.X, y); } - DrawText($"({mousePosition.X}, {mousePosition.Y})", geometry.StatusBox.Min.X + 160, y); + DrawText($"({mousePosition.X}, {mousePosition.Y})", geometry.StatusBox.Min.X + 72, y); Vector2i imagePosition = ScreenToImage(mousePosition); DrawText($"({imagePosition.X}, {imagePosition.Y})", geometry.StatusBox.Min.X + 320, y); }