Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using CustomDatePicker.Classes;
- using Microsoft.Phone.Controls;
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Windows;
- namespace CustomDatePicker.View
- {
- public partial class MonthYearPicker : DateTimePickerPageBase
- {
- public MonthYearPicker()
- {
- InitializeComponent();
- // Hook up the data sources
- PrimarySelector.DataSource = new YearDataSource();
- SecondarySelector.DataSource = new MonthDataSource();
- InitializeDateTimePickerPage(PrimarySelector, SecondarySelector);
- }
- protected override IEnumerable<Microsoft.Phone.Controls.Primitives.LoopingSelector> GetSelectorsOrderedByCulturePattern()
- {
- string pattern = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern.ToUpperInvariant();
- if (DateShouldFlowRTL())
- {
- char[] reversedPattern = pattern.ToCharArray();
- Array.Reverse(reversedPattern);
- pattern = new string(reversedPattern);
- }
- return GetSelectorsOrderedByCulturePattern(
- pattern,
- new char[] { 'Y', 'M' },
- new Microsoft.Phone.Controls.Primitives.LoopingSelector[] { PrimarySelector, SecondarySelector });
- }
- private bool DateShouldFlowRTL()
- {
- string lang = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
- return lang == "ar" || lang == "fa";
- }
- internal override void SetFlowDirection(System.Windows.FlowDirection flowDirection)
- {
- HeaderTitle.FlowDirection = flowDirection;
- PrimarySelector.FlowDirection = flowDirection;
- SecondarySelector.FlowDirection = flowDirection;
- }
- protected override void OnOrientationChanged(OrientationChangedEventArgs e)
- {
- if (null == e)
- {
- throw new ArgumentNullException("e");
- }
- base.OnOrientationChanged(e);
- SystemTrayPlaceholder.Visibility = (0 != (PageOrientation.Portrait & e.Orientation)) ?
- Visibility.Visible :
- Visibility.Collapsed;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement