public void OnNavigatedTo(NavigationContext navigationContext)
        {
            ViewModel = (GeotagFileBrowserViewModel)navigationContext.Parameters["viewModel"];
            DataContext = ViewModel;

            ViewModel.OnNavigatedTo(navigationContext);   
        }
Example #2
0
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            ViewModel   = (GeotagFileBrowserViewModel)navigationContext.Parameters["viewModel"];
            DataContext = ViewModel;

            ViewModel.OnNavigatedTo(navigationContext);
        }
        public MediaFileBrowserViewModel(MediaFileWatcher mediaFileWatcher, IRegionManager regionManager, IEventAggregator eventAggregator)
        {
    
            MediaFileWatcher = mediaFileWatcher;
            RegionManager = regionManager;
            EventAggregator = eventAggregator;
          
            MediaFileGridViewModel = new MediaFileGridViewModel(mediaFileWatcher.MediaFileState, EventAggregator);
       
            ImageViewModel = new MediaFileBrowserImagePanelViewModel(eventAggregator);
            ImageViewModel.SelectedScaleMode = MediaViewer.UserControls.ImagePanel.ScaleMode.FIT_HEIGHT_AND_WIDTH;

            imageMediaStackPanelViewModel = new MediaFileStackPanelViewModel(MediaFileGridViewModel.MediaStateCollectionView, EventAggregator);            
            imageMediaStackPanelViewModel.IsVisible = true;

            VideoViewModel = new VideoPanel.VideoViewModel(EventAggregator);

            videoMediaStackPanelViewModel = new MediaFileStackPanelViewModel(MediaFileGridViewModel.MediaStateCollectionView, EventAggregator);            
            videoMediaStackPanelViewModel.IsVisible = true;

            GeotagFileBrowserViewModel = new GeotagFileBrowserViewModel(MediaFileGridViewModel.MediaStateCollectionView, EventAggregator);

            GeotagFileBrowserStackPanelViewModel = new MediaFileStackPanelViewModel(MediaFileGridViewModel.MediaStateCollectionView, EventAggregator);
            GeotagFileBrowserStackPanelViewModel.IsVisible = true;
                       
            DeleteSelectedItemsCommand = new Command(new Action(deleteSelectedItems));
      
            ImportSelectedItemsCommand = new Command(() =>
            {          
                ImportView import = new ImportView();
                import.DataContext = new ImportViewModel(MediaFileWatcher.Instance);
                import.ShowDialog();          
            });

            ExportSelectedItemsCommand = new Command(() =>
            {
                ImportView export = new ImportView();
                export.DataContext = new ExportViewModel(MediaFileWatcher.Instance);
                export.ShowDialog();
              
            });

            ExpandCommand = new Command<MediaFileItem>((item) =>
            {              
                if (item == null)
                {                   
                    if (SelectedItems.Count == 0) return;

                    item = SelectedItems.ElementAt(0) as MediaFileItem;
                }

                if (item.Metadata is ImageMetadata)
                {
                    navigateToImageView(item);
                }
                else if (item.Metadata is VideoMetadata ||
                    item.Metadata is AudioMetadata)
                {
                    navigateToVideoView(item);
                }
             
                
            });

            ContractCommand = new Command(() =>
                {
                    NavigateBackCommand.Execute(null);
                   
                });

            ContractCommand.IsExecutable = false;

            NavigateToGeotagFileBrowserCommand = new Command(() =>
                {
                    navigateToGeotagFileBrowser();
                   
                });

            CreateImageCollageCommand = new Command(() =>
            {
                if (SelectedItems.Count == 0) return;

                ImageCollageView collage = new ImageCollageView();

                collage.ViewModel.Media = SelectedItems;
                collage.ShowDialog();
            });

            TranscodeVideoCommand = new Command(() =>
            {
                if (SelectedItems.Count == 0) return;

                VideoTranscodeView transcode = new VideoTranscodeView();
                List<VideoAudioPair> items = new List<VideoAudioPair>();
                foreach (MediaItem item in SelectedItems)
                {
                    items.Add(new VideoAudioPair(item));
                }

                transcode.ViewModel.Items = items;
                transcode.ViewModel.OutputPath = MediaFileWatcher.Path;

                transcode.ShowDialog();
            });

            TranscodeImageCommand = new Command(() =>
            {
                if (SelectedItems.Count == 0) return;

                ImageTranscodeView transcode = new ImageTranscodeView();
                transcode.ViewModel.Items = SelectedItems;
                transcode.ViewModel.OutputPath = MediaFileWatcher.Path;

                transcode.ShowDialog();
            });

            CreateVideoPreviewImagesCommand = new Command(() =>
                {                 
                    if (SelectedItems.Count == 0) return;

                    VideoPreviewImageView preview = new VideoPreviewImageView();
                    
                    preview.ViewModel.Media = SelectedItems;
                    preview.ShowDialog();
                });
      
            CreateTorrentFileCommand = new Command(() =>
                {
               
                    //if (SelectedItems.Count == 0) return;

                    try
                    {
                        TorrentCreationView torrent = new TorrentCreationView();

                        torrent.ViewModel.PathRoot = mediaFileWatcher.Path;
                        torrent.ViewModel.Media = new ObservableCollection<MediaFileItem>(SelectedItems);
                        
                        torrent.ShowDialog();
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                });
  
            
           
            NavigateToMediaFileGridCommand = new Command(navigateToMediaFileGrid);
            NavigateToImageViewCommand = new Command<MediaFileItem>(navigateToImageView);
            NavigateToVideoViewCommand = new Command<MediaFileItem>(navigateToVideoView);

            NavigateBackCommand = NavigateToMediaFileGridCommand;

            SelectedItems = new List<MediaFileItem>();

            EventAggregator.GetEvent<MediaSelectionEvent>().Subscribe(mediaFileBrowser_MediaSelectionEvent);
            
        }