summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WP8/ResourcesProvider.cs
diff options
context:
space:
mode:
authorJason Smith <jason.smith@xamarin.com>2016-03-22 20:02:25 (GMT)
committerJason Smith <jason.smith@xamarin.com>2016-03-22 23:13:41 (GMT)
commit17fdde66d94155fc62a034fa6658995bef6fd6e5 (patch)
treeb5e5073a2a7b15cdbe826faa5c763e270a505729 /Xamarin.Forms.Platform.WP8/ResourcesProvider.cs
downloadxamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.zip
xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.gz
xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.bz2
Initial import
Diffstat (limited to 'Xamarin.Forms.Platform.WP8/ResourcesProvider.cs')
-rw-r--r--Xamarin.Forms.Platform.WP8/ResourcesProvider.cs59
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 0000000..3eaf2a1
--- /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