summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WP8/ResourcesProvider.cs
diff options
context:
space:
mode:
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 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