Ejemplo n.º 1
0
 public MainViewModel(TableViewModel tableViewModel, EntryViewModel entryViewModel, TopBarViewModel topBarViewModel)
 {
     TopBarViewModel = topBarViewModel;
     TableViewModel  = tableViewModel;
     TopBarViewModel.PropertyChanged += OnTopBarPropertyChanged;
     EntryViewModel = entryViewModel;
 }
Ejemplo n.º 2
0
        private async Task RefreshObjectContainerTask(bool force)
        {
            await Client.RefreshObjectContainer(force);

            ResourcesViewModel.Synchronize(ObjectContainer.Instance.CurrentSelectedPlanet);
            TopBarViewModel.UpdatePlayerPlanets(ObjectContainer.Instance.PlayerPlanets);
            CheckHostileMissions();
        }
Ejemplo n.º 3
0
        public IViewComponentResult Invoke()
        {
            var model = new TopBarViewModel();

            model.SubscibedSubs.AddRange(_subDao.GetSubsByIds(_contextService.GetSubscribedSubIds()).Select(x => x.Name).OrderBy(x => x));
            model.DefaultSubs.AddRange(_subDao.GetSubsByIds(_subDao.GetDefaultSubs()).Select(x => x.Name));
            return(View(model));
        }
Ejemplo n.º 4
0
        //TODO DarthAffe 06.01.2016: This is a somehow weird design ...
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            this.DispatcherUnhandledException += OnDispatcherUnhandledException;

            _apiService    = new HikariApiService();
            _configService = new ConfigService();
            _patchService  = new PatchService(_apiService, UpdateStatusFunc);

            _topBarViewModel     = new TopBarViewModel(_configService);
            _gamesViewModel      = new GamesViewModel(_configService, _patchService);
            _mainWindowViewModel = new MainWindowViewModel(_apiService, _topBarViewModel, _gamesViewModel);

            new MainWindow {
                DataContext = _mainWindowViewModel
            }.Show();
        }
Ejemplo n.º 5
0
        public MainWindowViewModel(OGameHttpClient client) : base(client)
        {
            ResourcesViewModel = new ResourcesViewModel(client);
            TopBarViewModel    = new TopBarViewModel(ResourcesViewModel);
            GalaxyViewModel    = new GalaxyViewModel(client);

            Observable.Interval(TimeSpan.FromMinutes(5))
            .SubscribeOnDispatcher()
            .DelayTask(() => TimeSpan.FromMinutes(Random.Next(10, 20)))
            .Select(i => SafeHttpTask(() => RefreshObjectContainerTask(false)))
            .Subscribe();

            Observable.Interval(TimeSpan.FromMinutes(1))
            .SubscribeOnDispatcher()
            .Where(i => WorkerQueueActionRunner.ExecutionQueue.Any())
            .Subscribe(token =>
            {
                WorkerQueueActionRunner.CheckQueue();
            });

            Init();
        }
Ejemplo n.º 6
0
 public ActionResult TopBar()
 {
     var model = new TopBarViewModel();
     model.SubscibedSubs.AddRange(_subDao.GetSubsByIds(_contextService.GetSubscribedSubIds()).Select(x => x.Name));
     return PartialView(model);
 }
Ejemplo n.º 7
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var language = RouteData?.Values["language"]?.ToString();

            var regionValue = RouteData?.Values["regionValue"] as RegionValue;
            var region      = regionValue?.Region;

            var(regionPagesUrl, _, regionTitle, regions) = await _cmsApiProxy.GetRegionList(region, language);

            var baseUrl = $"/{language}";

            var model = new TopBarViewModel
            {
                Regions = regions.Select(n => new TopBarViewModel.RegionViewModel
                {
                    Id      = n.Id,
                    Name    = n.Title?.Rendered,
                    UrlPath = GetRegionUrlPath(language, n.Url_path)
                }).ToList(),
                Region         = regionTitle,
                LanguageCode   = language,
                BasePartialUrl = baseUrl
            };

            var pages = await _cmsApiProxy.GetPages(language, regionPagesUrl);

            var urlList    = new List <string>();
            var partialUrl = string.Empty;

            if (!string.IsNullOrEmpty(language))
            {
                urlList.Add(language);
            }

            if (!string.IsNullOrEmpty(region))
            {
                urlList.Add(region);
            }

            if (urlList.Any())
            {
                partialUrl = string.Join("/", urlList);
            }

            model.RegionUrl = $"/{partialUrl}";

            // Get only top menu pages
            model.Pages = pages
                          .Where(p => p.Page_type?.First().TypeName == CmsVariable.TopMenuPageTypeName)
                          .Select(n => new TopBarViewModel.PageViewModel
            {
                Id       = n.Id,
                PageName = n.Title?.Rendered,
                UrlPath  = !string.IsNullOrEmpty(partialUrl) ? $"{partialUrl}/{n.Slug}" : n.Slug
            }).ToList();

            model.RootUrl = $"{Request.Scheme}://{Request.Host}";

            model.Translations = await _cmsApiProxy.GetTranslationsByPrefix(language, "topbar.");

            return(View(model));
        }
Ejemplo n.º 8
0
        public IViewComponentResult Invoke()
        {
            var model = new TopBarViewModel();

            return View(model);
        }