Skip to content

Commit

Permalink
Replace EnumToIntConverter with a dumber variant that doesn't set .NE…
Browse files Browse the repository at this point in the history
…T Native on fire

god
  • Loading branch information
Difegue committed Sep 10, 2022
1 parent b601738 commit 36bd660
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 221 deletions.
45 changes: 0 additions & 45 deletions Sources/Stylophone.Localization/Strings/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 0 additions & 20 deletions Sources/Stylophone.Localization/Strings/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -183,26 +183,6 @@
<data name="OKButtonText" xml:space="preserve">
<value>OK</value>
</data>
<data name="ExceptionSettingsStorageExtensionsFileNameIsNullOrEmpty" xml:space="preserve">
<value>File name is null or empty. Specify a valid file name</value>
<comment>File name is null or empty to save file in settings storage extensions</comment>
</data>
<data name="ExceptionEnumToBooleanConverterValueMustBeAnEnum" xml:space="preserve">
<value>value must be an Enum!</value>
<comment>Value must be an Enum in enum to boolean converter</comment>
</data>
<data name="ExceptionEnumToBooleanConverterParameterMustBeAnEnumName" xml:space="preserve">
<value>parameter must be an Enum name!</value>
<comment>Parameter must be an Enum name in enum to boolean converter</comment>
</data>
<data name="ExceptionViewLifeTimeControlViewDisposal" xml:space="preserve">
<value>This view is being disposed.</value>
<comment>View disposed</comment>
</data>
<data name="ExceptionViewLifeTimeControlMissingReleasedSubscription" xml:space="preserve">
<value>All pages opened in a new window must subscribe to the Released Event.</value>
<comment>The page is not subscribed to the Released event.</comment>
</data>
<data name="NotificationAddedToPlaylist" xml:space="preserve">
<value>Added to Playlist {0}!</value>
</data>
Expand Down
20 changes: 0 additions & 20 deletions Sources/Stylophone.Localization/Strings/Resources.fr-FR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -129,26 +129,6 @@
<value>Bibliothèque</value>
<comment>Navigation view item name for Library</comment>
</data>
<data name="ExceptionSettingsStorageExtensionsFileNameIsNullOrEmpty" xml:space="preserve">
<value>File name is null or empty. Specify a valid file name</value>
<comment>File name is null or empty to save file in settings storage extensions</comment>
</data>
<data name="ExceptionEnumToBooleanConverterValueMustBeAnEnum" xml:space="preserve">
<value>value must be an Enum!</value>
<comment>Value must be an Enum in enum to boolean converter</comment>
</data>
<data name="ExceptionEnumToBooleanConverterParameterMustBeAnEnumName" xml:space="preserve">
<value>parameter must be an Enum name!</value>
<comment>Parameter must be an Enum name in enum to boolean converter</comment>
</data>
<data name="ExceptionViewLifeTimeControlViewDisposal" xml:space="preserve">
<value>This view is being disposed.</value>
<comment>View disposed</comment>
</data>
<data name="ExceptionViewLifeTimeControlMissingReleasedSubscription" xml:space="preserve">
<value>All pages opened in a new window must subscribe to the Released Event.</value>
<comment>The page is not subscribed to the Released event.</comment>
</data>
<data name="NotificationAddedToPlaylist" xml:space="preserve">
<value>Ajouté à la Playlist {0} !</value>
</data>
Expand Down
20 changes: 0 additions & 20 deletions Sources/Stylophone.Localization/Strings/Resources.pt-PT.resx
Original file line number Diff line number Diff line change
Expand Up @@ -182,26 +182,6 @@
<data name="OKButtonText" xml:space="preserve">
<value>OK</value>
</data>
<data name="ExceptionSettingsStorageExtensionsFileNameIsNullOrEmpty" xml:space="preserve">
<value>File name is null or empty. Specify a valid file name</value>
<comment>File name is null or empty to save file in settings storage extensions</comment>
</data>
<data name="ExceptionEnumToBooleanConverterValueMustBeAnEnum" xml:space="preserve">
<value>value must be an Enum!</value>
<comment>Value must be an Enum in enum to boolean converter</comment>
</data>
<data name="ExceptionEnumToBooleanConverterParameterMustBeAnEnumName" xml:space="preserve">
<value>parameter must be an Enum name!</value>
<comment>Parameter must be an Enum name in enum to boolean converter</comment>
</data>
<data name="ExceptionViewLifeTimeControlViewDisposal" xml:space="preserve">
<value>This view is being disposed.</value>
<comment>View disposed</comment>
</data>
<data name="ExceptionViewLifeTimeControlMissingReleasedSubscription" xml:space="preserve">
<value>All pages opened in a new window must subscribe to the Released Event.</value>
<comment>The page is not subscribed to the Released event.</comment>
</data>
<data name="NotificationAddedToPlaylist" xml:space="preserve">
<value>Adicionado na Lista de reprodução {0}!</value>
</data>
Expand Down
20 changes: 0 additions & 20 deletions Sources/Stylophone.Localization/Strings/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -183,26 +183,6 @@
<data name="OKButtonText" xml:space="preserve">
<value>OK</value>
</data>
<data name="ExceptionSettingsStorageExtensionsFileNameIsNullOrEmpty" xml:space="preserve">
<value>File name is null or empty. Specify a valid file name</value>
<comment>File name is null or empty to save file in settings storage extensions</comment>
</data>
<data name="ExceptionEnumToBooleanConverterValueMustBeAnEnum" xml:space="preserve">
<value>value must be an Enum!</value>
<comment>Value must be an Enum in enum to boolean converter</comment>
</data>
<data name="ExceptionEnumToBooleanConverterParameterMustBeAnEnumName" xml:space="preserve">
<value>parameter must be an Enum name!</value>
<comment>Parameter must be an Enum name in enum to boolean converter</comment>
</data>
<data name="ExceptionViewLifeTimeControlViewDisposal" xml:space="preserve">
<value>This view is being disposed.</value>
<comment>View disposed</comment>
</data>
<data name="ExceptionViewLifeTimeControlMissingReleasedSubscription" xml:space="preserve">
<value>All pages opened in a new window must subscribe to the Released Event.</value>
<comment>The page is not subscribed to the Released event.</comment>
</data>
<data name="NotificationAddedToPlaylist" xml:space="preserve">
<value>Added to Playlist {0}!</value>
</data>
Expand Down
20 changes: 0 additions & 20 deletions Sources/Stylophone.Localization/Strings/Resources.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -183,26 +183,6 @@
<data name="OKButtonText" xml:space="preserve">
<value>好</value>
</data>
<data name="ExceptionSettingsStorageExtensionsFileNameIsNullOrEmpty" xml:space="preserve">
<value>文件名为空。请指定有效文件名。</value>
<comment>File name is null or empty to save file in settings storage extensions</comment>
</data>
<data name="ExceptionEnumToBooleanConverterValueMustBeAnEnum" xml:space="preserve">
<value>值必须为枚举类型。</value>
<comment>Value must be an Enum in enum to boolean converter</comment>
</data>
<data name="ExceptionEnumToBooleanConverterParameterMustBeAnEnumName" xml:space="preserve">
<value>参数必须为枚举类型。</value>
<comment>Parameter must be an Enum name in enum to boolean converter</comment>
</data>
<data name="ExceptionViewLifeTimeControlViewDisposal" xml:space="preserve">
<value>该视图已被释放。</value>
<comment>View disposed</comment>
</data>
<data name="ExceptionViewLifeTimeControlMissingReleasedSubscription" xml:space="preserve">
<value>所有在新窗口打开的页面必须订阅 Released 事件。</value>
<comment>The page is not subscribed to the Released event.</comment>
</data>
<data name="NotificationAddedToPlaylist" xml:space="preserve">
<value>已添加到播放列表“{0}”。</value>
</data>
Expand Down
68 changes: 0 additions & 68 deletions Sources/Stylophone/Converters/EnumConverters.cs

This file was deleted.

32 changes: 32 additions & 0 deletions Sources/Stylophone/Converters/ThemeToIntConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Stylophone.Common.Interfaces;
using Stylophone.Localization.Strings;
using System;

using Windows.UI.Xaml.Data;

namespace Stylophone.Helpers
{
public class ThemeToIntConverter : IValueConverter
{

public object Convert(object value, Type targetType, object parameter, string language)
{

if (value is Theme t)
return (int)t;

throw new ArgumentException("Not a Theme");
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
if (value is int enumInt)
{
// Cast enumInt to EnumType
return Enum.ToObject(typeof(Theme), enumInt);
}

throw new ArgumentException("Not an int");
}
}
}
4 changes: 2 additions & 2 deletions Sources/Stylophone/Stylophone.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<AppxBundle>Always</AppxBundle>
<AppxBundlePlatforms>x86|x64|arm</AppxBundlePlatforms>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
<PackageCertificateThumbprint>187A5D2AFF2CB3A375B862E45117B9B7DF13CACF</PackageCertificateThumbprint>
<PackageCertificateThumbprint>AC6B4D78B6FC1C9719183572B36F08C049AFFB1E</PackageCertificateThumbprint>
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
<!-- Workaround to prevent resource.pri exploding for other languages with LibVLC installed -->
<AppxBundleAutoResourcePackageQualifiers>DXFeatureLevel</AppxBundleAutoResourcePackageQualifiers>
Expand Down Expand Up @@ -205,7 +205,7 @@
<Compile Include="Converters\DoubleToThicknessConverter.cs" />
<Compile Include="Converters\SkiaConverters.cs" />
<Compile Include="Converters\SecondsToTimeConverter.cs" />
<Compile Include="Converters\EnumConverters.cs" />
<Compile Include="Converters\ThemeToIntConverter.cs" />
<Compile Include="Helpers\LiveTileHelper.cs" />
<Compile Include="Helpers\UWPHelpers.cs" />
<Compile Include="Helpers\NavHelper.cs" />
Expand Down
11 changes: 5 additions & 6 deletions Sources/Stylophone/Views/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
xmlns:controls="using:Microsoft.UI.Xaml.Controls"
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:helper="using:Stylophone.Helpers"
xmlns:local="using:Stylophone.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:strings="using:Stylophone.Localization.Strings"
xmlns:stylophone="using:Stylophone.Common.Interfaces"
xmlns:helpers="using:Stylophone.Helpers"
mc:Ignorable="d">
<Page.Resources>
<helper:EnumToBooleanConverter x:Key="EnumToBooleanConverter" EnumType="stylophone:Theme" />
<helper:EnumToIntConverter x:Key="EnumToIntConverter" EnumType="stylophone:Theme" />

<helpers:ThemeToIntConverter x:Key="ThemeToIntConverter"/>

<converters:BoolToObjectConverter x:Key="IconConverter">
<converters:BoolToObjectConverter.TrueValue>
<FontIcon Foreground="{StaticResource AccentFillColorDefaultBrush}" Glyph="&#xE953;" />
Expand Down Expand Up @@ -174,7 +173,7 @@
</local:SettingsBlockControl.Icon>

<local:SettingsBlockControl.SettingsActionableElement>
<ComboBox SelectedIndex="{x:Bind ViewModel.ElementTheme, Converter={StaticResource EnumToIntConverter}, Mode=TwoWay}">
<ComboBox SelectedIndex="{x:Bind ViewModel.ElementTheme, Converter={StaticResource ThemeToIntConverter}, Mode=TwoWay}">
<ComboBoxItem Content="{x:Bind strings:Resources.SettingsThemeDefault}"/>
<ComboBoxItem Content="{x:Bind strings:Resources.SettingsThemeLight}"/>
<ComboBoxItem Content="{x:Bind strings:Resources.SettingsThemeDark}"/>
Expand Down

0 comments on commit 36bd660

Please sign in to comment.