Exemple #1
0
        public MediaManagerViewmodel(IEngine engine, IPreview preview)
        {
            _mediaManager = engine.MediaManager;
            _engine       = engine;
            _preview      = preview;
            if (preview != null)
            {
                PreviewViewmodel = new PreviewViewmodel(engine, preview);
            }

            MediaDirectories = new List <MediaDirectoryViewmodel>();
            MediaDirectories.AddRange(_mediaManager.IngestDirectories.Where(d => d.ContainsImport()).Select(d => new MediaDirectoryViewmodel(d, true)));
            IArchiveDirectory archiveDirectory = _mediaManager.ArchiveDirectory;

            if (archiveDirectory != null)
            {
                MediaDirectories.Insert(0, new MediaDirectoryViewmodel(archiveDirectory));
            }
            IAnimationDirectory animationDirectoryPri = _mediaManager.AnimationDirectoryPRI;

            if (animationDirectoryPri != null)
            {
                MediaDirectories.Insert(0, new MediaDirectoryViewmodel(animationDirectoryPri));
            }
            IAnimationDirectory animationDirectorySec = _mediaManager.AnimationDirectorySEC;

            if (animationDirectorySec != null)
            {
                MediaDirectories.Insert(0, new MediaDirectoryViewmodel(animationDirectorySec));
            }
            IServerDirectory serverDirectoryPri = _mediaManager.MediaDirectoryPRI;

            if (serverDirectoryPri != null)
            {
                MediaDirectories.Insert(0, new MediaDirectoryViewmodel(serverDirectoryPri));
            }
            IServerDirectory serverDirectorySec = _mediaManager.MediaDirectorySEC;

            if (serverDirectorySec != null && serverDirectorySec != serverDirectoryPri)
            {
                MediaDirectories.Insert(1, new MediaDirectoryViewmodel(serverDirectorySec));
            }

            _mediaCategory    = MediaCategories.FirstOrDefault();
            SelectedDirectory = MediaDirectories.FirstOrDefault();
            if (_mediaManager.FileManager != null)
            {
                FileManagerViewmodel = new FileManagerViewmodel(_mediaManager.FileManager);
            }
            RecordersViewmodel = new RecordersViewmodel(_engine, _mediaManager.Recorders);
            RecordersViewmodel.PropertyChanged += _recordersViewmodel_PropertyChanged;
            ComposePlugins();
            VideoPreview?.SetSource(RecordersViewmodel.Channel?.PreviewUrl);

            CommandSearch = new UICommand {
                ExecuteDelegate = _search, CanExecuteDelegate = _canSearch
            };
            CommandClearFilters = new UICommand {
                ExecuteDelegate = _clearFilters, CanExecuteDelegate = _canClearFilters
            };
            CommandDeleteSelected = new UICommand {
                ExecuteDelegate = _deleteSelected, CanExecuteDelegate = o => _isSomethingSelected() && engine.HaveRight(EngineRight.MediaDelete)
            };
            CommandIngestSelectedToServer = new UICommand {
                ExecuteDelegate = _ingestSelectedToServer, CanExecuteDelegate = _canIngestSelectedToServer
            };
            CommandMoveSelectedToArchive = new UICommand {
                ExecuteDelegate = _moveSelectedToArchive, CanExecuteDelegate = o => _selectedDirectory != null && _selectedDirectory.IsServerDirectory && _isSomethingSelected() && engine.HaveRight(EngineRight.MediaArchive) && engine.HaveRight(EngineRight.MediaDelete)
            };
            CommandCopySelectedToArchive = new UICommand {
                ExecuteDelegate = _copySelectedToArchive, CanExecuteDelegate = o => _selectedDirectory != null && _selectedDirectory.IsServerDirectory && _isSomethingSelected() && engine.HaveRight(EngineRight.MediaArchive)
            };
            CommandSweepStaleMedia = new UICommand {
                ExecuteDelegate = _sweepStaleMedia, CanExecuteDelegate = o => CurrentUser.IsAdmin
            };
            CommandGetLoudness = new UICommand {
                ExecuteDelegate = _getLoudness, CanExecuteDelegate = o => _isSomethingSelected() && engine.HaveRight(EngineRight.MediaEdit)
            };
            CommandExport = new UICommand {
                ExecuteDelegate = _export, CanExecuteDelegate = _canExport
            };
            CommandRefresh = new UICommand {
                ExecuteDelegate = ob => _refreshMediaDirectory(_selectedDirectory?.Directory), CanExecuteDelegate = _canRefresh
            };
            CommandSyncPriToSec = new UICommand {
                ExecuteDelegate = _syncSecToPri, CanExecuteDelegate = o => _selectedDirectory.IsServerDirectory && CurrentUser.IsAdmin
            };
            CommandCloneAnimation = new UICommand {
                ExecuteDelegate = _cloneAnimation, CanExecuteDelegate = _canCloneAnimation
            };
            CommandTogglePropertiesPanel = new UICommand {
                ExecuteDelegate = o => IsPropertiesPanelVisible = !IsPropertiesPanelVisible
            };
        }
Exemple #2
0
        public MediaManagerViewmodel(IEngine engine, IPreview preview)
        {
            _mediaManager = engine.MediaManager;
            Engine        = engine;
            _preview      = preview;
            if (preview != null)
            {
                PreviewViewmodel = new PreviewViewmodel(engine, preview);
            }

            MediaDirectories = new List <MediaDirectoryViewmodel>();
            MediaDirectories.AddRange(_mediaManager.IngestDirectories.Where(d => d.ContainsImport()).Select(d => new MediaDirectoryViewmodel(d, d.DirectoryName, true)));
            var archiveDirectory = _mediaManager.ArchiveDirectory;

            if (archiveDirectory != null)
            {
                MediaDirectories.Insert(0, new MediaDirectoryViewmodel(archiveDirectory, resources._archive));
            }
            var animationDirectorySec = _mediaManager.AnimationDirectorySEC;
            var animationDirectoryPri = _mediaManager.AnimationDirectoryPRI;

            if (animationDirectorySec != null && animationDirectorySec != animationDirectoryPri)
            {
                MediaDirectories.Insert(0, new MediaDirectoryViewmodel(animationDirectorySec, resources._animations_Secondary));
            }
            if (animationDirectoryPri != null)
            {
                MediaDirectories.Insert(0, new MediaDirectoryViewmodel(animationDirectoryPri, resources._animations_Primary));
            }
            var serverDirectoryPri = _mediaManager.MediaDirectoryPRI;
            var serverDirectorySec = _mediaManager.MediaDirectorySEC;

            if (serverDirectorySec != null && serverDirectorySec != serverDirectoryPri)
            {
                MediaDirectories.Insert(0, new MediaDirectoryViewmodel(serverDirectorySec, resources._secondary));
            }
            if (serverDirectoryPri != null)
            {
                MediaDirectories.Insert(0, new MediaDirectoryViewmodel(serverDirectoryPri, resources._primary));
            }

            _mediaCategory    = MediaCategories.FirstOrDefault();
            SelectedDirectory = MediaDirectories.FirstOrDefault();
            if (_mediaManager.FileManager != null)
            {
                FileManagerViewmodel = new FileManagerViewmodel(_mediaManager.FileManager);
            }
            RecordersViewmodel = new RecordersViewmodel(Engine, _mediaManager.Recorders);
            RecordersViewmodel.PropertyChanged += _recordersViewmodel_PropertyChanged;
            VideoPreview = UiPluginManager.ComposePart <IVideoPreview>(this);
            VideoPreview?.SetSource(RecordersViewmodel.Channel?.PreviewUrl);

            CommandSearch                 = new UiCommand(_search, _canSearch);
            CommandClearFilters           = new UiCommand(_clearFilters, _canClearFilters);
            CommandDeleteSelected         = new UiCommand(_deleteSelected, o => _isSomethingSelected() && engine.HaveRight(EngineRight.MediaDelete));
            CommandIngestSelectedToServer = new UiCommand(_ingestSelectedToServer, _canIngestSelectedToServer);
            CommandMoveSelectedToArchive  = new UiCommand(_moveSelectedToArchive, o => _selectedDirectory != null && _selectedDirectory.IsServerDirectory && _isSomethingSelected() && engine.HaveRight(EngineRight.MediaArchive) && engine.HaveRight(EngineRight.MediaDelete));
            CommandCopySelectedToArchive  = new UiCommand(_copySelectedToArchive, o => _selectedDirectory != null && _selectedDirectory.IsServerDirectory && _isSomethingSelected() && engine.HaveRight(EngineRight.MediaArchive));
            CommandSweepStaleMedia        = new UiCommand(_sweepStaleMedia, o => CurrentUser.IsAdmin);
            CommandGetLoudness            = new UiCommand(_getLoudness, o => _isSomethingSelected() && engine.HaveRight(EngineRight.MediaEdit));
            CommandExport                 = new UiCommand(_export, _canExport);
            CommandRefresh                = new UiCommand(async ob => await _reloadFiles(), _canRefresh);
            CommandSyncPriToSec           = new UiCommand(_syncSecToPri, o => _selectedDirectory.IsServerDirectory && CurrentUser.IsAdmin);
            CommandCloneAnimation         = new UiCommand(_cloneAnimation, _canCloneAnimation);
            CommandTogglePropertiesPanel  = new UiCommand(o => IsPropertiesPanelVisible = !IsPropertiesPanelVisible);
            CommandVerifyAllMedia         = new UiCommand(_verifyAllMedia, o => _selectedDirectory.IsServerDirectory && CurrentUser.IsAdmin);
        }
        public MediaManagerViewmodel(IMediaManager mediaManager, IPreview preview)
        {
            _mediaManager = mediaManager;
            _preview      = preview;
            if (preview != null)
            {
                PreviewViewmodel = new PreviewViewmodel(preview);
            }

            MediaDirectories = new List <MediaDirectoryViewmodel>();
            MediaDirectories.AddRange(mediaManager.IngestDirectories.Where(d => d.ContainsImport()).Select(d => new MediaDirectoryViewmodel(d, true)));
            IArchiveDirectory archiveDirectory = mediaManager.ArchiveDirectory;

            if (archiveDirectory != null)
            {
                MediaDirectories.Insert(0, new MediaDirectoryViewmodel(archiveDirectory));
            }

            IAnimationDirectory animationDirectoryPRI = mediaManager.AnimationDirectoryPRI;

            if (animationDirectoryPRI != null)
            {
                MediaDirectories.Insert(0, new MediaDirectoryViewmodel(animationDirectoryPRI));
            }
            IAnimationDirectory animationDirectorySEC = mediaManager.AnimationDirectorySEC;

            if (animationDirectorySEC != null)
            {
                MediaDirectories.Insert(0, new MediaDirectoryViewmodel(animationDirectorySEC));
            }

            IServerDirectory        serverDirectoryPRI   = mediaManager.MediaDirectoryPRI;
            MediaDirectoryViewmodel serverDirectoryPRIVm = new MediaDirectoryViewmodel(serverDirectoryPRI);

            if (serverDirectoryPRI != null)
            {
                MediaDirectories.Insert(0, serverDirectoryPRIVm);
            }
            IServerDirectory serverDirectorySEC = mediaManager.MediaDirectorySEC;

            if (serverDirectorySEC != null && serverDirectorySEC != serverDirectoryPRI)
            {
                MediaDirectories.Insert(1, new MediaDirectoryViewmodel(serverDirectorySEC));
            }

            _mediaCategory    = MediaCategories.FirstOrDefault();
            SelectedDirectory = serverDirectoryPRIVm;
            if (mediaManager.FileManager != null)
            {
                FileManagerViewmodel = new FileManagerViewmodel(mediaManager.FileManager);
            }
            RecordersViewmodel = new RecordersViewmodel(mediaManager.Recorders);
            RecordersViewmodel.PropertyChanged += _recordersViewmodel_PropertyChanged;
            _previewDisplay = true;
            ComposePlugins();
            VideoPreview?.SetSource(RecordersViewmodel.Channel?.PreviewUrl);

            CommandSearch = new UICommand {
                ExecuteDelegate = _search, CanExecuteDelegate = _canSearch
            };
            CommandClearFilters = new UICommand {
                ExecuteDelegate = _clearFilters, CanExecuteDelegate = _canClearFilters
            };
            CommandDeleteSelected = new UICommand {
                ExecuteDelegate = _deleteSelected, CanExecuteDelegate = _isSomethingSelected
            };
            CommandIngestSelectedToServer = new UICommand {
                ExecuteDelegate = _ingestSelectedToServer, CanExecuteDelegate = _canIngestSelectedToServer
            };
            CommandMoveSelectedToArchive = new UICommand {
                ExecuteDelegate = _moveSelectedToArchive, CanExecuteDelegate = o => _selectedDirectory != null && _selectedDirectory.IsServerDirectory && _isSomethingSelected(o)
            };
            CommandCopySelectedToArchive = new UICommand {
                ExecuteDelegate = _copySelectedToArchive, CanExecuteDelegate = o => _selectedDirectory != null && _selectedDirectory.IsServerDirectory && _isSomethingSelected(o)
            };
            CommandSweepStaleMedia = new UICommand {
                ExecuteDelegate = _sweepStaleMedia
            };
            CommandGetLoudness = new UICommand {
                ExecuteDelegate = _getLoudness, CanExecuteDelegate = _isSomethingSelected
            };
            CommandExport = new UICommand {
                ExecuteDelegate = _export, CanExecuteDelegate = _canExport
            };
            CommandRefresh = new UICommand {
                ExecuteDelegate = ob => _refreshMediaDirectory(_selectedDirectory?.Directory), CanExecuteDelegate = o => _selectedDirectory?.IsIngestDirectory == true
            };
            CommandSyncPriToSec = new UICommand {
                ExecuteDelegate = _syncSecToPri, CanExecuteDelegate = o => _selectedDirectory.IsServerDirectory
            };
            CommandCloneAnimation = new UICommand {
                ExecuteDelegate = _cloneAnimation, CanExecuteDelegate = _canCloneAnimation
            };
        }