diff options
| author | LukePulverenti <luke.pulverenti@gmail.com> | 2013-02-20 20:33:05 -0500 |
|---|---|---|
| committer | LukePulverenti <luke.pulverenti@gmail.com> | 2013-02-20 20:33:05 -0500 |
| commit | 767cdc1f6f6a63ce997fc9476911e2c361f9d402 (patch) | |
| tree | 49add55976f895441167c66cfa95e5c7688d18ce /MediaBrowser.Plugins.DefaultTheme/DisplayPreferences/SortMenuPage.xaml.cs | |
| parent | 845554722efaed872948a9e0f7202e3ef52f1b6e (diff) | |
Pushing missing changes
Diffstat (limited to 'MediaBrowser.Plugins.DefaultTheme/DisplayPreferences/SortMenuPage.xaml.cs')
| -rw-r--r-- | MediaBrowser.Plugins.DefaultTheme/DisplayPreferences/SortMenuPage.xaml.cs | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/MediaBrowser.Plugins.DefaultTheme/DisplayPreferences/SortMenuPage.xaml.cs b/MediaBrowser.Plugins.DefaultTheme/DisplayPreferences/SortMenuPage.xaml.cs new file mode 100644 index 000000000..6d6068d16 --- /dev/null +++ b/MediaBrowser.Plugins.DefaultTheme/DisplayPreferences/SortMenuPage.xaml.cs @@ -0,0 +1,95 @@ +using MediaBrowser.Model.Net; +using MediaBrowser.UI; +using MediaBrowser.UI.Controls; +using System; +using System.Windows; +using System.Windows.Controls; + +namespace MediaBrowser.Plugins.DefaultTheme.DisplayPreferences +{ + /// <summary> + /// Interaction logic for SortMenuPage.xaml + /// </summary> + public partial class SortMenuPage : BaseDisplayPreferencesPage + { + /// <summary> + /// Initializes a new instance of the <see cref="SortMenuPage" /> class. + /// </summary> + public SortMenuPage() + { + InitializeComponent(); + + chkRemember.Click += chkRemember_Click; + } + + /// <summary> + /// Handles the Click event of the chkRemember control. + /// </summary> + /// <param name="sender">The source of the event.</param> + /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param> + async void chkRemember_Click(object sender, RoutedEventArgs e) + { + try + { + await MainPage.UpdateRememberSort(chkRemember.IsChecked.HasValue && chkRemember.IsChecked.Value); + } + catch (HttpException) + { + App.Instance.ShowDefaultErrorMessage(); + } + } + + /// <summary> + /// Called when [loaded]. + /// </summary> + protected override void OnLoaded() + { + chkRemember.IsChecked = MainPage.DisplayPreferences.RememberSorting; + + var index = 0; + + var currentValue = MainPage.SortBy ?? string.Empty; + + foreach (var option in MainPage.Folder.SortOptions) + { + var radio = new ExtendedRadioButton { GroupName = "Options" }; + + radio.SetResourceReference(StyleProperty, "ViewMenuRadioButton"); + + var textblock = new TextBlock { Text = option }; + + textblock.SetResourceReference(StyleProperty, "TextBlockStyle"); + + radio.Content = textblock; + + if (string.IsNullOrEmpty(MainPage.DisplayPreferences.SortBy)) + { + radio.IsChecked = index == 0; + } + else + { + radio.IsChecked = currentValue.Equals(option, StringComparison.OrdinalIgnoreCase); + } + + radio.Tag = option; + radio.Click += radio_Click; + + pnlOptions.Children.Add(radio); + + index++; + } + + base.OnLoaded(); + } + + /// <summary> + /// Handles the Click event of the radio control. + /// </summary> + /// <param name="sender">The source of the event.</param> + /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param> + async void radio_Click(object sender, RoutedEventArgs e) + { + await MainPage.UpdateSortOption((sender as RadioButton).Tag.ToString()); + } + } +} |
