Skip to content

Commit

Permalink
#7 Fix font size option
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreye committed Jan 6, 2019
1 parent 8f61fab commit 12f2e26
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 24 deletions.
41 changes: 22 additions & 19 deletions ILSpy.Core/Options/DisplaySettingsPanel.xaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:local="clr-namespace:ICSharpCode.ILSpy.Options"
x:Class="ICSharpCode.ILSpy.Options.DisplaySettingsPanel">
<Grid>
Expand Down Expand Up @@ -29,25 +30,27 @@
</DropDown>
<TextBlock Grid.Column="2" Margin="3,0">Size:</TextBlock>
<DropDown Grid.Column="3" SelectedItem="{Binding SelectedFontSize, Converter={x:Static local:FontSizeConverter.Instance}}" Margin="3,0">
<DropDownItem>6</DropDownItem>
<DropDownItem>7</DropDownItem>
<DropDownItem>8</DropDownItem>
<DropDownItem>9</DropDownItem>
<DropDownItem>10</DropDownItem>
<DropDownItem>11</DropDownItem>
<DropDownItem>12</DropDownItem>
<DropDownItem>13</DropDownItem>
<DropDownItem>14</DropDownItem>
<DropDownItem>15</DropDownItem>
<DropDownItem>16</DropDownItem>
<DropDownItem>17</DropDownItem>
<DropDownItem>18</DropDownItem>
<DropDownItem>19</DropDownItem>
<DropDownItem>20</DropDownItem>
<DropDownItem>21</DropDownItem>
<DropDownItem>22</DropDownItem>
<DropDownItem>23</DropDownItem>
<DropDownItem>24</DropDownItem>
<DropDown.Items>
<sys:Double>6</sys:Double>
<sys:Double>7</sys:Double>
<sys:Double>8</sys:Double>
<sys:Double>9</sys:Double>
<sys:Double>10</sys:Double>
<sys:Double>11</sys:Double>
<sys:Double>12</sys:Double>
<sys:Double>13</sys:Double>
<sys:Double>14</sys:Double>
<sys:Double>15</sys:Double>
<sys:Double>16</sys:Double>
<sys:Double>17</sys:Double>
<sys:Double>18</sys:Double>
<sys:Double>19</sys:Double>
<sys:Double>20</sys:Double>
<sys:Double>21</sys:Double>
<sys:Double>22</sys:Double>
<sys:Double>23</sys:Double>
<sys:Double>24</sys:Double>
</DropDown.Items>
</DropDown>
<Border Grid.Row="1" Grid.ColumnSpan="4" BorderBrush="{DynamicResource ThemeControlHighlightHighBrush}" BorderThickness="1" Margin="3,5">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="AaBbCcXxYyZz" FontFamily="{Binding SelectedFont}" FontSize="{Binding SelectedFontSize}" />
Expand Down
21 changes: 16 additions & 5 deletions ILSpy.Core/Options/DisplaySettingsPanel.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,29 @@ 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);
}

throw new NotImplementedException();
}

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;
Expand Down

0 comments on commit 12f2e26

Please sign in to comment.