public SearchViewModel(MediaFileWatcher mediaFileWatcher) { MediaFileWatcher = mediaFileWatcher; RecurseSubDirectories = false; Query = new SearchQuery(); SearchCommand = new AsyncCommand <SearchQuery>(async(query) => { SearchCommand.IsExecutable = false; await Task.Run(() => doSearch(query)); SearchCommand.IsExecutable = true; }); ClearRatingStartCommand = new Command(new Action(() => { Query.RatingStart = null; })); ClearRatingEndCommand = new Command(new Action(() => { Query.RatingEnd = null; })); }
public ShellViewModel(MediaFileWatcher mediaFileWatcher, IRegionManager regionManager, IEventAggregator eventAggregator) { RegionManager = regionManager; EventAggregator = eventAggregator; ImageViewModel = new ImagePanel.ImageViewModel(eventAggregator); ImageViewModel.SelectedScaleMode = UserControls.ImagePanel.ScaleMode.UNSCALED; imageMediaStackPanelViewModel = new MediaFileStackPanelViewModel(MediaFileWatcher.Instance.MediaFileState, EventAggregator); imageMediaStackPanelViewModel.MediaStateCollectionView.FilterModes.MoveCurrentTo(MediaFilterMode.Images); VideoViewModel = new VideoPanel.VideoViewModel(EventAggregator); videoMediaStackPanelViewModel = new MediaFileStackPanelViewModel(MediaFileWatcher.Instance.MediaFileState, EventAggregator); videoMediaStackPanelViewModel.MediaStateCollectionView.FilterModes.MoveCurrentTo(MediaFilterMode.Video); MediaFileBrowserViewModel = new MediaFileBrowserViewModel(mediaFileWatcher, regionManager, eventAggregator); VideoPlayerViewModel.setLibAVLogCallback(Logger.Log); VideoPlayerViewModel.enableLibAVLogging(LogMessageModel.LogLevel.INFO); createDatabase(); VideoPlayer2.VideoPlayer2Test test = new VideoPlayer2.VideoPlayer2Test(); //test.Test(); //TestWindow window = new TestWindow(); //window.Show(); }
public MediaFileBrowserDirectoryBrowserViewModel(MediaFileWatcher mediaFileWatcher, IEventAggregator eventAggregator) { MediaFileWatcher = mediaFileWatcher; EventAggregator = eventAggregator; BrowsePathHistory = Settings.Default.BrowsePathHistory; FavoriteLocations = Settings.Default.FavoriteLocations; EventAggregator.GetEvent <MediaBrowserPathChangedEvent>().Subscribe((location) => { BrowsePath = location; }); }
public MetaDataUpdateViewModel(MediaFileWatcher mediaFileWatcher, IEventAggregator eventAggregator) { MediaFileState = mediaFileWatcher.MediaFileState; EventAggregator = eventAggregator; WindowTitle = "Updating Metadata"; WindowIcon = "pack://application:,,,/Resources/Icons/info.ico"; CancelCommand.IsExecutable = true; OkCommand.IsExecutable = false; counter = null; }
void setDefaults(MediaFileWatcher mediaFileWatcher) { BackgroundColor = Colors.White; FontColor = Colors.Black; NrColumns = 3; NrRows = 16; MaxPreviewImageWidth = 1280; IsCaptureIntervalSecondsEnabled = true; CaptureIntervalSeconds = 25; OutputPath = mediaFileWatcher.Path; OutputPathHistory = Settings.Default.VideoPreviewOutputDirectoryHistory; IsAddTags = true; IsAddTimestamps = true; IsCommentEnabled = false; FontSize = 20; JpegQuality = 80; IsAddHeader = true; }
void setDefaults(MediaFileWatcher mediaFileWatcher) { BackgroundColor = Colors.LightGray; FontColor = Colors.Black; NrColumns = 6; MaxWidth = 1280; IsMaxGridHeightEnabled = true; MaxGridHeight = 200; OutputPath = mediaFileWatcher.Path; OutputPathHistory = Settings.Default.ImageCollageOutputDirectoryHistory; IsCommentEnabled = false; FontSize = 20; JpegQuality = 80; IsAddHeader = true; IsAddInfo = true; IsUseThumbs = true; Filename = String.IsNullOrEmpty(OutputPath) ? "collage" : Path.GetFileName(OutputPath); }
public VideoPreviewImageViewModel(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 (VideoPreviewImageProgressViewModel vm = new VideoPreviewImageProgressViewModel()) { progress.DataContext = vm; vm.AsyncState = this; progress.Show(); Task task = vm.generatePreviews(); OnClosingRequest(); await task; MiscUtils.insertIntoHistoryCollection(OutputPathHistory, OutputPath); } }); CancelCommand = new Command(() => { OnClosingRequest(); }); DefaultsCommand = new Command(() => { setDefaults(mediaFileWatcher); }); }
public ExportViewModel(MediaFileWatcher mediaFileWatcher) { Title = "Export Media"; OkCommand = new Command(async() => { CancellableOperationProgressView progress = new CancellableOperationProgressView(); ExportProgressViewModel vm = new ExportProgressViewModel(mediaFileWatcher.MediaFileState); progress.DataContext = vm; progress.Show(); Task t = vm.exportAsync(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(); })); }
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 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); }