private async Task <SettingsWindowVM> SetupViewModels() { var albumArt = new AlbumArtVM(_albumArtModel, _trackModel); var albumArtPopup = new AlbumArtPopupVM(_albumArtPopupModel, _trackModel); var audioBand = new AudioBandVM(_audioBandModel); var customLabels = new CustomLabelsVM(_customLabelsModel, this); var nextButton = new NextButtonVM(_nextButtonModel); var playPauseButton = new PlayPauseButtonVM(_playPauseButtonModel, _trackModel); var prevButton = new PreviousButtonVM(_previousButtonModel); var progressBar = new ProgressBarVM(_progressBarModel, _trackModel); await _uiDispatcher.InvokeAsync(() => InitializeBindingSources(albumArtPopup, albumArt, audioBand, nextButton, playPauseButton, prevButton, progressBar)); return(new SettingsWindowVM { AlbumArtPopupVM = albumArtPopup, ProgressBarVM = progressBar, PreviousButtonVM = prevButton, PlayPauseButtonVM = playPauseButton, NextButtonVM = nextButton, AudioBandVM = audioBand, AboutVm = new AboutVM(), AlbumArtVM = albumArt, CustomLabelsVM = customLabels, AudioSourceSettingsVM = new ObservableCollection <AudioSourceSettingsVM>() }); }
/// <summary> /// Initializes a new instance of the <see cref="SettingsWindow"/> class /// with the settings viewmodel. /// </summary> /// <param name="vm">The settings window viewmodel.</param> /// <param name="audioBandVM">The audioband view model</param> /// <param name="albumArtPopupVM">The album art popup view model</param> /// <param name="albumArtVM">The album art view model</param> /// <param name="customLabelsVM">The custom labels view model</param> /// <param name="aboutVm">The about dialog view model</param> /// <param name="nextButtonVM">The next button view model</param> /// <param name="playPauseButtonVM">The play/pause button view model</param> /// <param name="previousButtonVM">The previous button view model</param> /// <param name="progressBarVM">The progress bar view model</param> public SettingsWindow( SettingsWindowVM vm, AudioBandVM audioBandVM, AlbumArtPopupVM albumArtPopupVM, AlbumArtVM albumArtVM, CustomLabelsVM customLabelsVM, AboutVM aboutVm, NextButtonVM nextButtonVM, PlayPauseButtonVM playPauseButtonVM, PreviousButtonVM previousButtonVM, ProgressBarVM progressBarVM) { AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; ElementHost.EnableModelessKeyboardInterop(this); CancelCloseCommand = new RelayCommand(CancelCloseCommandOnExecute); SaveCloseCommand = new RelayCommand(SaveCloseCommandOnExecute); AudioBandVM = audioBandVM; AlbumArtPopupVM = albumArtPopupVM; AlbumArtVM = albumArtVM; CustomLabelsVM = customLabelsVM; AboutVM = aboutVm; NextButtonVM = nextButtonVM; PlayPauseButtonVM = playPauseButtonVM; PreviousButtonVM = previousButtonVM; ProgressBarVM = progressBarVM; InitializeComponent(); DataContext = vm; _vm = vm; Activated += OnActivated; }
public void Init() { _hostMock = new Mock <ICustomLabelHost>(); _dialogMock = new Mock <IDialogService>(); _label = new CustomLabel(); _vm = new CustomLabelsVM(new List <CustomLabel>(), _hostMock.Object); }
public void Init() { _labelServiceMock = new Mock <ICustomLabelService>(); _dialogMock = new Mock <IDialogService>(); _appSettingsMock = new Mock <IAppSettings>(); _appSettingsMock.Setup(x => x.CustomLabels).Returns(new List <CustomLabel>()); _label = new CustomLabel(); _vm = new CustomLabelsVM(_appSettingsMock.Object, _labelServiceMock.Object, _dialogMock.Object); }
public void RemoveLabel_ThenCancel() { _appSettingsMock.SetupGet(x => x.CustomLabels).Returns(new List <CustomLabel> { new CustomLabel() }); _dialogMock.Setup(o => o.ShowConfirmationDialog(It.IsAny <string>(), It.IsAny <string>())).Returns(true); _vm = new CustomLabelsVM(_appSettingsMock.Object, _labelServiceMock.Object, _dialogMock.Object); _vm.BeginEdit(); var label = _vm.CustomLabels[0]; _vm.RemoveLabelCommand.Execute(label); _vm.CancelEdit(); Assert.AreEqual(1, _vm.CustomLabels.Count); Assert.AreEqual(label, _vm.CustomLabels[0]); _labelServiceMock.Verify(o => o.RemoveCustomTextLabel(label), Times.Once); }
private async Task <SettingsWindowVM> SetupViewModels() { var albumArt = new AlbumArtVM(_albumArtModel, _trackModel); var albumArtPopup = new AlbumArtPopupVM(_albumArtPopupModel, _trackModel); var audioBand = new AudioBandVM(_audioBandModel); var customLabels = new CustomLabelsVM(_customLabelsModel, this); var nextButton = new NextButtonVM(_nextButtonModel); var playPauseButton = new PlayPauseButtonVM(_playPauseButtonModel, _trackModel); var prevButton = new PreviousButtonVM(_previousButtonModel); var progressBar = new ProgressBarVM(_progressBarModel, _trackModel); var allAudioSourceSettings = new List <AudioSourceSettingsVM>(); foreach (var audioSource in _audioSourceLoader.AudioSources) { var matchingSetting = _audioSourceSettingsModel.FirstOrDefault(s => s.AudioSourceName == audioSource.Name); if (matchingSetting != null) { allAudioSourceSettings.Add(new AudioSourceSettingsVM(matchingSetting, audioSource)); } else { var newSettings = new AudioSourceSettings { AudioSourceName = audioSource.Name }; _audioSourceSettingsModel.Add(newSettings); allAudioSourceSettings.Add(new AudioSourceSettingsVM(newSettings, audioSource)); } } await _uiDispatcher.InvokeAsync(() => InitializeBindingSources(albumArtPopup, albumArt, audioBand, nextButton, playPauseButton, prevButton, progressBar)); return(new SettingsWindowVM { AlbumArtPopupVM = albumArtPopup, ProgressBarVM = progressBar, PreviousButtonVM = prevButton, PlayPauseButtonVM = playPauseButton, NextButtonVM = nextButton, AudioBandVM = audioBand, AboutVm = new AboutVM(), AlbumArtVM = albumArt, CustomLabelsVM = customLabels, AudioSourceSettingsVM = allAudioSourceSettings }); }
public async Task RemoveLabel_ThenCancel() { var host = new Mock <ICustomLabelHost>(); var dialog = new Mock <IDialogService>(); var vm = new CustomLabelsVM(new List <CustomLabel> { new CustomLabel() }, host.Object); vm.BeginEdit(); dialog.Setup(o => o.ShowConfirmationDialogAsync(It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult(true)); vm.DialogService = dialog.Object; var label = vm.CustomLabels[0]; await vm.RemoveLabelCommand.ExecuteAsync(label); vm.CancelEdit(); Assert.AreEqual(1, vm.CustomLabels.Count); Assert.AreEqual(label, vm.CustomLabels[0]); host.Verify(o => o.RemoveCustomTextLabel(label), Times.Once); }