public SettingsOnlineViewModel(IUnityContainer container, IProviderService providerService, IDialogService dialogService, IScrobblingService scrobblingService, IEventAggregator eventAggregator) { this.container = container; this.providerService = providerService; this.dialogService = dialogService; this.scrobblingService = scrobblingService; this.eventAggregator = eventAggregator; this.scrobblingService.SignInStateChanged += (_) => { this.IsLastFmSigningIn = false; OnPropertyChanged(() => this.IsLastFmSignedIn); OnPropertyChanged(() => this.LastFmUsername); OnPropertyChanged(() => this.IsLastFmSignInError); }; this.AddCommand = new DelegateCommand(() => this.AddSearchProvider()); this.EditCommand = new DelegateCommand(() => { this.EditSearchProvider(); }, () => { return(this.SelectedSearchProvider != null); }); this.RemoveCommand = new DelegateCommand(() => { this.RemoveSearchProvider(); }, () => { return(this.SelectedSearchProvider != null); }); this.LastfmSignInCommand = new DelegateCommand(async() => { this.IsLastFmSigningIn = true; await this.scrobblingService.SignIn(); }); this.LastfmSignOutCommand = new DelegateCommand(() => this.scrobblingService.SignOut()); this.CreateLastFmAccountCommand = new DelegateCommand(() => Actions.TryOpenLink(Constants.LastFmJoinLink)); this.GetSearchProvidersAsync(); this.providerService.SearchProvidersChanged += (_, __) => this.GetSearchProvidersAsync(); this.GetCheckBoxesAsync(); this.GetTimeoutsAsync(); }
public SettingsOnlineViewModel(IUnityContainer container, IProviderService providerService, IDialogService dialogService, IScrobblingService scrobblingService) { this.container = container; this.providerService = providerService; this.dialogService = dialogService; this.scrobblingService = scrobblingService; this.scrobblingService.SignInStateChanged += (_) => { this.IsLastFmSigningIn = false; OnPropertyChanged(() => this.IsLastFmSignedIn); OnPropertyChanged(() => this.LastFmUsername); OnPropertyChanged(() => this.IsLastFmSignInError); }; this.AddCommand = new DelegateCommand(() => this.AddSearchProvider()); this.EditCommand = new DelegateCommand(() => { this.EditSearchProvider(); }, () => { return(this.SelectedSearchProvider != null); }); this.RemoveCommand = new DelegateCommand(() => { this.RemoveSearchProvider(); }, () => { return(this.SelectedSearchProvider != null); }); this.LastfmSignInCommand = new DelegateCommand(async() => { this.IsLastFmSigningIn = true; await this.scrobblingService.SignIn(); }); this.LastfmSignOutCommand = new DelegateCommand(() => this.scrobblingService.SignOut()); this.GetSearchProvidersAsync(); this.providerService.SearchProvidersChanged += (_, __) => this.GetSearchProvidersAsync(); }
public SettingsOnline() { InitializeComponent(); this.scrobblingService = ServiceLocator.Current.GetInstance <IScrobblingService>(); this.scrobblingService.SignInStateChanged += (_) => this.PasswordBox.Password = scrobblingService.Password; this.PasswordBox.Password = scrobblingService.Password; }
public PlaybackInfoControlViewModel(IPlaybackService playbackService, IMetadataService metadataService, IScrobblingService scrobblingService) { this.playbackService = playbackService; this.metadataService = metadataService; this.scrobblingService = scrobblingService; this.refreshTimer.Interval = this.refreshTimerIntervalMilliseconds; this.refreshTimer.Elapsed += RefreshTimer_Elapsed; this.playbackService.PlaybackSuccess += (_, e) => { this.SlideDirection = e.IsPlayingPreviousTrack ? SlideDirection.UpToDown : SlideDirection.DownToUp; this.refreshTimer.Stop(); this.refreshTimer.Start(); }; this.playbackService.PlaybackProgressChanged += (_, __) => this.UpdateTime(); this.playbackService.PlayingTrackChanged += (_, __) => this.RefreshPlaybackInfoAsync(this.playbackService.CurrentTrack, true); this.metadataService.RatingChanged += (e) => { if (this.track != null && e.SafePath.Equals(this.track.SafePath)) { this.track.Rating = e.Rating; this.RaisePropertyChanged(nameof(Rating)); } }; this.metadataService.LoveChanged += (e) => { if (this.track != null && e.SafePath.Equals(this.track.SafePath)) { this.track.Love = e.Love; this.RaisePropertyChanged(nameof(Love)); } }; // Settings SettingsClient.SettingChanged += async(_, e) => { if (SettingsClient.IsSettingChanged(e, "Behaviour", "EnableRating")) { this.EnableRating = (bool)e.SettingValue; } if (SettingsClient.IsSettingChanged(e, "Behaviour", "EnableLove")) { this.EnableLove = (bool)e.SettingValue; } }; // Defaults this.SlideDirection = SlideDirection.DownToUp; this.RefreshPlaybackInfoAsync(this.playbackService.CurrentTrack, false); this.EnableRating = SettingsClient.Get <bool>("Behaviour", "EnableRating"); this.EnableLove = SettingsClient.Get <bool>("Behaviour", "EnableLove"); }
public PlaybackInfoControlNanoViewModel( IPlaybackService playbackService, IMetadataService metadataService, IScrobblingService scrobblingService) : base( playbackService, metadataService, scrobblingService ) { }
public SettingsOnline(IScrobblingService scrobblingService) { InitializeComponent(); this.scrobblingService = scrobblingService; this.scrobblingService.SignInStateChanged += (_) => this.PasswordBox.Password = scrobblingService.Password; this.PasswordBox.Password = scrobblingService.Password; }
public SettingsOnlineViewModel(IContainerProvider container, IProviderService providerService, IDialogService dialogService, IScrobblingService scrobblingService, IEventAggregator eventAggregator) { this.container = container; this.providerService = providerService; this.dialogService = dialogService; this.scrobblingService = scrobblingService; this.eventAggregator = eventAggregator; this.scrobblingService.SignInStateChanged += (_) => { this.IsLastFmSigningIn = false; RaisePropertyChanged(nameof(this.IsLastFmSignedIn)); RaisePropertyChanged(nameof(this.LastFmUsername)); RaisePropertyChanged(nameof(this.IsLastFmSignInError)); }; this.AddCommand = new DelegateCommand(() => this.AddSearchProvider()); this.EditCommand = new DelegateCommand(() => { this.EditSearchProvider(); }, () => { return(this.SelectedSearchProvider != null); }); this.RemoveCommand = new DelegateCommand(() => { this.RemoveSearchProvider(); }, () => { return(this.SelectedSearchProvider != null); }); this.LastfmSignInCommand = new DelegateCommand(async() => { this.IsLastFmSigningIn = true; await this.scrobblingService.SignIn(); }); this.LastfmSignOutCommand = new DelegateCommand(() => this.scrobblingService.SignOut()); this.CreateLastFmAccountCommand = new DelegateCommand(() => { try { Actions.TryOpenLink(Constants.LastFmJoinLink); } catch (Exception ex) { LogClient.Error("Could not open the Last.fm web page. Exception: {0}", ex.Message); } }); this.GetSearchProvidersAsync(); this.providerService.SearchProvidersChanged += (_, __) => this.GetSearchProvidersAsync(); this.GetCheckBoxesAsync(); this.GetTimeoutsAsync(); }
public TrackViewModel(IMetadataService metadataService, IScrobblingService scrobblingService) { this.metadataService = metadataService; this.scrobblingService = scrobblingService; }
public ShellViewModel(IUnityContainer container, IRegionManager regionManager, IDialogService dialogService, IPlaybackService playbackService, II18nService i18nService, ITaskbarService taskbarService, IJumpListService jumpListService, IFileService fileService, IScrobblingService scrobblingService) { this.container = container; this.regionManager = regionManager; this.dialogService = dialogService; this.playbackService = playbackService; this.i18nService = i18nService; this.taskbarService = taskbarService; this.jumpListService = jumpListService; this.fileService = fileService; this.scrobblingService = scrobblingService; // Not used here, but needs to be instantiated in the main window to ensure scrobbling is enabled. // Event handlers this.dialogService.DialogVisibleChanged += isDialogVisible => { this.IsOverlayVisible = isDialogVisible; }; this.ShowLogfileCommand = new DelegateCommand(() => { try { Actions.TryViewInExplorer(LogClient.Logfile()); } catch (Exception ex) { LogClient.Error("Could not view the log file {0} in explorer. Exception: {1}", LogClient.Logfile(), ex.Message); } }); this.OpenPathCommand = new DelegateCommand <string>((string path) => { try { Actions.TryOpenPath(path); } catch (Exception ex) { LogClient.Error("Could not open the path {0} in Explorer. Exception: {1}", path, ex.Message); } }); ApplicationCommands.OpenPathCommand.RegisterCommand(this.OpenPathCommand); this.OpenLinkCommand = new DelegateCommand <string>((string link) => { try { Actions.TryOpenLink(link); } catch (Exception ex) { LogClient.Error("Could not open the link {0} in Internet Explorer. Exception: {1}", link, ex.Message); } }); ApplicationCommands.OpenLinkCommand.RegisterCommand(this.OpenLinkCommand); this.PreviousCommand = new DelegateCommand(async() => await this.playbackService.PlayPreviousAsync()); this.NextCommand = new DelegateCommand(async() => await this.playbackService.PlayNextAsync()); this.LoadedCommand = new DelegateCommand(() => this.fileService.ProcessArguments(Environment.GetCommandLineArgs())); this.playbackService.PlaybackFailed += (sender, playbackFailedEventArgs) => { switch (playbackFailedEventArgs.FailureReason) { case PlaybackFailureReason.FileNotFound: this.dialogService.ShowNotification(0xe711, 16, ResourceUtils.GetStringResource("Language_Error"), ResourceUtils.GetStringResource("Language_Error_Cannot_Play_This_Song_File_Not_Found"), ResourceUtils.GetStringResource("Language_Ok"), false, string.Empty); break; default: this.dialogService.ShowNotification(0xe711, 16, ResourceUtils.GetStringResource("Language_Error"), ResourceUtils.GetStringResource("Language_Error_Cannot_Play_This_Song"), ResourceUtils.GetStringResource("Language_Ok"), true, ResourceUtils.GetStringResource("Language_Log_File")); break; } }; // Equalizer this.ShowEqualizerCommand = new DelegateCommand(() => { EqualizerControl view = this.container.Resolve <EqualizerControl>(); view.DataContext = this.container.Resolve <EqualizerControlViewModel>(); this.dialogService.ShowCustomDialog( new EqualizerIcon() { IsDialogIcon = true }, ResourceUtils.GetStringResource("Language_Equalizer"), view, 570, 0, false, true, true, false, ResourceUtils.GetStringResource("Language_Close"), string.Empty, null); }); ApplicationCommands.ShowEqualizerCommand.RegisterCommand(this.ShowEqualizerCommand); // Populate the JumpList this.jumpListService.PopulateJumpListAsync(); }