// Private method to Read user preferences from registry [M] private void ReadRegistrys() { RegistryKey rKey = Registry.CurrentUser.OpenSubKey(@"Software\Mp3Box"); if (rKey == null) { // if registry subkey is resolve to null then create a sub-key >>> rKey = Registry.CurrentUser.CreateSubKey(@"Software\Mp3Box"); } else { try { // Get and Update volume value of Volume-Slider >> VolumeSlider.Value = double.Parse((string)rKey.GetValue("VL")); // Get and Update Repeat Mode >>> //RepeatMode = Iterator.ParseRepeatMode((string)rKey.GetValue("RM")); RepeatMode = FileManager.ParseRepeatMode((string)rKey.GetValue("RM")); UpdateRepratModeRadioBtn(RepeatMode); // Get and Update Position of the window over screen >>> Point Pos = Point.Parse((string)rKey.GetValue("SP")); this.Top = Pos.X; this.Left = Pos.Y; } catch (Exception Ex) { //MessageBox.Show(string.Format("Reading Registry Failed :\n{0}", Ex.Message), "Error", MessageBoxButton.OKCancel, MessageBoxImage.Error); } } rKey.Close(); }
// private method to Update RepeatMode-Radio-Button state. [M] private void UpdateRepratModeRadioBtn(Iterator.RepeatModeEnum Mode) { if (Iterator.RepeatModeEnum.RepeatAll == Mode) { repeatAllRb.IsChecked = true; } if (Iterator.RepeatModeEnum.RepeatOnce == Mode) { repeatOnceRb.IsChecked = true; } if (Iterator.RepeatModeEnum.Shuffle == Mode) { shuffleRb.IsChecked = true; } }
// Checked event handler for RepeatModeBtn RadioButton Group. [E] private void RepeatModeRadioButton_Checked(object sender, RoutedEventArgs e) { RadioButton btn = sender as RadioButton; if (btn.Tag.ToString() == "RepeatOnce") { fileManager.RepeatMode = RepeatMode = Iterator.RepeatModeEnum.RepeatOnce; } if (btn.Tag.ToString() == "RepeatAll") { fileManager.RepeatMode = RepeatMode = Iterator.RepeatModeEnum.RepeatAll; } if (btn.Tag.ToString() == "Shuffle") { fileManager.RepeatMode = RepeatMode = Iterator.RepeatModeEnum.Shuffle; } }