diff --git a/samples/Iconize.Sample.WPF/App.config b/samples/Iconize.Sample.WPF/App.config new file mode 100644 index 0000000..f8ea23e --- /dev/null +++ b/samples/Iconize.Sample.WPF/App.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/Iconize.Sample.WPF/App.xaml b/samples/Iconize.Sample.WPF/App.xaml new file mode 100644 index 0000000..207d41b --- /dev/null +++ b/samples/Iconize.Sample.WPF/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/samples/Iconize.Sample.WPF/App.xaml.cs b/samples/Iconize.Sample.WPF/App.xaml.cs new file mode 100644 index 0000000..caf4fbe --- /dev/null +++ b/samples/Iconize.Sample.WPF/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace Iconize.Sample.WPF +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/samples/Iconize.Sample.WPF/Iconize.Sample.WPF.csproj b/samples/Iconize.Sample.WPF/Iconize.Sample.WPF.csproj new file mode 100644 index 0000000..e0ef544 --- /dev/null +++ b/samples/Iconize.Sample.WPF/Iconize.Sample.WPF.csproj @@ -0,0 +1,126 @@ + + + + + Debug + AnyCPU + {BC80866B-FF73-4878-9544-F7C6851CB529} + WinExe + Iconize.Sample.WPF + Iconize.Sample.WPF + v4.7.2 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + true + + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + PublicResXFileCodeGenerator + Resources.Designer.cs + + + + + + + + + + + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + {37b28d65-4d60-4aa7-abf3-6b644c6fad0e} + Iconize.Sample + + + + + 3.5.0.169047 + + + 3.5.0.169047 + + + + \ No newline at end of file diff --git a/samples/Iconize.Sample.WPF/MainWindow.xaml b/samples/Iconize.Sample.WPF/MainWindow.xaml new file mode 100644 index 0000000..a80ffb2 --- /dev/null +++ b/samples/Iconize.Sample.WPF/MainWindow.xaml @@ -0,0 +1,14 @@ + + + + + diff --git a/samples/Iconize.Sample.WPF/MainWindow.xaml.cs b/samples/Iconize.Sample.WPF/MainWindow.xaml.cs new file mode 100644 index 0000000..4d4214a --- /dev/null +++ b/samples/Iconize.Sample.WPF/MainWindow.xaml.cs @@ -0,0 +1,21 @@ +using Xamarin.Forms; +using Xamarin.Forms.Platform.WPF; + +namespace Iconize.Sample.WPF +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : FormsApplicationPage + { + public MainWindow() + { + InitializeComponent(); + + Forms.Init(); + Plugin.Iconize.Iconize.Init(); + + LoadApplication(new Sample.App()); + } + } +} diff --git a/samples/Iconize.Sample.WPF/Properties/AssemblyInfo.cs b/samples/Iconize.Sample.WPF/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..21d95a5 --- /dev/null +++ b/samples/Iconize.Sample.WPF/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Iconize.Sample.WPF")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Iconize.Sample.WPF")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/samples/Iconize.Sample.WPF/Properties/Resources.Designer.cs b/samples/Iconize.Sample.WPF/Properties/Resources.Designer.cs new file mode 100644 index 0000000..31296de --- /dev/null +++ b/samples/Iconize.Sample.WPF/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Iconize.Sample.WPF.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Iconize.Sample.WPF.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/samples/Iconize.Sample.WPF/Properties/Resources.resx b/samples/Iconize.Sample.WPF/Properties/Resources.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/samples/Iconize.Sample.WPF/Properties/Resources.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/samples/Iconize.Sample.WPF/Properties/Settings.Designer.cs b/samples/Iconize.Sample.WPF/Properties/Settings.Designer.cs new file mode 100644 index 0000000..09252dd --- /dev/null +++ b/samples/Iconize.Sample.WPF/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Iconize.Sample.WPF.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/samples/Iconize.Sample.WPF/Properties/Settings.settings b/samples/Iconize.Sample.WPF/Properties/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/samples/Iconize.Sample.WPF/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/samples/Iconize.Sample.WPF/iconize-entypoplus.ttf b/samples/Iconize.Sample.WPF/iconize-entypoplus.ttf new file mode 100644 index 0000000..002e856 Binary files /dev/null and b/samples/Iconize.Sample.WPF/iconize-entypoplus.ttf differ diff --git a/samples/Iconize.Sample.WPF/iconize-fontawesome-brands.ttf b/samples/Iconize.Sample.WPF/iconize-fontawesome-brands.ttf new file mode 100644 index 0000000..5f72e91 Binary files /dev/null and b/samples/Iconize.Sample.WPF/iconize-fontawesome-brands.ttf differ diff --git a/samples/Iconize.Sample.WPF/iconize-fontawesome-regular.ttf b/samples/Iconize.Sample.WPF/iconize-fontawesome-regular.ttf new file mode 100644 index 0000000..a309313 Binary files /dev/null and b/samples/Iconize.Sample.WPF/iconize-fontawesome-regular.ttf differ diff --git a/samples/Iconize.Sample.WPF/iconize-fontawesome-solid.ttf b/samples/Iconize.Sample.WPF/iconize-fontawesome-solid.ttf new file mode 100644 index 0000000..7ece328 Binary files /dev/null and b/samples/Iconize.Sample.WPF/iconize-fontawesome-solid.ttf differ diff --git a/samples/Iconize.Sample.WPF/iconize-ionicons.ttf b/samples/Iconize.Sample.WPF/iconize-ionicons.ttf new file mode 100644 index 0000000..c4e4632 Binary files /dev/null and b/samples/Iconize.Sample.WPF/iconize-ionicons.ttf differ diff --git a/samples/Iconize.Sample.WPF/iconize-jam-icons.ttf b/samples/Iconize.Sample.WPF/iconize-jam-icons.ttf new file mode 100644 index 0000000..bf013e8 Binary files /dev/null and b/samples/Iconize.Sample.WPF/iconize-jam-icons.ttf differ diff --git a/samples/Iconize.Sample.WPF/iconize-material.ttf b/samples/Iconize.Sample.WPF/iconize-material.ttf new file mode 100644 index 0000000..7015564 Binary files /dev/null and b/samples/Iconize.Sample.WPF/iconize-material.ttf differ diff --git a/samples/Iconize.Sample.WPF/iconize-materialdesignicons.ttf b/samples/Iconize.Sample.WPF/iconize-materialdesignicons.ttf new file mode 100644 index 0000000..31a801b Binary files /dev/null and b/samples/Iconize.Sample.WPF/iconize-materialdesignicons.ttf differ diff --git a/samples/Iconize.Sample.WPF/iconize-meteocons.ttf b/samples/Iconize.Sample.WPF/iconize-meteocons.ttf new file mode 100644 index 0000000..98de682 Binary files /dev/null and b/samples/Iconize.Sample.WPF/iconize-meteocons.ttf differ diff --git a/samples/Iconize.Sample.WPF/iconize-simplelineicons.ttf b/samples/Iconize.Sample.WPF/iconize-simplelineicons.ttf new file mode 100644 index 0000000..6ecb686 Binary files /dev/null and b/samples/Iconize.Sample.WPF/iconize-simplelineicons.ttf differ diff --git a/samples/Iconize.Sample.WPF/iconize-typicons.ttf b/samples/Iconize.Sample.WPF/iconize-typicons.ttf new file mode 100644 index 0000000..f7df94b Binary files /dev/null and b/samples/Iconize.Sample.WPF/iconize-typicons.ttf differ diff --git a/samples/Iconize.Sample.WPF/iconize-weathericons.ttf b/samples/Iconize.Sample.WPF/iconize-weathericons.ttf new file mode 100644 index 0000000..948f0a5 Binary files /dev/null and b/samples/Iconize.Sample.WPF/iconize-weathericons.ttf differ diff --git a/samples/IconizeSamples.sln b/samples/IconizeSamples.sln index 8469ba7..57c4adf 100644 --- a/samples/IconizeSamples.sln +++ b/samples/IconizeSamples.sln @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Iconize.Sample.iOS", "Iconi EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Iconize.Sample.UWP", "Iconize.Sample.UWP\Iconize.Sample.UWP.csproj", "{F7A7B213-3304-4897-8465-906D114E9D9C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Iconize.Sample.WPF", "Iconize.Sample.WPF\Iconize.Sample.WPF.csproj", "{BC80866B-FF73-4878-9544-F7C6851CB529}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Ad-Hoc|Any CPU = Ad-Hoc|Any CPU @@ -213,8 +215,6 @@ Global {F7A7B213-3304-4897-8465-906D114E9D9C}.Debug|x64.Build.0 = Debug|x64 {F7A7B213-3304-4897-8465-906D114E9D9C}.Debug|x64.Deploy.0 = Debug|x64 {F7A7B213-3304-4897-8465-906D114E9D9C}.Debug|x86.ActiveCfg = Debug|x86 - {F7A7B213-3304-4897-8465-906D114E9D9C}.Debug|x86.Build.0 = Debug|x86 - {F7A7B213-3304-4897-8465-906D114E9D9C}.Debug|x86.Deploy.0 = Debug|x86 {F7A7B213-3304-4897-8465-906D114E9D9C}.Release|Any CPU.ActiveCfg = Release|x86 {F7A7B213-3304-4897-8465-906D114E9D9C}.Release|ARM.ActiveCfg = Release|ARM {F7A7B213-3304-4897-8465-906D114E9D9C}.Release|ARM.Build.0 = Release|ARM @@ -227,6 +227,53 @@ Global {F7A7B213-3304-4897-8465-906D114E9D9C}.Release|x86.ActiveCfg = Release|x86 {F7A7B213-3304-4897-8465-906D114E9D9C}.Release|x86.Build.0 = Release|x86 {F7A7B213-3304-4897-8465-906D114E9D9C}.Release|x86.Deploy.0 = Release|x86 + {BC80866B-FF73-4878-9544-F7C6851CB529}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Ad-Hoc|ARM.ActiveCfg = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Ad-Hoc|ARM.Build.0 = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Ad-Hoc|x64.ActiveCfg = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Ad-Hoc|x64.Build.0 = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Ad-Hoc|x86.ActiveCfg = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Ad-Hoc|x86.Build.0 = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.AppStore|Any CPU.ActiveCfg = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.AppStore|Any CPU.Build.0 = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.AppStore|ARM.ActiveCfg = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.AppStore|ARM.Build.0 = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.AppStore|iPhone.ActiveCfg = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.AppStore|iPhone.Build.0 = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.AppStore|x64.ActiveCfg = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.AppStore|x64.Build.0 = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.AppStore|x86.ActiveCfg = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.AppStore|x86.Build.0 = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Debug|ARM.ActiveCfg = Debug|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Debug|ARM.Build.0 = Debug|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Debug|iPhone.Build.0 = Debug|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Debug|x64.ActiveCfg = Debug|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Debug|x64.Build.0 = Debug|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Debug|x86.ActiveCfg = Debug|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Debug|x86.Build.0 = Debug|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Release|Any CPU.Build.0 = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Release|ARM.ActiveCfg = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Release|ARM.Build.0 = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Release|iPhone.ActiveCfg = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Release|iPhone.Build.0 = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Release|x64.ActiveCfg = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Release|x64.Build.0 = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Release|x86.ActiveCfg = Release|Any CPU + {BC80866B-FF73-4878-9544-F7C6851CB529}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Directory.Build.props b/src/Directory.Build.props index d68a7eb..1811b3d 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -4,7 +4,7 @@ - netstandard1.3;netstandard2.0;MonoAndroid90;Xamarin.iOS10;uap10.0.16299 + netstandard1.3;netstandard2.0;MonoAndroid90;Xamarin.iOS10;uap10.0.16299;net472 netstandard1.3;netstandard2.0;MonoAndroid90;Xamarin.iOS10;Xamarin.Mac20 diff --git a/src/Plugin.Iconize/Platform/WPF/PlatformExtensions.cs b/src/Plugin.Iconize/Platform/WPF/PlatformExtensions.cs new file mode 100644 index 0000000..ead8d2a --- /dev/null +++ b/src/Plugin.Iconize/Platform/WPF/PlatformExtensions.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Windows; +using System.Windows.Media; + +namespace Plugin.Iconize +{ + /// + /// Defines the . + /// + public static class PlatformExtensions + { + private static IDictionary FontCache { get; } = new Dictionary(); + + /// + /// To the font family. + /// + /// The module. + /// + public static FontFamily ToFontFamily(this IIconModule module) + { + var moduleType = module.GetType(); + if (!FontCache.ContainsKey(moduleType)) + { + FontCache.Add(moduleType, new FontFamily(new Uri("pack://application:,,,/"), $"/#{module.FontFamily}")); + } + return FontCache[moduleType]; + } + + /// + /// To the image source. + /// + /// The icon. + /// The size. + /// The color. + /// + public static ImageSource ToImageSource(this IIcon icon, Xamarin.Forms.Color color) + { + var character = $"{icon.Character}"; + var module = Iconize.FindModuleOf(icon); + + var typeface = new Typeface(new FontFamily(new Uri("pack://application:,,,/"), $"/#{module.FontFamily}"), FontStyles.Normal, FontWeights.Regular, FontStretches.Normal); + + if (!typeface.TryGetGlyphTypeface(out var glyphTypeface)) + throw new InvalidOperationException("No glyphtypeface found"); + + var glyphIndexes = new UInt16[character.Length]; + var advanceWidths = new Double[character.Length]; + for (int n = 0; n < character.Length; n++) + { + ushort glyphIndex = glyphTypeface.CharacterToGlyphMap[character[n]]; + glyphIndexes[n] = glyphIndex; + double width = glyphTypeface.AdvanceWidths[glyphIndex] * 1.0; + advanceWidths[n] = width; + } + + var gr = new GlyphRun(glyphTypeface, 0, false, 1.0, glyphIndexes, + new System.Windows.Point(0, 0), advanceWidths, + null, null, null, null, null, null); + + var glyphRunDrawing = new GlyphRunDrawing(new SolidColorBrush(ToUIColor(color)), gr); + return new DrawingImage(glyphRunDrawing); + } + + /// + /// To the color of the UI. + /// + /// The color. + /// + public static Color ToUIColor(this Xamarin.Forms.Color color) => Color.FromArgb((Byte)(color.A * Byte.MaxValue), (Byte)(color.R * Byte.MaxValue), (Byte)(color.G * Byte.MaxValue), (Byte)(color.B * Byte.MaxValue)); + } +} diff --git a/src/Plugin.Iconize/Platform/WPF/Renderers/IconButtonRenderer.cs b/src/Plugin.Iconize/Platform/WPF/Renderers/IconButtonRenderer.cs new file mode 100644 index 0000000..0253685 --- /dev/null +++ b/src/Plugin.Iconize/Platform/WPF/Renderers/IconButtonRenderer.cs @@ -0,0 +1,62 @@ +using System; +using System.ComponentModel; +using Plugin.Iconize; +using Xamarin.Forms; +using Xamarin.Forms.Platform.WPF; + +[assembly: ExportRenderer(typeof(IconButton), typeof(IconButtonRenderer))] + +namespace Plugin.Iconize +{ + public class IconButtonRenderer : ButtonRenderer + { + /// + /// Raises the event. + /// + /// The instance containing the event data. + protected override void OnElementChanged(ElementChangedEventArgs