public static void RegisterAllVMs(this IVMLocator vmLocator)
 {
     vmLocator.RegisterType <IAddRemoveFolderVM, AddRemoveFolderVM>();
     vmLocator.RegisterType <IFirstTimeViewModel, AddRemoveFolderVM>();
     vmLocator.RegisterType <IMainVM, MainVM>();
     vmLocator.RegisterType <StatusVM, StatusVM>();
 }
Esempio n. 2
0
 public AddRemoveFolderVM(IVMLocator vmLocator, IMessengerService messengerService, IMediaCollectionManager collectionManager, IApplicationSettings applicationSettings)
     : base(vmLocator)
 {
     _collectionManager   = collectionManager;
     _messengerService    = messengerService;
     _applicationSettings = applicationSettings;
 }
Esempio n. 3
0
 public App(IMessengerService messengerService, IUnityContainer unityContainer, IVMLocator vmLocator,
            IApplicationSettings applicationSettings)
 {
     _messengerService    = messengerService;
     _unityContainer      = unityContainer;
     _vmLocator           = vmLocator;
     _applicationSettings = applicationSettings;
 }
Esempio n. 4
0
        public MainVM(IVMLocator vmLocator, IMediaCollection mediaCollectionManager)
            : base(vmLocator)
        {
            _mediaCollectionManager = mediaCollectionManager;
            AllItems = new ObservableCollection <MediaItem>();
            AllItems.CollectionChanged += AllItems_CollectionChanged;

            OnLoadCommand = new RelayCommand(LoadedCmd);
            PlayCommand   = new RelayCommand <long>(PlayCmd, l => true);
        }
Esempio n. 5
0
 public static IEnumerable <T> GetSelectedItems <T>(this IVMLocator <T> locator) where T : CSharpToolkit.Utilities.Abstractions.IIdProvider
 {
     if (locator == null)
     {
         return(Enumerable.Empty <T>());
     }
     return((
                from s in locator.SelectedItems
                join m in locator.ModifyableItems on s.Id equals m.Id
                select m
                ).ToArray());
 }
        /// <summary>
        /// The logic used to update the <see cref="ModelSearcher" />.
        /// </summary>
        /// <param name="searcher">The new <see cref="ModelSearcher" />.</param>
        /// <returns>Task for async use.</returns>
        public async Task UpdateModelSearcher(IVMLocator <TModelSearcher> searcher)
        {
            var oldValue = _modelSearcher;

            if (Perform.ReplaceIfDifferent(ref _modelSearcher, searcher).WasSuccessful)
            {
                if (oldValue != null)
                {
                    Locators.Remove(oldValue);
                    oldValue.SelectedItems.CollectionChanged -= SelectedItems_CollectionChanged;
                    oldValue.ExportId -= ModelSearcher_ExportId;
                    oldValue.Cleared  -= ModelSearcher_Cleared;
                }
                if (_modelSearcher != null)
                {
                    _modelSearcher.SelectedItems.CollectionChanged += SelectedItems_CollectionChanged;
                    _modelSearcher.ExportId += ModelSearcher_ExportId;
                    _modelSearcher.Cleared  += ModelSearcher_Cleared;
                    Locators.Add(_modelSearcher);
                    if (_modelSearcher.CurrentItems.Any())
                    {
                        var navCollection =
                            (_modelSearcher.SelectedItems.Take(2).Count() == 2 ?
                             _modelSearcher.SelectedItems :
                             _modelSearcher.CurrentItems
                            );

                        _backForwardNavigator.UpdateNavigationCollection(navCollection.Select(item => item.Id));

                        int currentItem =
                            (_modelSearcher.SelectedItems.Any() ?
                             _modelSearcher.SelectedItems :
                             _modelSearcher.CurrentItems
                            ).First().Id;
                        await _backForwardNavigator.UpdateCurrentItem(currentItem);
                    }
                }
                await OnModelSearcherSwapped(oldValue);

                OnPropertyChanged(nameof(ModelSearcher));
            }
        }
Esempio n. 7
0
 protected BindableBase(IVMLocator vmLocator)
     : this()
 {
     VMLocator = vmLocator;
 }
Esempio n. 8
0
 public static bool AnyItemsSelectedEnable <T>(this IVMLocator <T> locator, Func <T, bool> function) where T : IIdProvider => (
     locator == null ||
     locator.GetSelectedItems().Any(function) == false
     ) == false;