From 12f2e26cfe0a0e690bf9faaf878c228a16e3264f Mon Sep 17 00:00:00 2001 From: Jeffrey Ye Date: Sun, 6 Jan 2019 09:36:47 -0800 Subject: [PATCH] #7 Fix font size option --- ILSpy.Core/Options/DisplaySettingsPanel.xaml | 41 ++++++++++--------- .../Options/DisplaySettingsPanel.xaml.cs | 21 +++++++--- 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/ILSpy.Core/Options/DisplaySettingsPanel.xaml b/ILSpy.Core/Options/DisplaySettingsPanel.xaml index d60df93..3fb4ed4 100644 --- a/ILSpy.Core/Options/DisplaySettingsPanel.xaml +++ b/ILSpy.Core/Options/DisplaySettingsPanel.xaml @@ -1,5 +1,6 @@  @@ -29,25 +30,27 @@ Size: - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 24 + + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + diff --git a/ILSpy.Core/Options/DisplaySettingsPanel.xaml.cs b/ILSpy.Core/Options/DisplaySettingsPanel.xaml.cs index a108897..fd27928 100644 --- a/ILSpy.Core/Options/DisplaySettingsPanel.xaml.cs +++ b/ILSpy.Core/Options/DisplaySettingsPanel.xaml.cs @@ -155,8 +155,12 @@ public class FontSizeConverter : IValueConverter public static readonly FontSizeConverter Instance = new FontSizeConverter(); public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) - { - if (value is double d) { + { + if (value == null) { + return 11.0; + } + + if (value is double d) { return Math.Round(d / 4 * 3); } @@ -164,9 +168,16 @@ public object Convert(object value, Type targetType, object parameter, System.Gl } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) - { - if (value is string s) - { + { + if (value == null) { + return 11.0 * 4 / 3; + } + + if (value is double dd) { + return dd * 4 / 3; + } + + if (value is string s) { if (double.TryParse(s, out double d)) return d * 4 / 3; return 11.0 * 4 / 3;