Advertisement
Guest User

MonthYearPicker.xaml.cs

a guest
Jan 2nd, 2014
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.26 KB | None | 0 0
  1. using CustomDatePicker.Classes;
  2. using Microsoft.Phone.Controls;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Globalization;
  6. using System.Windows;
  7.  
  8. namespace CustomDatePicker.View
  9. {
  10.     public partial class MonthYearPicker : DateTimePickerPageBase
  11.     {
  12.         public MonthYearPicker()
  13.         {
  14.             InitializeComponent();
  15.  
  16.             // Hook up the data sources
  17.             PrimarySelector.DataSource = new YearDataSource();
  18.             SecondarySelector.DataSource = new MonthDataSource();
  19.  
  20.             InitializeDateTimePickerPage(PrimarySelector, SecondarySelector);
  21.         }
  22.  
  23.         protected override IEnumerable<Microsoft.Phone.Controls.Primitives.LoopingSelector> GetSelectorsOrderedByCulturePattern()
  24.         {
  25.             string pattern = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern.ToUpperInvariant();
  26.  
  27.             if (DateShouldFlowRTL())
  28.             {
  29.                 char[] reversedPattern = pattern.ToCharArray();
  30.                 Array.Reverse(reversedPattern);
  31.                 pattern = new string(reversedPattern);
  32.             }
  33.  
  34.             return GetSelectorsOrderedByCulturePattern(
  35.                 pattern,
  36.                 new char[] { 'Y', 'M' },
  37.                 new Microsoft.Phone.Controls.Primitives.LoopingSelector[] { PrimarySelector, SecondarySelector });
  38.         }
  39.  
  40.         private bool DateShouldFlowRTL()
  41.         {
  42.             string lang = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
  43.             return lang == "ar" || lang == "fa";
  44.         }
  45.  
  46.         internal override void SetFlowDirection(System.Windows.FlowDirection flowDirection)
  47.         {
  48.             HeaderTitle.FlowDirection = flowDirection;
  49.  
  50.             PrimarySelector.FlowDirection = flowDirection;
  51.             SecondarySelector.FlowDirection = flowDirection;
  52.         }
  53.  
  54.         protected override void OnOrientationChanged(OrientationChangedEventArgs e)
  55.         {
  56.             if (null == e)
  57.             {
  58.                 throw new ArgumentNullException("e");
  59.             }
  60.  
  61.             base.OnOrientationChanged(e);
  62.             SystemTrayPlaceholder.Visibility = (0 != (PageOrientation.Portrait & e.Orientation)) ?
  63.                 Visibility.Visible :
  64.                 Visibility.Collapsed;
  65.         }
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement