Пример #1
0
        private async Task InitializeAudioGraphAsync()
        {
            _audioPlayer = new XAudioPlayer();

            var successful = await _audioPlayer.InitializeAudioGraphAsync();

            if (!successful)
            {
                IsAudioEffectsSupport = false;
                return;
            }

            IsAudioEffectsSupport         = true;
            _audioPlayer.MediaEnd        += (sender, args) => OnCurrentTrackEnd();
            _audioPlayer.StateChanged    += (sender, args) => DispatcherHelper.CheckBeginInvokeOnUI(() => State = _audioPlayer.State);
            _audioPlayer.ErrorOccurred   += (sender, args) => OnCurrentTrackEnd();
            _audioPlayer.PositionChanged += (sender, args) => DispatcherHelper.CheckBeginInvokeOnUI(() => NotifyPositionInternal(_audioPlayer.Position));

            _audioPlayer.IsEQEffectEnabled = LocalSettingsHelper.LoadValue(CommonKeys.EQEffectEnabled, false);
            _audioPlayer.EQBassGain        = LocalSettingsHelper.LoadValue(CommonKeys.EQBassGain, 50d);
            _audioPlayer.EQLowMidGain      = LocalSettingsHelper.LoadValue(CommonKeys.EQLowMidGain, 20d);
            _audioPlayer.EQHighMidGain     = LocalSettingsHelper.LoadValue(CommonKeys.EQHighMidGain, 70d);
            _audioPlayer.EQHighPitchGain   = LocalSettingsHelper.LoadValue(CommonKeys.EQHighPitchGain, 30d);

            _audioPlayer.IsEchoEffectEnabled = LocalSettingsHelper.LoadValue(CommonKeys.EchoEffectEnabled, false);
            _audioPlayer.EchoDelay           = LocalSettingsHelper.LoadValue(CommonKeys.EchoDelay, 50d);

            _audioPlayer.IsLimiterEffectEnabled = LocalSettingsHelper.LoadValue(CommonKeys.LimiterEffectEnabled, false);
            _audioPlayer.LimiterLoudness        = LocalSettingsHelper.LoadValue(CommonKeys.LimiterLoudness, 20u);

            _audioPlayer.IsReverbEffectEnabled = LocalSettingsHelper.LoadValue(CommonKeys.ReverbEffectEnabled, false);
            _audioPlayer.ReverbDecayTime       = LocalSettingsHelper.LoadValue(CommonKeys.ReverbDecay, 2d);
        }
Пример #2
0
 public void Save()
 {
     lock (lockable)
     {
         LocalSettingsHelper.GetContainer(SETTINGS_CONTAINER).WriteGroupSettings(this);
         SettingsChanged?.Invoke(null, EventArgs.Empty);
     }
 }
Пример #3
0
        static OptionsHelper()
        {
            options        = new OptionsEntity();
            SettingsKeeper = new LocalSettingsKeeper();
            SettingsKeeper.LoadSettings(options);
            var datFiles = LocalSettingsHelper.GetValues <string>(SettingsKeeper, "OPENED_DAT_FILE");

            options.OpenedDatFile.AddRange(datFiles);
        }
Пример #4
0
        public async Task InitializeAsync()
        {
            if (_initialized)
            {
                return;
            }
            _initialized = true;

            if (LocalSettingsHelper.LoadValue(CommonKeys.KeepScreenOn, false))
            {
                DisplayRequestHelper.RequestActive();
            }

            PlaylistsTitle = new ObservableCollection <string>((await Playlist.GetPlaylistsTitleAsync()));

            var lastUsedPlaylist = LocalSettingsHelper.LoadValue(CommonKeys.LastUsedPlaylist, PlaylistsTitle.FirstOrDefault());

            _selectedPlaylistTitle = PlaylistsTitle.SingleOrDefault(p => p.Equals(lastUsedPlaylist, StringComparison.OrdinalIgnoreCase)) ?? PlaylistsTitle.FirstOrDefault();
            RaisePropertyChanged(nameof(SelectedPlaylistTitle));
            await SwitchPlaylist(SelectedPlaylistTitle);

            if (ActivePlaylistViewModel == null)
            {
                return;
            }

            var lastPlayedSong = LocalSettingsHelper.LoadValue(CommonKeys.LastPlayedSong, string.Empty);

            if (string.IsNullOrEmpty(lastPlayedSong))
            {
                return;
            }

            var songs = ActivePlaylistViewModel.GetFlatSongs();

            if (songs.Count == 0)
            {
                return;
            }
            var targetSong = songs.FirstOrDefault(s => s.FileUriPath.Equals(lastPlayedSong, StringComparison.OrdinalIgnoreCase));

            if (targetSong == null)
            {
                return;
            }

            PlayerViewModel.PlaylistTitle = ActivePlaylistViewModel.Title;

            if (((App)Application.Current).IsFileActivated)
            {
                return;
            }

            PlayerViewModel.AutoPlay = LocalSettingsHelper.LoadValue(CommonKeys.AutoPlay, false);
            PlayerViewModel.Play(songs, songs.IndexOf(targetSong));
        }
Пример #5
0
 public void SaveSettings()
 {
     var task = ThreadPool.RunAsync((work) =>
     {
         Cities.Save();
         Immersive.Save();
         Preferences.Save();
         LocalSettingsHelper.WriteSettingsValue("Inited", true);
     });
 }
Пример #6
0
        public SleepingModeViewModel()
        {
            _userDefinedNumber = LocalSettingsHelper.LoadValue(CommonKeys.SleepingModeNumber, (uint)30).ToString();
            _isMinutesMode     = LocalSettingsHelper.LoadValue(CommonKeys.SleepingMinutesMode, true);
            _isSongsCountMode  = LocalSettingsHelper.LoadValue(CommonKeys.SleepingSongsCountMode, false);

            StartCommand = new ActionCommand <object>(ExecuteStartCommand);

            ViewModelLocator.Instance.PlayerViewModel.ActiveSongChanged += PlayerViewModelOnActiveSongChanged;
        }
Пример #7
0
 private string GetFavoriteState()
 {
     try
     {
         return(LocalSettingsHelper.GetContainerValue <string>(SettingContainer.Favorite, "StateCode"));
     }
     catch
     {
         return(string.Empty);
     }
 }
Пример #8
0
 private void OnFavoriteCommandExecute()
 {
     if (IsFavoriteState)
     {
         LocalSettingsHelper.MarkContainer(SettingContainer.Favorite, "StateCode", string.Empty);
     }
     else
     {
         LocalSettingsHelper.MarkContainer(SettingContainer.Favorite, "StateCode", SelectedState.StateCode);
     }
     SetFavoriteIcon();
 }
Пример #9
0
        public async Task InitializeAsync()
        {
            if (_initialized)
            {
                return;
            }
            _initialized = true;

            _isLoopOn         = LocalSettingsHelper.LoadValue(CommonKeys.IsLoopOn, false);
            _isShuffleOn      = LocalSettingsHelper.LoadValue(CommonKeys.IsShuffleOn, false);
            _isSingleRepeatOn = LocalSettingsHelper.LoadValue(CommonKeys.IsSingleRepeatOn, false);

            await InitializeAudioGraphAsync();
        }
Пример #10
0
        public AudioEffectsViewModel()
        {
            _isEqualizerEnabled = LocalSettingsHelper.LoadValue(CommonKeys.EQEffectEnabled, false);
            _isEchoEnabled      = LocalSettingsHelper.LoadValue(CommonKeys.EchoEffectEnabled, false);
            _isLimiterEnabled   = LocalSettingsHelper.LoadValue(CommonKeys.LimiterEffectEnabled, false);
            _isReverbEnabled    = LocalSettingsHelper.LoadValue(CommonKeys.ReverbEffectEnabled, false);

            _echoDelay       = PlayerViewModel.XAudioPlayer?.EchoDelay ?? 50;
            _limiterLoudness = PlayerViewModel.XAudioPlayer?.LimiterLoudness ?? 20;
            _reverbDecayTime = PlayerViewModel.XAudioPlayer?.ReverbDecayTime ?? 2;
            _eq100HzGain     = PlayerViewModel.XAudioPlayer?.EQBassGain ?? 50;
            _eq900HzGain     = PlayerViewModel.XAudioPlayer?.EQLowMidGain ?? 20;
            _eq5kHzGain      = PlayerViewModel.XAudioPlayer?.EQHighMidGain ?? 70;
            _eq12kHzGain     = PlayerViewModel.XAudioPlayer?.EQHighPitchGain ?? 30;
        }
Пример #11
0
 private static Settings Load()
 {
     try
     {
         if (LocalSettingsHelper.GetContainer(SETTINGS_CONTAINER).ReadGroupSettings(out Settings s))
         {
             return(s);
         }
         else
         {
             return(new Settings());
         }
     }
     catch (Exception)
     {
         return(new Settings());
     }
 }
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            Task.Run(async() => await LocalSettingsHelper.InitializeAsync()).Wait();

            MVARegistrationHelpers.UnlockLimitedAccessFeature();
            LogRouter.Initialize();

            this.keywordRegistration = new KeywordRegistration(new Version(1, 0, 0, 0));

            this.agentSessionManager = new AgentSessionManager();

            //var _ = this.UpdateSessionAsync();
            _ = this.DoKeywordSetupAsync();
            MVARegistrationHelpers.IsBackgroundTaskRegistered = true;
        }
Пример #13
0
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            switch (ConfirmDelete.Visibility)
            {
            case Visibility.Visible:
                RoamingSettingsHelper.ClearAllSettings();
                LocalSettingsHelper.ClearAllSettings();
                App.Current.Exit();
                break;

            case Visibility.Collapsed:
                ConfirmDelete.Visibility = Visibility.Visible;
                DeleteButton.Content     = "OK!";
                break;

            default:
                break;
            }
        }
Пример #14
0
        public static SettingsModel Get()
        {
            var s = new SettingsModel();

            s.Cities      = Cities.Get();
            s.Immersive   = Immersive.Get();
            s.Preferences = Preferences.Get();
            var init = LocalSettingsHelper.ReadSettingsValue("Inited");

            if (init == null)
            {
                s.Inited = false;
            }
            else
            {
                s.Inited = true;
            }
            return(s);
        }
Пример #15
0
 internal void Complete()
 {
     Cities.Save();
     LocalSettingsHelper.WriteSettingsValue("Inited", true);
 }
Пример #16
0
 public static void SaveSettings()
 {
     LocalSettingsHelper.SetValues(SettingsKeeper, "OPENED_DAT_FILE", options.OpenedDatFile.Take(20).ToArray());
     SettingsKeeper.SaveSettings(options);
 }
Пример #17
0
 public SettingsViewModel()
 {
     _autoPlay     = LocalSettingsHelper.LoadValue(CommonKeys.AutoPlay, false);
     _keepScreenOn = LocalSettingsHelper.LoadValue(CommonKeys.KeepScreenOn, false);
 }