Exemplo n.º 1
0
        public Playlist(ViewModelServiceContainer container, IValidator <Playlist> validator, DialogViewModel dialogViewModel, Data.Playlist model)
            : base(model, validator, container.Messenger)
        {
            using (BusyStack.GetToken())
            {
                _itemsLock        = new object();
                _dialogViewModel  = dialogViewModel ?? throw new ArgumentNullException(nameof(dialogViewModel), $"{nameof(dialogViewModel)} {Resources.IsRequired}");
                _sequenceProvider = container.SequenceService;

                _translator   = container.LocalizationService;
                _title        = model.Title;
                _description  = model.Description;
                _repeatMode   = (RepeatMode)model.RepeatMode;
                _isShuffeling = model.IsShuffeling;
                _sequence     = model.Sequence;

                RepeatModes = new RangeObservableCollection <RepeatMode>(Enum.GetValues(typeof(RepeatMode)).Cast <RepeatMode>().ToList());
                History     = new Stack <int>();

                Items = new RangeObservableCollection <MediaItem>();
                Items.CollectionChanged += (o, e) => OnPropertyChanged(nameof(Count));
                BindingOperations.EnableCollectionSynchronization(Items, _itemsLock);
                View = CollectionViewSource.GetDefaultView(Items);
                OnPropertyChanged(nameof(Count));

                InitializeCommands();
                Validate();
            }
        }
Exemplo n.º 2
0
        public static void ForEach <TSource>(this IRangeObservableCollection <TSource> baseCollection, Action <TSource> action)
        {
            if (baseCollection == null)
            {
                throw new ArgumentNullException(nameof(baseCollection), $"{nameof(baseCollection)} {Resources.IsRequired}");
            }

            if (action == null)
            {
                throw new ArgumentNullException(nameof(action), $"{nameof(action)} {Resources.IsRequired}");
            }

            foreach (var item in baseCollection)
            {
                action(item);
            }
        }
Exemplo n.º 3
0
        public static IEnumerable <TResult> ForEach <TSource, TResult>(this IRangeObservableCollection <TSource> baseCollection, Func <TSource, TResult> action)
        {
            if (baseCollection == null)
            {
                throw new ArgumentNullException(nameof(baseCollection), $"{nameof(baseCollection)} {Resources.IsRequired}");
            }

            if (action == null)
            {
                throw new ArgumentNullException(nameof(action), $"{nameof(action)} {Resources.IsRequired}");
            }

            foreach (var item in baseCollection)
            {
                yield return(action(item));
            }
        }
        protected MapleFileSystemContainerBase(string name, string fullName, IDepth depth, IFileSystemDirectory parent) : base(name, fullName, depth, parent)
        {
            using (_busyStack.GetToken())
            {
                IsContainer = true;

                Children = new RangeObservableCollection <IFileSystemInfo>();

                NoFilesCollectionView = CollectionViewSource.GetDefaultView(Children);
                DefaultCollectionView = CollectionViewSource.GetDefaultView(Children);

                using (NoFilesCollectionView.DeferRefresh())
                    NoFilesCollectionView.Filter = NoFilesFilter;

                using (DefaultCollectionView.DeferRefresh())
                    DefaultCollectionView.Filter = SearchFilter;
            }
        }
Exemplo n.º 5
0
        protected MapleFileSystemContainerBase(string name, string fullName, IDepth depth, IFileSystemDirectory parent, IMessenger messenger, ILoggingService loggingService)
            : base(name, fullName, depth, parent, messenger)
        {
            using (BusyStack.GetToken())
            {
                IsContainer = true;

                Children = new RangeObservableCollection <IFileSystemInfo>();

                NoFilesCollectionView = CollectionViewSource.GetDefaultView(Children);
                DefaultCollectionView = CollectionViewSource.GetDefaultView(Children);

                using (NoFilesCollectionView.DeferRefresh())
                    NoFilesCollectionView.Filter = NoFilesFilter;

                using (DefaultCollectionView.DeferRefresh())
                    DefaultCollectionView.Filter = SearchFilter;

                _loggingService = loggingService ?? throw new ArgumentNullException(nameof(loggingService), $"{nameof(loggingService)} {Resources.IsRequired}");
            }
        }
 public ViewModelSelectionChangedMessage(IRangeObservableCollection <TViewModel> sender, TViewModel viewModel) : base(sender, viewModel)
 {
 }