Esempio n. 1
0
        public PlayControlViewModel(Dispatcher dispatcher, SMPSettings settings, PlaylistsViewModel playlistsViewModel, MedialibViewModel medialibViewModel)
        {
            this.playlistsViewModel = playlistsViewModel;
            this.medialibViewModel  = medialibViewModel;

            this.SMPSettings = settings;

            this.PlayerEngine.PlayNextFileAction = () => {
                if (this.SMPSettings.PlayerSettings.RepeatMode)
                {
                    if (this.CanPlayOrPause())
                    {
                        var file = this.playlistsViewModel.GetCurrentPlayListFile();
                        if (file != null)
                        {
                            this.PlayerEngine.Play(file);
                        }
                    }
                }
                else
                {
                    if (this.CanPlayNext())
                    {
                        this.PlayNext();
                    }
                }
            };
        }
    public PlayControlViewModel(Dispatcher dispatcher, SMPSettings settings, PlaylistsViewModel playlistsViewModel, MedialibViewModel medialibViewModel) {
      this.playlistsViewModel = playlistsViewModel;
      this.medialibViewModel = medialibViewModel;

      this.SMPSettings = settings;

      this.PlayerEngine.PlayNextFileAction = () => {
                                               if (this.SMPSettings.PlayerSettings.RepeatMode) {
                                                 if (this.CanPlayOrPause()) {
                                                   var file = this.playlistsViewModel.GetCurrentPlayListFile();
                                                   if (file != null) {
                                                     this.PlayerEngine.Play(file);
                                                   }
                                                 }
                                               } else {
                                                 if (this.CanPlayNext()) {
                                                   this.PlayNext();
                                                 }
                                               }
                                             };
    }
    public MedialibView(MedialibViewModel medialibViewModel) {
      this.DataContext = medialibViewModel;

      this.InitializeComponent();

      this.AllowDrop = true;

      this.SourceInitialized += (sender, e) => this.FitIntoScreen();

      this.Closed += (sender, e) => {
                       var viewModel = ((MedialibViewModel)this.DataContext);
                       if (viewModel.FileSearchWorker.CanStopSearch()) {
                         viewModel.FileSearchWorker.StopSearch();
                       }
                     };

      // Override this to allow drop functionality.
      DragEventHandler previewDragOver = (sender, e) => {
                                           if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
                                             var viewModel = (MedialibViewModel)this.DataContext;
                                             e.Effects = viewModel.FileSearchWorker.CanStartSearch() ? DragDropEffects.Copy : DragDropEffects.None;
                                           } else {
                                             e.Effects = DragDropEffects.None;
                                           }
                                           e.Handled = true;
                                         };
      this.PreviewDragOver += previewDragOver;
      this.PreviewDragEnter += previewDragOver;
      this.PreviewDrop += (sender, e) => {
                            if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
                              var viewModel = (MedialibViewModel)this.DataContext;
                              // Get data object
                              var dataObject = e.Data as DataObject;
                              if (dataObject != null && dataObject.ContainsFileDropList()) {
                                viewModel.HandleDropAction(dataObject.GetFileDropList());
                              }
                            }
                          };
    }