Ejemplo n.º 1
0
        private void WindowMenuItemCommand_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            Window parent = Window.GetWindow((MenuItem)e.OriginalSource);

            e.CanExecute =
                (e.OriginalSource as MenuItem).Name !=
                Enum.GetName(typeof(WindowUtilityLibrary.WindowType), WindowUtilityLibrary.GetWindowTypeEnum(parent.GetType()));
        }
Ejemplo n.º 2
0
        private void ConnectItemLoaded(object sender, RoutedEventArgs e)
        {
            if (sender == null)
            {
                throw new ArgumentNullException(nameof(sender));
            }

            Window parent = Window.GetWindow((MenuItem)sender);

            WindowUtilityLibrary.WindowType windowType = WindowUtilityLibrary.GetWindowTypeEnum(parent.GetType());
            if (windowType != WindowUtilityLibrary.WindowType.Audiocheck)
            {
                (sender as MenuItem).Visibility = Visibility.Collapsed;
            }
        }
        /// <summary>
        /// Save user preferences.
        /// </summary>
        /// <returns>True if saved, false if validation error.</returns>
        private bool Save()
        {
            save_button.IsEnabled = false;
            Preferences.Default.obs_settings_changed = false;
            if (!WindowUtilityLibrary.DependencyObjectIsValid(this))
            {
                save_validation_error.Visibility = Visibility.Visible;
                NotifyTextBlockChanged(save_validation_error);
                save_button.IsEnabled = true;
                return(false);
            }
            else
            {
                save_validation_error.Visibility = Visibility.Hidden;
            }

            ResourceManager rm = new ResourceManager("uk.JohnCook.dotnet.StreamController.Properties.Resources", typeof(PreferencesWindow).Assembly);

            UpdatePreferenceIfChanged("obs_uri_scheme", cbUriProtocol.Text);
            if (cbUsePassword.IsChecked.Value && pbPassword.Password == PASSWORD_PLACEHOLDER)
            {
                if (!Preferences.Default.obs_use_password)
                {
                    _ = MessageBox.Show(rm.GetString("new_password_placeholder_error", CultureInfo.CurrentCulture), rm.GetString("title_new_password_error", CultureInfo.CurrentCulture), MessageBoxButton.OK);
                    save_button.IsEnabled = true;
                    return(false);
                }
            }
            else if (cbUsePassword.IsChecked.Value)
            {
                SharedModels.SecurePreferences securePreferences = new SharedModels.SecurePreferences();
                char[] password = pbPassword.Password.ToArray();
                string output   = String.Empty;
                _ = securePreferences.StoreString(ref output, ref password);
                Preferences.Default.obs_password = output;
                Array.Clear(password, 0, password.Length);
                pbPassword.Password = PASSWORD_PLACEHOLDER;
                Preferences.Default.obs_use_password = true;

                _ = MessageBox.Show(rm.GetString("new_password_set_message", CultureInfo.CurrentCulture), rm.GetString("title_new_password_saved", CultureInfo.CurrentCulture), MessageBoxButton.OK);
            }
            else
            {
                Preferences.Default.obs_use_password = false;
                Preferences.Default.obs_password     = String.Empty;
            }


            UpdatePreferenceIfChanged("obs_local_clock_source_name", ComboBoxLocalClockTimeSource.Text);
            UpdatePreferenceIfChanged("local_timezone_use_utc_offset", !CheckBoxLocalClockCustomTimezone.IsChecked.Value);
            UpdatePreferenceIfChanged("local_timezone_abbreviation", TextBoxLocalClockTimezoneNormal.Text);
            UpdatePreferenceIfChanged("local_timezone_dst_abbreviation", TextBoxLocalClockTimezoneDst.Text);
            UpdatePreferenceIfChanged("obs_local_clock_weather_json_url", TextBoxLocalClockWeatherUrl.Text);
            UpdatePreferenceIfChanged("obs_local_clock_weather_json_url_fetch_delay", TextBoxLocalClockWeatherUrlFetchDelay.Text);
            UpdatePreferenceIfChanged("obs_local_clock_location_source_name", ComboBoxLocalClockWeatherLocationSource.Text);
            UpdatePreferenceIfChanged("obs_local_clock_weather_symbol_source_name", ComboBoxLocalClockWeatherSymbolSource.Text);
            UpdatePreferenceIfChanged("obs_local_clock_weather_temp_source_name", ComboBoxLocalClockWeatherTempSource.Text);
            UpdatePreferenceIfChanged("obs_local_clock_weather_attrib1_source_name", ComboBoxLocalClockWeatherAttrib1Source.Text);
            UpdatePreferenceIfChanged("obs_local_clock_weather_attrib1_text", TextBoxLocalClockWeatherAttrib1Value.Text);
            UpdatePreferenceIfChanged("obs_local_clock_weather_attrib2_source_name", ComboBoxLocalClockWeatherAttrib2Source.Text);
            UpdatePreferenceIfChanged("obs_local_clock_weather_attrib2_text", TextBoxLocalClockWeatherAttrib2Value.Text);
            UpdatePreferenceIfChanged("obs_local_clock_cycle_delay", TextBoxLocalClockWeatherCycleDelay.Text);
            UpdatePreferenceIfChanged("obs_slideshow_source_name", ComboBoxSlideShowSource.Text);
            UpdatePreferenceIfChanged("obs_slideshow_next_scene_delay", TextBoxSlideShowSceneDelay.Text);


            Preferences.Default.Save();
            Preferences.Default.obs_settings_changed = true;
            // TODO: Update existing ObsWsClient.AutoReconnect if necessary
            return(true);
        }
Ejemplo n.º 4
0
 private void WindowMenuItemCommand_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     WindowUtilityLibrary.WindowType windowType = (WindowUtilityLibrary.WindowType)Enum.Parse(typeof(WindowUtilityLibrary.WindowType), (e.OriginalSource as MenuItem).Name);
     WindowUtilityLibrary.MakeWindowActive(windowType);
 }
 private void NotifyIcon_TrayMouseDoubleClick(object sender, RoutedEventArgs e)
 {
     WindowUtilityLibrary.MakeWindowActive(WindowUtilityLibrary.WindowType.Audiocheck);
 }