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 { /// /// Interaction logic for IndexMenuPage.xaml /// public partial class IndexMenuPage : BaseDisplayPreferencesPage { /// /// Initializes a new instance of the class. /// public IndexMenuPage() { InitializeComponent(); chkRememberIndex.Click += chkRememberIndex_Click; } /// /// Handles the Click event of the chkRememberIndex control. /// /// The source of the event. /// The instance containing the event data. async void chkRememberIndex_Click(object sender, RoutedEventArgs e) { try { await MainPage.UpdateRememberIndex(chkRememberIndex.IsChecked.HasValue && chkRememberIndex.IsChecked.Value); } catch (HttpException) { App.Instance.ShowDefaultErrorMessage(); } } /// /// Called when [loaded]. /// protected override void OnLoaded() { chkRememberIndex.IsChecked = MainPage.DisplayPreferences.RememberIndexing; var index = 0; var currentValue = MainPage.IndexBy ?? string.Empty; foreach (var option in MainPage.Folder.IndexOptions) { 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.IndexBy)) { 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(); } /// /// Handles the Click event of the radio control. /// /// The source of the event. /// The instance containing the event data. async void radio_Click(object sender, RoutedEventArgs e) { await MainPage.UpdateIndexOption((sender as RadioButton).Tag.ToString()); } } }