diff options
author | Jason Smith <jason.smith@xamarin.com> | 2016-03-22 13:02:25 -0700 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-03-22 16:13:41 -0700 |
commit | 17fdde66d94155fc62a034fa6658995bef6fd6e5 (patch) | |
tree | b5e5073a2a7b15cdbe826faa5c763e270a505729 /Xamarin.Forms.Platform.WP8/ResourcesProvider.cs | |
download | xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.gz xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.bz2 xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.zip |
Initial import
Diffstat (limited to 'Xamarin.Forms.Platform.WP8/ResourcesProvider.cs')
-rw-r--r-- | Xamarin.Forms.Platform.WP8/ResourcesProvider.cs | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.WP8/ResourcesProvider.cs b/Xamarin.Forms.Platform.WP8/ResourcesProvider.cs new file mode 100644 index 00000000..3eaf2a1f --- /dev/null +++ b/Xamarin.Forms.Platform.WP8/ResourcesProvider.cs @@ -0,0 +1,59 @@ +using System.Windows.Controls; + +namespace Xamarin.Forms.Platform.WinPhone +{ + internal class ResourcesProvider : ISystemResourcesProvider + { + ResourceDictionary _dictionary; + + public IResourceDictionary GetSystemResources() + { + _dictionary = new ResourceDictionary(); + + UpdateStyles(); + + return _dictionary; + } + + Style GetListItemDetailTextStyle() + { + var result = new Style(typeof(Label)); + + result.Setters.Add(new Setter { Property = Label.FontSizeProperty, Value = 32 }); + + return result; + } + + Style GetListItemTextStyle() + { + var result = new Style(typeof(Label)); + + result.Setters.Add(new Setter { Property = Label.FontSizeProperty, Value = 48 }); + + return result; + } + + Style GetStyle(System.Windows.Style style, TextBlock hackbox) + { + hackbox.Style = style; + + var result = new Style(typeof(Label)); + result.Setters.Add(new Setter { Property = Label.FontFamilyProperty, Value = hackbox.FontFamily }); + + result.Setters.Add(new Setter { Property = Label.FontSizeProperty, Value = hackbox.FontSize }); + + return result; + } + + void UpdateStyles() + { + var textBlock = new TextBlock(); + _dictionary[Device.Styles.TitleStyleKey] = GetStyle((System.Windows.Style)System.Windows.Application.Current.Resources["PhoneTextTitle1Style"], textBlock); + _dictionary[Device.Styles.SubtitleStyleKey] = GetStyle((System.Windows.Style)System.Windows.Application.Current.Resources["PhoneTextTitle2Style"], textBlock); + _dictionary[Device.Styles.BodyStyleKey] = GetStyle((System.Windows.Style)System.Windows.Application.Current.Resources["PhoneTextNormalStyle"], textBlock); + _dictionary[Device.Styles.CaptionStyleKey] = GetStyle((System.Windows.Style)System.Windows.Application.Current.Resources["PhoneTextSmallStyle"], textBlock); + _dictionary[Device.Styles.ListItemTextStyleKey] = GetListItemTextStyle(); + _dictionary[Device.Styles.ListItemDetailTextStyleKey] = GetListItemDetailTextStyle(); + } + } +}
\ No newline at end of file |