Example #1
0
        public MainViewModel(int visibleItems)
        {
            PageTitle   = "DJNano Show";
            Tours       = new ListViewModel <DynamicStorageDataConfig, Tours1Schema>(new ToursConfig(), visibleItems);
            Videos      = new ListViewModel <YouTubeDataConfig, YouTubeSchema>(new VideosConfig(), visibleItems);
            Social      = new ListViewModel <LocalStorageDataConfig, MenuSchema>(new SocialConfig());
            Discography = new ListViewModel <DynamicStorageDataConfig, Discography1Schema>(new DiscographyConfig(), visibleItems);
            Biography   = new ListViewModel <LocalStorageDataConfig, HtmlSchema>(new BiographyConfig(), visibleItems);
            Actions     = new List <ActionInfo>();

            if (GetViewModels().Any(vm => !vm.HasLocalData))
            {
                Actions.Add(new ActionInfo
                {
                    Command    = new RelayCommand(Refresh),
                    Style      = ActionKnownStyles.Refresh,
                    Name       = "RefreshButton",
                    ActionType = ActionType.Primary
                });
            }
        }
Example #2
0
        public MainViewModel(int visibleItems) : base()
        {
            PageTitle   = "DJNano Show";
            Tours       = ListViewModel.CreateNew(Singleton <ToursConfig> .Instance, visibleItems);
            Videos      = ListViewModel.CreateNew(Singleton <VideosConfig> .Instance, visibleItems);
            Gallery     = ListViewModel.CreateNew(Singleton <GalleryConfig> .Instance, visibleItems);
            Social      = ListViewModel.CreateNew(Singleton <SocialConfig> .Instance);
            Discography = ListViewModel.CreateNew(Singleton <DiscographyConfig> .Instance, visibleItems);
            Biography   = ListViewModel.CreateNew(Singleton <BiographyConfig> .Instance, visibleItems);

            Actions = new List <ActionInfo>();

            if (GetViewModels().Any(vm => !vm.HasLocalData))
            {
                Actions.Add(new ActionInfo
                {
                    Command    = new RelayCommand(Refresh),
                    Style      = ActionKnownStyles.Refresh,
                    Name       = "RefreshButton",
                    ActionType = ActionType.Primary
                });
            }
        }
Example #3
0
        public static ListViewModel CreateNew <TSchema>(SectionConfigBase <TSchema> sectionConfig, int visibleItems = 0) where TSchema : SchemaBase
        {
            var vm = new ListViewModel
            {
                SectionName    = sectionConfig.Name,
                Title          = sectionConfig.ListPage.Title,
                NavigationInfo = sectionConfig.ListPage.ListNavigationInfo,
                PageTitle      = sectionConfig.ListPage.PageTitle,
                _visibleItems  = visibleItems,
                HasLocalData   = !sectionConfig.NeedsNetwork
            };

            var settings = new CacheSettings
            {
                Key          = sectionConfig.Name,
                Expiration   = vm.CacheExpiration,
                NeedsNetwork = sectionConfig.NeedsNetwork,
                UseStorage   = sectionConfig.NeedsNetwork,
            };

            //we save a reference to the load delegate in order to avoid export TSchema outside the view model
            vm.LoadDataInternal = (refresh, filterFunc) => AppCache.LoadItemsAsync <TSchema>(settings, sectionConfig.LoadDataAsyncFunc, (content) => vm.ParseItems(sectionConfig.ListPage, content, filterFunc), refresh);

            if (sectionConfig.NeedsNetwork)
            {
                vm.Actions.Add(new ActionInfo
                {
                    Command    = vm.Refresh,
                    Style      = ActionKnownStyles.Refresh,
                    Name       = "RefreshButton",
                    ActionType = ActionType.Primary
                });
            }

            return(vm);
        }