/// <summary> /// Invoked when a property of the settings manager changes /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event data</param> private void SettingsManager_PropertyChanged(object sender, PropertyChangedWithValuesEventArgs e) { Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { switch (e.PropertyName) { case "SourceListConfig": SourceList.Config = SettingsManager.SourceListConfig; break; case "MinimizeToTray": Console.WriteLine("M2T changed to: " + SettingsManager.MinimizeToTray); PrefMin2Tray.IsChecked = SettingsManager.MinimizeToTray; break; case "ShowOSD": PrefOSD.IsChecked = SettingsManager.ShowOSD; break; case "OpenAddPolicy": OpenFileAddDescriptionConverter aconv = new OpenFileAddDescriptionConverter(); string apolicy = (string)aconv.Convert(SettingsManager.OpenAddPolicy, null, null, null); foreach (ComboBoxItem cbi in AddPolicyCombo.Items) { if ((string)cbi.Content == apolicy) { AddPolicyCombo.SelectedItem = cbi; break; } } break; case "OpenPlayPolicy": OpenFilePlayDescriptionConverter pconv = new OpenFilePlayDescriptionConverter(); string ppolicy = (string)pconv.Convert(SettingsManager.OpenPlayPolicy, null, null, null); foreach (ComboBoxItem cbi in PlayPolicyCombo.Items) { if ((string)cbi.Content == ppolicy) { PlayPolicyCombo.SelectedItem = cbi; break; } } break; case "SearchPolicy": SearchPolicyDescriptionConverter sconv = new SearchPolicyDescriptionConverter(); string spolicy = (string)sconv.Convert(SettingsManager.SearchPolicy, null, null, null); foreach (ComboBoxItem cbi in SearchPolicyCombo.Items) { if ((string)cbi.Content == spolicy) { SearchPolicyCombo.SelectedItem = cbi; break; } } break; case "UpgradePolicy": UpgradePolicyDescriptionConverter uconv = new UpgradePolicyDescriptionConverter(); string upolicy = (string)uconv.Convert(SettingsManager.UpgradePolicy, null, null, null); foreach (ComboBoxItem cbi in UpgradePolicyCombo.Items) { if ((string)cbi.Content == upolicy) { UpgradePolicyCombo.SelectedItem = cbi; break; } } break; } })); }
/// <summary> /// Invoked when the control panel is loaded /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event data</param> private void ControlPanel_Loaded(object sender, RoutedEventArgs e) { if (!initialized) { if (System.Windows.Forms.VisualStyles.VisualStyleInformation.DisplayName == "") { ControlPanelMain.Background = SystemColors.WindowBrush; ControlPanelLeft.Background = SystemColors.WindowBrush; } AboutChannel.Text = Capitalize(SettingsManager.Channel); UpdateUpgradeCheck(); AboutVersion.Text = Capitalize(SettingsManager.Release, true); // release name AboutRelease.Text = Unix2Date(SettingsManager.Version); // release date AboutStamp.Text = Version2String(SettingsManager.Version); // release version AboutArch.Text = SettingsManager.Architecture + "-bit"; if (SettingsManager.UpgradePolicy == UpgradePolicy.Manual) PrefCheckForUpgrades.Visibility = System.Windows.Visibility.Visible; // create languages foreach (ComboBoxItem cbi in PrefLanguage.Items) { if ((string)cbi.Tag == SettingsManager.Language) { PrefLanguage.SelectedItem = cbi; break; } } UpgradePolicyDescriptionConverter uconv = new UpgradePolicyDescriptionConverter(); string upolicy = (string)uconv.Convert(UpgradePolicy, null, null, null); SearchPolicyDescriptionConverter sconv = new SearchPolicyDescriptionConverter(); string spolicy = (string)sconv.Convert(SearchPolicy, null, null, null); OpenFileAddDescriptionConverter aconv = new OpenFileAddDescriptionConverter(); string apolicy = (string)aconv.Convert(ExternalClickAdd, null, null, null); OpenFilePlayDescriptionConverter pconv = new OpenFilePlayDescriptionConverter(); string ppolicy = (string)pconv.Convert(ExternalClickPlay, null, null, null); foreach (ComboBoxItem cbi in SearchPolicyCombo.Items) { if ((string)cbi.Content == spolicy) { SearchPolicyCombo.SelectedItem = cbi; break; } } foreach (ComboBoxItem cbi in UpgradePolicyCombo.Items) { if ((string)cbi.Content == upolicy) { UpgradePolicyCombo.SelectedItem = cbi; break; } } foreach (ComboBoxItem cbi in AddPolicyCombo.Items) { if ((string)cbi.Content == apolicy) { AddPolicyCombo.SelectedItem = cbi; break; } } foreach (ComboBoxItem cbi in PlayPolicyCombo.Items) { if ((string)cbi.Content == ppolicy) { PlayPolicyCombo.SelectedItem = cbi; break; } } SearchPolicyCombo.SelectionChanged += new SelectionChangedEventHandler(SearchPolicyCombo_SelectionChanged); UpgradePolicyCombo.SelectionChanged += new SelectionChangedEventHandler(UpgradePolicyCombo_SelectionChanged); AddPolicyCombo.SelectionChanged += new SelectionChangedEventHandler(AddPolicyCombo_SelectionChanged); PlayPolicyCombo.SelectionChanged += new SelectionChangedEventHandler(PlayPolicyCombo_SelectionChanged); PrefLanguage.SelectionChanged += new SelectionChangedEventHandler(PrefLanguage_SelectionChanged); initialized = true; } }
/// <summary> /// Invoked when the user changes search policy /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event data</param> private void SearchPolicyCombo_SelectionChanged(object sender, SelectionChangedEventArgs e) { SettingsManager.FileListConfig.Filter = ""; SettingsManager.HistoryListConfig.Filter = ""; SettingsManager.QueueListConfig.Filter = ""; SettingsManager.YouTubeListConfig.Filter = ""; foreach (PlaylistData p in SettingsManager.Playlists) p.ListConfig.Filter = ""; ParentWindow.PlaybackControls.Search.Clear(); SearchPolicyDescriptionConverter conv = new SearchPolicyDescriptionConverter(); ComboBoxItem cbi = (ComboBoxItem)SearchPolicyCombo.SelectedValue; SearchPolicy = (SearchPolicy)conv.ConvertBack((string)cbi.Content, null, null, null); }