Selaa lähdekoodia

Delete text transformation option (#103)

Daniel Chalmers 1 kuukausi sitten
vanhempi
sitoutus
219b341e27

+ 0 - 25
DesktopClock.Tests/TimeStringFormatterTests.cs

@@ -19,7 +19,6 @@ public class TimeStringFormatterTests
             default,
             "HH:mm",
             null,
-            TextTransform.None,
             CultureInfo.InvariantCulture);
 
         Assert.Equal("12:15", result);
@@ -38,7 +37,6 @@ public class TimeStringFormatterTests
             default,
             "d",
             null,
-            TextTransform.None,
             formatProvider);
 
         Assert.Equal(now.ToString("d", formatProvider), result);
@@ -58,7 +56,6 @@ public class TimeStringFormatterTests
             countdownTo,
             "HH:mm",
             "{hh\\:mm}",
-            TextTransform.None,
             CultureInfo.InvariantCulture);
 
         Assert.Equal("01:02", result);
@@ -79,7 +76,6 @@ public class TimeStringFormatterTests
             countdownTo,
             "HH:mm",
             "c",
-            TextTransform.None,
             formatProvider);
 
         Assert.Equal((countdownTo - nowDateTime).ToString("c", formatProvider), result);
@@ -108,7 +104,6 @@ public class TimeStringFormatterTests
                 countdownTo,
                 "HH:mm",
                 " ",
-                TextTransform.None,
                 CultureInfo.CurrentCulture);
 
             Assert.Equal(countdownTo.Humanize(utcDate: false, dateToCompareAgainst: nowDateTime), result);
@@ -133,28 +128,8 @@ public class TimeStringFormatterTests
             default,
             "HH:mm",
             null,
-            TextTransform.None,
             CultureInfo.InvariantCulture);
 
         Assert.Equal("18:30", result);
     }
-
-    [Fact]
-    public void Format_AppliesTextTransform()
-    {
-        var now = new DateTimeOffset(2024, 1, 1, 13, 5, 0, TimeSpan.Zero);
-        var formatProvider = new CultureInfo("en-US");
-
-        var result = TimeStringFormatter.Format(
-            now,
-            now.DateTime,
-            TimeZoneInfo.Utc,
-            default,
-            "h:mm tt",
-            null,
-            TextTransform.Lowercase,
-            formatProvider);
-
-        Assert.Equal("1:05 pm", result);
-    }
 }

+ 0 - 8
DesktopClock/Data/TextTransform.cs

@@ -1,8 +0,0 @@
-namespace DesktopClock;
-
-public enum TextTransform
-{
-    None,
-    Uppercase,
-    Lowercase,
-}

+ 0 - 2
DesktopClock/MainWindow.xaml.cs

@@ -169,7 +169,6 @@ public partial class MainWindow : Window
 
             case nameof(Settings.Default.Format):
             case nameof(Settings.Default.CountdownFormat):
-            case nameof(Settings.Default.TextTransform):
                 UpdateTimeString();
                 break;
 
@@ -279,7 +278,6 @@ public partial class MainWindow : Window
             Settings.Default.CountdownTo,
             Settings.Default.Format,
             Settings.Default.CountdownFormat,
-            Settings.Default.TextTransform,
             CultureInfo.DefaultThreadCurrentCulture);
     }
 

+ 0 - 5
DesktopClock/Properties/Settings.cs

@@ -114,11 +114,6 @@ public sealed class Settings : INotifyPropertyChanged, IDisposable
     /// </summary>
     public string FontWeight { get; set; } = "Normal";
 
-    /// <summary>
-    /// Text transformation to apply to the clock's text.
-    /// </summary>
-    public TextTransform TextTransform { get; set; } = TextTransform.None;
-
     /// <summary>
     /// Text color for the clock's text.
     /// </summary>

+ 0 - 8
DesktopClock/SettingsWindow.xaml

@@ -265,14 +265,6 @@
                                Margin="0,0,0,16"
                                Style="{StaticResource DescriptionTextBlock}" />
 
-                    <TextBlock Text="Capitalization"
-                               Style="{StaticResource LabelTextBlock}" />
-                    <ComboBox ItemsSource="{Binding TextTransforms}"
-                              SelectedItem="{Binding Settings.TextTransform, Mode=TwoWay}" />
-                    <TextBlock Text="Change the displayed text to uppercase or lowercase."
-                               Margin="0,0,0,16"
-                               Style="{StaticResource DescriptionTextBlock}" />
-
                     <TextBlock Text="Text color"
                                Style="{StaticResource LabelTextBlock}" />
                     <Grid Style="{StaticResource ControlRow}">

+ 0 - 6
DesktopClock/SettingsWindow.xaml.cs

@@ -240,7 +240,6 @@ public partial class SettingsWindowViewModel : ObservableObject
         FontFamilies = GetAllSystemFonts().Distinct().OrderBy(f => f).ToList();
         FontStyles = ["Normal", "Italic", "Oblique"];
         FontWeights = ["Thin", "ExtraLight", "Light", "Normal", "Medium", "SemiBold", "Bold", "ExtraBold", "Black", "ExtraBlack"];
-        TextTransforms = Enum.GetValues(typeof(TextTransform)).Cast<TextTransform>().ToArray();
         ImageStretches = Enum.GetValues(typeof(Stretch)).Cast<Stretch>().ToArray();
         TimeZones = TimeZoneInfo.GetSystemTimeZones();
     }
@@ -260,11 +259,6 @@ public partial class SettingsWindowViewModel : ObservableObject
     /// </summary>
     public IList<string> FontWeights { get; }
 
-    /// <summary>
-    /// All available text transformations.
-    /// </summary>
-    public IList<TextTransform> TextTransforms { get; }
-
     /// <summary>
     /// All available stretch options for background images.
     /// </summary>

+ 1 - 17
DesktopClock/Utilities/TimeStringFormatter.cs

@@ -13,7 +13,6 @@ public static class TimeStringFormatter
         DateTime countdownTo,
         string format,
         string countdownFormat,
-        TextTransform textTransform,
         IFormatProvider formatProvider)
     {
         var timeInSelectedZone = TimeZoneInfo.ConvertTime(now, timeZone);
@@ -33,21 +32,6 @@ public static class TimeStringFormatter
             result = Tokenizer.FormatWithTokenizerOrFallBack(countdown, countdownFormat, formatProvider);
         }
 
-        return ApplyTransform(result, textTransform, formatProvider);
-    }
-
-    private static string ApplyTransform(string value, TextTransform textTransform, IFormatProvider formatProvider)
-    {
-        if (textTransform == TextTransform.None)
-            return value;
-
-        var culture = formatProvider as CultureInfo;
-
-        return textTransform switch
-        {
-            TextTransform.Uppercase => culture == null ? value.ToUpper() : value.ToUpper(culture),
-            TextTransform.Lowercase => culture == null ? value.ToLower() : value.ToLower(culture),
-            _ => value,
-        };
+        return result;
     }
 }