コード例 #1
0
ファイル: MainControl.cs プロジェクト: RicjFonZ/audio-band
        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>()
            });
        }
コード例 #2
0
        /// <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;
        }
コード例 #3
0
 private void InitializeBindingSources(
     AlbumArtPopupVM albumArtPopupVm,
     AlbumArtVM albumartVm,
     AudioBandVM audioBandVm,
     NextButtonVM nextButtonVm,
     PlayPauseButtonVM playPauseButtonVm,
     PreviousButtonVM previousButtonVm,
     ProgressBarVM progressBarVm)
 {
     AlbumArtPopupVMBindingSource.DataSource   = albumArtPopupVm;
     AlbumArtVMBindingSource.DataSource        = albumartVm;
     AudioBandVMBindingSource.DataSource       = audioBandVm;
     NextButtonVMBindingSource.DataSource      = nextButtonVm;
     PlayPauseButtonVMBindingSource.DataSource = playPauseButtonVm;
     PreviousButtonVMBindingSource.DataSource  = previousButtonVm;
     ProgressBarVMBindingSource.DataSource     = progressBarVm;
 }
コード例 #4
0
ファイル: MainControl.cs プロジェクト: break7533/audio-band
        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
            });
        }