/// <summary> /// Handles the Unchecked event of the LanguageMenuItem control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void LanguageMenuItemUnchecked(object sender, RoutedEventArgs e) { if (ActiveLangs.Contains((sender as MenuItem).Tag as string)) { ActiveLangs.Remove((sender as MenuItem).Tag as string); Settings.Set("Active Subtitle Languages", ActiveLangs); } }
/// <summary> /// Handles the Loaded event of the UserControl control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void UserControlLoaded(object sender, RoutedEventArgs e) { if (SubtitlesListViewItemCollection == null) { SubtitlesListViewItemCollection = new ObservableCollection <SubtitleItem>(); listView.ItemsSource = SubtitlesListViewItemCollection; appendLanguage.IsChecked = Settings.Get <bool>("Append Language to Subtitle"); } LoadEngines(); if (languages.Items.Count == 0) { foreach (var lang in Languages.List) { var mi = new MenuItem { Header = new StackPanel { Orientation = Orientation.Horizontal }, IsCheckable = true, IsChecked = ActiveLangs.Contains(lang.Key), StaysOpenOnClick = true, Tag = lang.Key }; (mi.Header as StackPanel).Children.Add(new Image { Source = new BitmapImage(new Uri("/RSTVShowTracker;component/Images/flag-" + lang.Key + ".png", UriKind.Relative)), Width = 16, Height = 16, Margin = new Thickness(3, -2, 0, 0) }); (mi.Header as StackPanel).Children.Add(new Label { Content = lang.Value, Padding = new Thickness(5, 0, 0, 0) }); mi.Checked += LanguageMenuItemChecked; mi.Unchecked += LanguageMenuItemUnchecked; languages.Items.Add(mi); } var mi2 = new MenuItem { Header = new StackPanel { Orientation = Orientation.Horizontal }, IsCheckable = true, IsChecked = ActiveLangs.Contains("null"), StaysOpenOnClick = true, Tag = "null" }; (mi2.Header as StackPanel).Children.Add(new Image { Source = new BitmapImage(new Uri("/RSTVShowTracker;component/Images/unknown.png", UriKind.Relative)), Width = 16, Height = 16, Margin = new Thickness(3, -2, 0, 0) }); (mi2.Header as StackPanel).Children.Add(new Label { Content = "Unknown", Padding = new Thickness(5, 0, 0, 0) }); mi2.Checked += LanguageMenuItemChecked; mi2.Unchecked += LanguageMenuItemUnchecked; languages.Items.Add(mi2); } }