Ejemplo n.º 1
0
        public SettingsPlaybackViewModel(IPlaybackService playbackService, ITaskbarService taskbarService, INotificationService notificationService, IDialogService dialogService)
        {
            this.playbackService     = playbackService;
            this.taskbarService      = taskbarService;
            this.notificationService = notificationService;
            this.dialogService       = dialogService;

            ShowTestNotificationCommand = new DelegateCommand(() => this.notificationService.ShowNotificationAsync());

            this.GetCheckBoxesAsync();
            this.GetNotificationPositionsAsync();
            this.GetNotificationSecondsAsync();
            this.GetLatenciesAsync();
        }
Ejemplo n.º 2
0
        public ShellViewModel(IPlaybackService playbackService, ITaskbarService taskbarService, IDialogService dialogService,
                              IJumpListService jumpListService, IFileService fileService, IUpdateService updateService)
        {
            this.TaskbarService = taskbarService;

            dialogService.DialogVisibleChanged += isDialogVisible => { this.IsOverlayVisible = isDialogVisible; };

            this.PlayPreviousCommand = new DelegateCommand(async() => await playbackService.PlayPreviousAsync());
            this.PlayNextCommand     = new DelegateCommand(async() => await playbackService.PlayNextAsync());
            this.PlayOrPauseCommand  = new DelegateCommand(async() => await playbackService.PlayOrPauseAsync());

            this.LoadedCommand = new DelegateCommand(() => fileService.ProcessArguments(Environment.GetCommandLineArgs()));

            // Populate the JumpList
            jumpListService.PopulateJumpListAsync();
        }
Ejemplo n.º 3
0
        public ShellViewModel(IPlaybackService playbackService, ITaskbarService taskbarService, IDialogService dialogService)
        {
            this.TaskbarService = taskbarService;
            this.dialogService  = dialogService;

            this.dialogService.DialogVisibleChanged += isDialogVisible => { this.IsOverlayVisible = isDialogVisible; };

            this.PlayPreviousCommand = new DelegateCommand(async() => await playbackService.PlayPreviousAsync());
            this.PlayNextCommand     = new DelegateCommand(async() => await playbackService.PlayNextAsync());
            this.PlayOrPauseCommand  = new DelegateCommand(async() => await playbackService.PlayOrPauseAsync());

            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);
                }
            });
        }
Ejemplo n.º 4
0
        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();
        }