Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
rampaa committed Oct 12, 2023
1 parent bcf0729 commit 2741027
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
16 changes: 2 additions & 14 deletions JL.Windows/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,6 @@ namespace JL.Windows;
internal static class ConfigManager
{
#region General

private static readonly ComboBoxItem[] s_japaneseFonts =
WindowsUtils.FindJapaneseFonts().OrderBy(static f => f.Foreground == Brushes.DimGray).ThenBy(static font => font.Content)
.ToArray();

private static readonly ComboBoxItem[] s_popupJapaneseFonts =
Array.ConvertAll(s_japaneseFonts, static f => new ComboBoxItem
{
Content = f.Content,
FontFamily = f.FontFamily,
Foreground = f.Foreground
});

public static bool InactiveLookupMode { get; set; } = false;
public static Brush HighlightColor { get; private set; } = Brushes.AliceBlue;
public static bool RequireLookupKeyPress { get; private set; } = false;
Expand Down Expand Up @@ -186,9 +173,10 @@ internal static class ConfigManager
#endregion

public static ExeConfigurationFileMap MappedExeConfiguration { get; set; } = new();
private static readonly ComboBoxItem[] s_japaneseFonts = WindowsUtils.FindJapaneseFonts();
private static readonly ComboBoxItem[] s_popupJapaneseFonts = WindowsUtils.CloneJapaneseFontComboBoxItems(s_japaneseFonts);
private static SkinType s_theme = SkinType.Dark;


public static void ApplyPreferences()
{
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(MappedExeConfiguration, ConfigurationUserLevel.None);
Expand Down
33 changes: 29 additions & 4 deletions JL.Windows/Utilities/WindowsUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ internal static class WindowsUtils
public static double DpiAwareFixedPopupXPosition { get; set; } = ConfigManager.FixedPopupXPosition / Dpi.DpiScaleX;
public static double DpiAwareFixedPopupYPosition { get; set; } = ConfigManager.FixedPopupYPosition / Dpi.DpiScaleY;

public static List<ComboBoxItem> FindJapaneseFonts()
public static ComboBoxItem[] FindJapaneseFonts()
{
List<ComboBoxItem> japaneseFonts = new();

Expand Down Expand Up @@ -88,18 +88,43 @@ public static List<ComboBoxItem> FindJapaneseFonts()

if (!foundGlyph)
{
comboBoxItem.Foreground = Brushes.DimGray;
comboBoxItem.Foreground = Brushes.LightSlateGray;
japaneseFonts.Add(comboBoxItem);
}
}
else
{
comboBoxItem.Foreground = Brushes.DimGray;
comboBoxItem.Foreground = Brushes.LightSlateGray;
japaneseFonts.Add(comboBoxItem);
}
}

return japaneseFonts;
return japaneseFonts
.OrderBy(static f => f.Foreground == Brushes.LightSlateGray)
.ThenBy(static font => font.Content)
.ToArray();
}

public static ComboBoxItem[] CloneJapaneseFontComboBoxItems(ComboBoxItem[] japaneseFontsComboBoxItems)
{
ComboBoxItem[] clone = new ComboBoxItem[japaneseFontsComboBoxItems.Length];
for (int i = 0; i < japaneseFontsComboBoxItems.Length; i++)
{
ComboBoxItem comboBoxItem = japaneseFontsComboBoxItems[i];

clone[i] = new ComboBoxItem()
{
Content = comboBoxItem.FontFamily.Source,
FontFamily = comboBoxItem.FontFamily
};

if (comboBoxItem.Foreground == Brushes.LightSlateGray)
{
clone[i].Foreground = Brushes.LightSlateGray;
}
}

return clone;
}

public static void ShowAddNameWindow(string? selectedText, string reading = "")
Expand Down

0 comments on commit 2741027

Please sign in to comment.