public ImageTranscodeViewModel()
        {
            OkCommand = new Command(async () =>
            {
                CancellableOperationProgressView progress = new CancellableOperationProgressView();
                ImageTranscodeProgressViewModel vm = new ImageTranscodeProgressViewModel(this);
                progress.DataContext = vm;              

                Task task = vm.startTranscodeAsync();
                progress.Show();
                OnClosingRequest();
                await task;

                MiscUtils.insertIntoHistoryCollection(Settings.Default.ImageTranscodeOutputDirectoryHistory, OutputPath);
            });


            DefaultsCommand = new Command(() =>
            {
                setDefaults();
            });

            CancelCommand = new Command(() =>
            {
                OnClosingRequest();
            });

            DirectoryPickerCommand = new Command(() =>
            {
                DirectoryPickerView directoryPicker = new DirectoryPickerView();
                DirectoryPickerViewModel vm = (DirectoryPickerViewModel)directoryPicker.DataContext;
                vm.InfoString = "Select Transcode Output Path";
                vm.SelectedPath = OutputPath;
                vm.PathHistory = OutputPathHistory;

                if (directoryPicker.ShowDialog() == true)
                {
                    OutputPath = vm.SelectedPath;
                }

            });

            OutputPathHistory = Settings.Default.ImageTranscodeOutputDirectoryHistory;            
            OutputFormatCollectionView = new ListCollectionView(outFormats);
            JpegRotationCollectionView = new ListCollectionView(Enum.GetNames(typeof(Rotation)));
            PngInterlacingCollectionView = new ListCollectionView(Enum.GetNames(typeof(PngInterlaceOption)));
            TiffCompressionCollectionView = new ListCollectionView(Enum.GetNames(typeof(TiffCompressOption)));

            setDefaults();
        }
예제 #2
0
        public ImageCollageViewModel(MediaFileWatcher mediaFileWatcher)
        {                      
            setDefaults(mediaFileWatcher);
           
            directoryPickerCommand = new Command(new Action(() =>
            {
                DirectoryPickerView directoryPicker = new DirectoryPickerView();
                DirectoryPickerViewModel vm = (DirectoryPickerViewModel)directoryPicker.DataContext;
                vm.SelectedPath = OutputPath;
                vm.PathHistory = OutputPathHistory;

                if (directoryPicker.ShowDialog() == true)
                {
                    OutputPath = vm.SelectedPath;
                }

            }));

            OkCommand = new Command(async () =>
            {
                CancellableOperationProgressView progress = new CancellableOperationProgressView();
                using (ImageCollageProgressViewModel vm = new ImageCollageProgressViewModel())
                {
                    progress.DataContext = vm;
                    vm.AsyncState = this;
                    progress.Show();
                    Task task = vm.generateImage();
                    OnClosingRequest();
                    await task;
                    MiscUtils.insertIntoHistoryCollection(OutputPathHistory, OutputPath);
                }
            });
            CancelCommand = new Command(() =>
            {
                OnClosingRequest();
            });

            DefaultsCommand = new Command(() =>
            {
                setDefaults(mediaFileWatcher);
            });
        }
        public TorrentCreationViewModel()
        {
            
            IsPrivate = false;                     
            IsCommentEnabled = false;

            OutputPathHistory = new ObservableCollection<string>();
            InputPathHistory = new ObservableCollection<string>();

            AnnounceURLHistory = Settings.Default.TorrentAnnounceHistory;
            if (AnnounceURLHistory.Count > 0)
            {
                AnnounceURL = AnnounceURLHistory[0];
            }

            InputDirectoryPickerCommand = new Command(new Action(async () =>
            {
                DirectoryPickerView directoryPicker = new DirectoryPickerView();
                DirectoryPickerViewModel vm = (DirectoryPickerViewModel)directoryPicker.DataContext;
                vm.SelectedPath = String.IsNullOrEmpty(InputPath) ? PathRoot : InputPath;
                vm.PathHistory = InputPathHistory;

                if (directoryPicker.ShowDialog() == true)
                {                    
                    InputPath = vm.SelectedPath;
                    TorrentName = Path.GetFileName(InputPath);

                    ScanFilesViewModel scanFilesViewModel = new ScanFilesViewModel();
                    NonCancellableOperationProgressView progressView = new NonCancellableOperationProgressView();
                    progressView.DataContext = scanFilesViewModel;

                    ObservableCollection<MediaFileItem> items = new ObservableCollection<MediaFileItem>();

                    await Task.Factory.StartNew(() =>
                    {
                        App.Current.Dispatcher.BeginInvoke(new Action(() => {

                            progressView.ShowDialog();

                        }));

                        try
                        {
                            items = scanFilesViewModel.getInputMedia(InputPath);
                        }
                        catch (Exception e)
                        {
                            Logger.Log.Error("Error reading: " + inputPath, e);
                            MessageBox.Show("Error reading: " + inputPath + "\n\n" + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        finally
                        {
                            Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                            {
                                progressView.Close();
                            }));
                        }
                    });                                              

                    Media = items;                                      
                }

            }));

            OutputDirectoryPickerCommand = new Command(new Action(() =>
            {
                DirectoryPickerView directoryPicker = new DirectoryPickerView();
                DirectoryPickerViewModel vm = (DirectoryPickerViewModel)directoryPicker.DataContext;
                vm.SelectedPath = OutputPath;
                vm.PathHistory = OutputPathHistory;

                if (directoryPicker.ShowDialog() == true)
                {
                    OutputPath = vm.SelectedPath;
                }

            }));

            CancelCommand = new Command(() =>
            {
                OnClosingRequest();
            });

            OkCommand = new Command(async () =>
                {
                    CancellableOperationProgressView progress = new CancellableOperationProgressView();
                    TorrentCreationProgressViewModel vm = new TorrentCreationProgressViewModel();
                    progress.DataContext = vm;
                    Task task = vm.createTorrentAsync(this);
                    progress.Show();                    
                    OnClosingRequest();
                    await task;
                                                                     
                });
        }
예제 #4
0
        public ImageSearchViewModel()           
        {                   
            NrColumns = 4;

            SearchCommand = new AsyncCommand<int>(async (imageOffset) =>
            {
                try
                {
                    if (imageOffset == 0)
                    {
                        CurrentQuery = new ImageSearchQuery(this);
                    }

                    SearchCommand.IsExecutable = false;
                    await doSearch(CurrentQuery, imageOffset);
                }
                catch (Exception e)
                {
                    MessageBox.Show("Image search error\n\n" + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                finally
                {
                    SearchCommand.IsExecutable = true;
                }
            });

            ViewCommand = new Command<SelectableMediaItem>((selectableItem) =>
                {
                    ImageResultItem item = (ImageResultItem)selectableItem.Item;
                    
                    if(item.ImageInfo.ContentType.Equals("image/animatedgif")) {

                        Shell.ShellViewModel.navigateToVideoView(item);  

                    } else {

                        Shell.ShellViewModel.navigateToImageView(item);     
                    }
                });

            ViewSourceCommand = new Command<SelectableMediaItem>((selectableItem) =>
                {
                    ImageResultItem item = (ImageResultItem)selectableItem.Item;

                    Process.Start(item.ImageInfo.SourceUrl);
                });

            SelectAllCommand = new Command(() =>
            {
                MediaStateCollectionView.selectAll();
            }, false);

            DeselectAllCommand = new Command(() =>
            {
                MediaStateCollectionView.deselectAll();
            });

            CloseCommand = new Command(() =>
            {             
                OnClosingRequest();
            });

            DownloadCommand = new AsyncCommand<SelectableMediaItem>(async (selectableItem) =>
                {
                    List<MediaItem> items = MediaStateCollectionView.getSelectedItems();
                    if (items.Count == 0)
                    {
                        items.Add(selectableItem.Item);
                    }

                    String outputPath = null;

                    switch (ImageSearchPlugin.Properties.Settings.Default.ImageSaveMode)
                    {
                        case MediaViewer.Infrastructure.Constants.SaveLocation.Current:
                            {
                                outputPath = MediaFileWatcher.Instance.Path;
                                break;
                            }
                        case MediaViewer.Infrastructure.Constants.SaveLocation.Ask:
                            {
                                DirectoryPickerView directoryPicker = new DirectoryPickerView();
                                directoryPicker.DirectoryPickerViewModel.InfoString = "Select Output Directory";
                                directoryPicker.DirectoryPickerViewModel.SelectedPath = MediaFileWatcher.Instance.Path;

                                if (directoryPicker.ShowDialog() == false)
                                {
                                    return;
                                }

                                outputPath = directoryPicker.DirectoryPickerViewModel.SelectedPath;

                                break;
                            }
                        case MediaViewer.Infrastructure.Constants.SaveLocation.Fixed:
                            {
                                outputPath = ImageSearchPlugin.Properties.Settings.Default.FixedDownloadPath;
                                break;
                            }
                        default:
                            break;
                    }

                    CancellableOperationProgressView progressView = new CancellableOperationProgressView();
                    DownloadProgressViewModel vm = new DownloadProgressViewModel();
                    progressView.DataContext = vm;

                    progressView.Show();
                    vm.OkCommand.IsExecutable = false;
                    vm.CancelCommand.IsExecutable = true;

                    try
                    {
                        await Task.Factory.StartNew(() =>
                        {
                            vm.startDownload(outputPath, items);

                        }, vm.CancellationToken);

                    }
                    catch (Exception)
                    {

                    }

                    vm.OkCommand.IsExecutable = true;
                    vm.CancelCommand.IsExecutable = false;
                });

            SettingsViewModel = (ImageSearchSettingsViewModel)ServiceLocator.Current.GetInstance(typeof(ImageSearchSettingsViewModel));
           
            Size = new ListCollectionView(size);
            Size.MoveCurrentTo(Settings.Default.Size);
            SafeSearch = new ListCollectionView(safeSearch);
            SafeSearch.MoveCurrentTo(Settings.Default.SafeSearch);
            Layout = new ListCollectionView(layout);
            Layout.MoveCurrentTo(Settings.Default.Layout);
            Type = new ListCollectionView(type);
            Type.MoveCurrentTo(Settings.Default.Type);
            People = new ListCollectionView(people);
            People.MoveCurrentTo(Settings.Default.People);
            Color = new ListCollectionView(color);
            Color.MoveCurrentTo(Settings.Default.Color);

            GeoTag = new GeoTagCoordinatePair();

            MediaState = new MediaState();

            MediaStateCollectionView = new ImageResultCollectionView(MediaState);        
            MediaStateCollectionView.MediaState.MediaStateType = MediaStateType.SearchResult;

            WeakEventManager<MediaLockedCollection, EventArgs>.AddHandler(MediaStateCollectionView.MediaState.UIMediaCollection, "IsLoadingChanged", mediaCollection_IsLoadingChanged);
            
        }
예제 #5
0
        public MetaDataViewModel(MediaFileWatcher mediaFileWatcher, IEventAggregator eventAggregator)
        {            
            //Items = new ObservableCollection<MediaFileItem>();
            itemsLock = new Object();

            DynamicProperties = new ObservableCollection<Tuple<string, string>>();
            BindingOperations.EnableCollectionSynchronization(DynamicProperties, itemsLock);

            EventAggregator = eventAggregator;

            Tags = new ObservableCollection<Tag>();
            tagsLock = new Object();
            BindingOperations.EnableCollectionSynchronization(Tags, tagsLock);      

            AddTags = new ObservableCollection<Tag>();
            addTagsLock = new Object();
            BindingOperations.EnableCollectionSynchronization(AddTags, addTagsLock);

            RemoveTags = new ObservableCollection<Tag>();
            removeTagsLock = new Object();
            BindingOperations.EnableCollectionSynchronization(RemoveTags, removeTagsLock);

            MetaDataPresets = new ObservableCollection<PresetMetadata>();

            loadMetaDataPresets();

            clear();
            BatchMode = false;
            IsEnabled = false;
            IsReadOnly = true;

            WriteMetaDataCommand = new AsyncCommand(async () =>
            {
                CancellableOperationProgressView metaDataUpdateView = new CancellableOperationProgressView();
                MetaDataUpdateViewModel vm = new MetaDataUpdateViewModel(mediaFileWatcher, EventAggregator);
                metaDataUpdateView.DataContext = vm;
                metaDataUpdateView.Show();             
                await vm.writeMetaDataAsync(new MetaDataUpdateViewModelAsyncState(this));

            });

            FilenamePresetsCommand = new Command(() =>
            {
                FilenameRegexView filenamePreset = new FilenameRegexView();
                FilenameRegexViewModel vm = (FilenameRegexViewModel)filenamePreset.DataContext;

                if (filenamePreset.ShowDialog() == true)
                {
                    if (!vm.SelectedRegex.IsEmpty)
                    {
                        Filename = vm.SelectedRegex.Regex;
                        ReplaceFilename = vm.SelectedRegex.Replace;
                    }
                }

            }); 

            DirectoryPickerCommand = new Command(() => 
            {
                DirectoryPickerView directoryPicker = new DirectoryPickerView();
                DirectoryPickerViewModel vm = (DirectoryPickerViewModel)directoryPicker.DataContext;
                vm.SelectedPath = String.IsNullOrEmpty(Location) ? mediaFileWatcher.Path : Location;
                lock (Items)
                {
                    vm.SelectedItems = new List<MediaFileItem>(Items);
                }
                vm.PathHistory = Settings.Default.MetaDataUpdateDirectoryHistory;
              
                if (directoryPicker.ShowDialog() == true)
                {                    
                    Location = vm.SelectedPath;                    
                }

            });

            MetaDataPresetsCommand = new Command(() =>
                {
                    MetaDataPresetsView metaDataPresets = new MetaDataPresetsView();
                    metaDataPresets.ShowDialog();
                    loadMetaDataPresets();                    

                });

            ClearRatingCommand = new Command(() =>
                {
                    Rating = null;
                });

           
         

            mediaFileWatcher.MediaFileState.ItemPropertyChanged += MediaState_ItemPropertiesChanged;
          
            FilenameHistory = Settings.Default.FilenameHistory;
            ReplaceFilenameHistory = Settings.Default.ReplaceFilenameHistory;

            MovePathHistory = Settings.Default.MetaDataUpdateDirectoryHistory;

            FavoriteLocations = Settings.Default.FavoriteLocations;

            IsRegexEnabled = false;
            ReplaceFilename = "";
        }
        public VideoTranscodeViewModel()
        {

            OutputPathHistory = Settings.Default.TranscodeOutputDirectoryHistory;

            OkCommand = new Command(async () =>
                {                    
                    CancellableOperationProgressView progress = new CancellableOperationProgressView();
                    VideoTranscodeProgressViewModel vm = new VideoTranscodeProgressViewModel(this);
                    progress.DataContext = vm;
                    vm.WindowIcon = IconUri;

                    Task task = vm.startTranscodeAsync();
                    progress.Show();
                    OnClosingRequest();
                    await task;

                    MiscUtils.insertIntoHistoryCollection(Settings.Default.TranscodeOutputDirectoryHistory, OutputPath);
                });


            DefaultsCommand = new Command(() =>
                {
                    setDefaults();
                });

            CancelCommand = new Command(() =>
            {
                OnClosingRequest();
            });

            DirectoryPickerCommand = new Command(() =>
                {
                    DirectoryPickerView directoryPicker = new DirectoryPickerView();
                    DirectoryPickerViewModel vm = (DirectoryPickerViewModel)directoryPicker.DataContext;
                    vm.InfoString = "Select Transcode Output Path";
                    vm.SelectedPath = OutputPath;
                    vm.PathHistory = OutputPathHistory;

                    if (directoryPicker.ShowDialog() == true)
                    {
                        OutputPath = vm.SelectedPath;
                    }

                });

            SupportedAudioEncoders = new ListCollectionView(Enum.GetValues(typeof(AudioEncoders)));
            SupportedAudioEncoders.Filter = supportedAudioEncodersFilter;
            SupportedVideoEncoders = new ListCollectionView(Enum.GetValues(typeof(VideoEncoders)));
            SupportedVideoEncoders.Filter = supportedVideoEncodersFilter;

            Items = new List<VideoAudioPair>();
            Title = "Transcode Video(s)";
            IconUri = "/MediaViewer;component/Resources/Icons/videofile.ico";

            setDefaults();

            IsTimeRangeEnabled = false;
            StartTimeRange = 0;
            EndTimeRange = 0;
        }
예제 #7
0
        public ImportViewModel(MediaFileWatcher mediaFileWatcher)
        {
            Title = "Import Media";
            
            OkCommand = new Command(async () =>
            {
                CancellableOperationProgressView progress = new CancellableOperationProgressView();
                ImportProgressViewModel vm = new ImportProgressViewModel(mediaFileWatcher.MediaFileState);
                progress.DataContext = vm;
                progress.Show();
                Task t = vm.importAsync(IncludeLocations, ExcludeLocations);
                OnClosingRequest();
                await t;
            });
          
            CancelCommand = new Command(() =>
                {
                    OnClosingRequest();
                });
          
            IncludeLocations = new ObservableCollection<ScanLocation>();

            IncludeLocations.Add(new ScanLocation(mediaFileWatcher.Path));

            AddIncludeLocationCommand = new Command(new Action(() =>
            {
                DirectoryPickerView directoryPicker = new DirectoryPickerView();
                DirectoryPickerViewModel vm = (DirectoryPickerViewModel)directoryPicker.DataContext;

                if (SelectedIncludeLocation == null)
                {
                    vm.SelectedPath = mediaFileWatcher.Path;
                }
                else
                {
                    vm.SelectedPath = SelectedIncludeLocation.Location;
                }

                if (directoryPicker.ShowDialog() == true)
                {
                    ScanLocation newLocation = new ScanLocation(vm.SelectedPath);
                    if (!IncludeLocations.Contains(newLocation))
                    {
                        IncludeLocations.Add(newLocation);
                    }
                }

                if (IncludeLocations.Count > 0)
                {
                    OkCommand.IsExecutable = true;
                }
               
            }));

            RemoveIncludeLocationCommand = new Command(new Action(() =>
                {
                    for (int i = IncludeLocations.Count() - 1; i >= 0; i--)
                    {
                        if (IncludeLocations[i].IsSelected == true)
                        {
                            IncludeLocations.RemoveAt(i);
                        }
                    }

                    if (IncludeLocations.Count == 0)
                    {
                        OkCommand.IsExecutable = false;
                    }
                }));

            ClearIncludeLocationsCommand = new Command(new Action(() =>
            {
                IncludeLocations.Clear();
                OkCommand.IsExecutable = false;
            }));

            ExcludeLocations = new ObservableCollection<ScanLocation>();
       
            AddExcludeLocationCommand = new Command(new Action(() =>
            {
                DirectoryPickerView directoryPicker = new DirectoryPickerView();
                DirectoryPickerViewModel vm = (DirectoryPickerViewModel)directoryPicker.DataContext;

                if (SelectedExcludeLocation == null)
                {
                    vm.SelectedPath = mediaFileWatcher.Path;
                }
                else
                {
                    vm.SelectedPath = SelectedExcludeLocation.Location;
                }

                if (directoryPicker.ShowDialog() == true)
                {
                    ScanLocation newLocation = new ScanLocation(vm.SelectedPath);
                    if (!ExcludeLocations.Contains(newLocation))
                    {
                        ExcludeLocations.Add(newLocation);
                    }
                }
          
            }));

            RemoveExcludeLocationCommand = new Command(new Action(() =>
            {
                for (int i = ExcludeLocations.Count() - 1; i >= 0; i--)
                {
                    if (ExcludeLocations[i].IsSelected == true)
                    {
                        ExcludeLocations.RemoveAt(i);
                    }
                }
             
            }));

            ClearExcludeLocationsCommand = new Command(new Action(() =>
            {
                ExcludeLocations.Clear();             
            }));
        }
예제 #8
0
        private async Task clearMedia()
        {
            MessageBoxResult result = MessageBox.Show("Are you sure you want to clear all Media from the database?", "Clear All Media", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
            if (result == MessageBoxResult.No) return;

            List<BaseMetadata> media;

            using (MetadataDbCommands mediaCommands = new MetadataDbCommands())
            {
                media = mediaCommands.getAllMetadata();
            }

            List<MediaFileItem> items = new List<MediaFileItem>();

            foreach (BaseMetadata m in media)
            {
                items.Add(MediaFileItem.Factory.create(m.Location));
            }

            ExportProgressViewModel export = new ExportProgressViewModel(MediaFileWatcher.Instance.MediaFileState);

            CancellableOperationProgressView exportView = new CancellableOperationProgressView();
            exportView.DataContext = export;
            exportView.ShowDialog();
            await export.exportAsync(items);

            NrMedia = 0;
        }
예제 #9
0
        void clearTags()
        {
            MessageBoxResult result = MessageBox.Show("Are you sure you want to clear all unused Tags from the database?", "Clear All Unused Tags", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
            if (result == MessageBoxResult.No) return;

            CancellableOperationProgressView clearView = new CancellableOperationProgressView();
            TagOperationsViewModel vm = new TagOperationsViewModel();
            clearView.DataContext = vm;
            Task.Run(() => vm.clear());
            clearView.ShowDialog();
            NrTags = 0;

        }
예제 #10
0
        private void importTags()
        {
            OpenFileDialog loadTagsDialog = MediaViewer.Model.Utils.Windows.FileDialog.createLoadTagsFileDialog();
            if (loadTagsDialog.ShowDialog() == false) return;

            CancellableOperationProgressView importView = new CancellableOperationProgressView();
            TagOperationsViewModel vm = new TagOperationsViewModel();
            importView.DataContext = vm;
            Task.Run(() => vm.import(loadTagsDialog.FileName));
            importView.ShowDialog();
            NrTags = 0;           
        }
예제 #11
0
        private void exportTags()
        {
            SaveFileDialog saveTagsDialog = MediaViewer.Model.Utils.Windows.FileDialog.createSaveTagsFileDialog();
            if (saveTagsDialog.ShowDialog() == false) return;

            CancellableOperationProgressView exportView = new CancellableOperationProgressView();
            TagOperationsViewModel vm = new TagOperationsViewModel();
            exportView.DataContext = vm;
            Task.Run(() => vm.export(saveTagsDialog.FileName));                      
            exportView.ShowDialog();           
        }
예제 #12
0
        public YoutubeViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
        {
            TokenSource = new CancellationTokenSource();
            
            RegionManager = regionManager;
            EventAggregator = eventAggregator;
            NrColumns = 4;

            MediaState = new MediaState();
            MediaStateCollectionView = new YoutubeCollectionView(MediaState);
            MediaState.clearUIState("Empty", DateTime.Now, MediaStateType.SearchResult);

            MediaStateCollectionView.SelectionChanged += mediaStateCollectionView_SelectionChanged;
                        
            ViewCommand = new Command<SelectableMediaItem>((selectableItem) =>
            {               
                if(selectableItem.Item.Metadata == null) return;

                if (selectableItem.Item is YoutubeVideoItem)
                {
                    YoutubeVideoItem item = selectableItem.Item as YoutubeVideoItem;

                    if (item.IsEmbeddedOnly)
                    {
                        Process.Start("https://www.youtube.com/watch?v=" + item.VideoId);
                    }
                    else
                    {
                        YoutubeVideoStreamedItem video, audio;
                        item.getStreams(out video, out audio, (int)Properties.Settings.Default.MaxPlaybackResolution);

                        Shell.ShellViewModel.navigateToVideoView(video, null, audio);
                    }
                }
                               
            });

            ViewChannelCommand = new AsyncCommand<SelectableMediaItem>(async (selectableItem) =>
            {
                if (selectableItem.Item.Metadata == null) return;

                YoutubeItem item = selectableItem.Item as YoutubeItem;

                SearchResource.ListRequest searchListRequest = Youtube.Search.List("snippet");
                searchListRequest.ChannelId = item.ChannelId;
                searchListRequest.MaxResults = YoutubeSearchViewModel.maxResults;
                searchListRequest.Order = Google.Apis.YouTube.v3.SearchResource.ListRequest.OrderEnum.Date;

                MediaStateCollectionView.FilterModes.MoveCurrentToFirst();

                await searchAsync(searchListRequest, item.ChannelTitle, false);
                
            });

            ViewPlaylistCommand = new AsyncCommand<SelectableMediaItem>(async (selectableItem) =>
                {
                    if (selectableItem.Item.Metadata == null) return;

                    YoutubePlaylistItem item = selectableItem.Item as YoutubePlaylistItem;

                    PlaylistItemsResource.ListRequest searchListRequest = Youtube.PlaylistItems.List("snippet");
                    searchListRequest.PlaylistId = item.PlaylistId;
                    searchListRequest.MaxResults = YoutubeSearchViewModel.maxResults;

                    MediaStateCollectionView.FilterModes.MoveCurrentToFirst();

                    await searchAsync(searchListRequest, item.Name, false);
                                        
                });

            SubscribeCommand = new Command<SelectableMediaItem>((selectableItem) =>
                {
                    YoutubeChannelItem item = selectableItem.Item as YoutubeChannelItem;

                    EventAggregator.GetEvent<AddFavoriteChannelEvent>().Publish(item);
                });

            DownloadCommand = new AsyncCommand<SelectableMediaItem>(async (selectableItem) => {

                List<MediaItem> items = MediaStateCollectionView.getSelectedItems();
                if (items.Count == 0)
                {
                    items.Add(selectableItem.Item);
                }

                String outputPath = null;

                switch (YoutubePlugin.Properties.Settings.Default.VideoSaveMode)
                {
                    case MediaViewer.Infrastructure.Constants.SaveLocation.Current:
                        {
                            outputPath = MediaFileWatcher.Instance.Path;
                            break;
                        }
                    case MediaViewer.Infrastructure.Constants.SaveLocation.Ask:
                        {
                            DirectoryPickerView directoryPicker = new DirectoryPickerView();
                            directoryPicker.DirectoryPickerViewModel.InfoString = "Select Output Directory";
                            directoryPicker.DirectoryPickerViewModel.SelectedPath = MediaFileWatcher.Instance.Path;

                            if (directoryPicker.ShowDialog() == false)
                            {
                                return;
                            }

                            outputPath = directoryPicker.DirectoryPickerViewModel.SelectedPath;

                            break;
                        }
                    case MediaViewer.Infrastructure.Constants.SaveLocation.Fixed:
                        {
                            outputPath = YoutubePlugin.Properties.Settings.Default.FixedDownloadPath;
                            break;
                        }
                    default:
                        break;
                }

                CancellableOperationProgressView progressView = new CancellableOperationProgressView();
                DownloadProgressViewModel vm = new DownloadProgressViewModel();
                progressView.DataContext = vm;

                progressView.Show();
                vm.OkCommand.IsExecutable = false;
                vm.CancelCommand.IsExecutable = true;

                await Task.Factory.StartNew(() =>
                {
                    vm.startDownload(outputPath, items);
                });

                vm.OkCommand.IsExecutable = true;
                vm.CancelCommand.IsExecutable = false;
                        
            });

            LoadNextPageCommand = new AsyncCommand(async () =>
            {                        
                await searchAsync(CurrentQuery, "", true);       
            });

            SelectAllCommand = new Command(() =>
            {
                MediaStateCollectionView.selectAll();
            }, false);

            DeselectAllCommand = new Command(() =>
            {
                MediaStateCollectionView.deselectAll();
            });

            ShutdownCommand = new Command(() =>
                {
                    Properties.Settings.Default.Save();
                });

            MediaState.UIMediaCollection.IsLoadingChanged += UIMediaCollection_IsLoadingChanged;

            MediaViewer.Model.Global.Commands.GlobalCommands.ShutdownCommand.RegisterCommand(ShutdownCommand);

            setupViews();

            EventAggregator.GetEvent<SearchEvent>().Subscribe(searchEvent);

            SearchTask = null;
        }