private async Task LoadData()
        {
            switchesRespose      = settingService.GetSettingSwitches();
            autoUpdateTimeRepose = settingService.GetSettingAutoUpdateTime();
            userRespose          = await userService.GetUserAsync();

            ViewModel.AutoUpdateSettingPage autoUpdateSettingPage = new ViewModel.AutoUpdateSettingPage()
            {
                Switches        = switchesRespose.Switches,
                AutoUpdateTimes = autoUpdateTimeRepose.AutoUpdateTimes
            };
            ViewModel.GeneralSettingPage generalSettingPage = new ViewModel.GeneralSettingPage()
            {
                Switches = switchesRespose.Switches
            };
            ViewModel.SettingPage settingPage = new ViewModel.SettingPage()
            {
                AutoUpdateSettingPage = autoUpdateSettingPage,
                GeneralSettingPage    = generalSettingPage,
                UserConfig            = userRespose.UserConfig
            };
            colorResponse = await colorService.GetColorAsync();

            this.LVMood.DataContext     = colorResponse.UserColors;
            this.LayoutRoot.DataContext = null;
            this.LayoutRoot.DataContext = settingPage;
        }
Beispiel #2
0
        /// <summary>
        /// 此部分中提供的方法只是用于使
        /// NavigationHelper 可响应页面的导航方法。
        /// <para>
        /// 应将页面特有的逻辑放入用于
        /// <see cref="NavigationHelper.LoadState"/>
        /// 和 <see cref="NavigationHelper.SaveState"/> 的事件处理程序中。
        /// 除了在会话期间保留的页面状态之外
        /// LoadState 方法中还提供导航参数。
        /// </para>
        /// </summary>
        /// <param name="e">提供导航方法数据和
        /// 无法取消导航请求的事件处理程序。</param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            colorResponse = new GetColorRespose();

            StatusBar sb = StatusBar.GetForCurrentView();
            await sb.HideAsync();

            VisualStateManager.GoToState(this, "MoreHide", false);
            cityId = e.Parameter == null ? "" : e.Parameter.ToString();
            this.navigationHelper.OnNavigatedTo(e);

            userCityRespose = await userService.GetUserCityAsync();

            if (userCityRespose == null)
            {
                Frame.Navigate(typeof(AddCityPage), 1);
                return;
            }
            else
            {
                if (cityId == "")
                {
                    cityId = userCityRespose.UserCities.FirstOrDefault().CityId;
                }
                try
                {
                    userRespose = await userService.GetUserAsync();

                    weatherTypeRespose = await weatherService.GetWeatherTypeAsync();
                    await GetWeather(cityId, 0);

                    colorResponse = await colorService.GetColorAsync();

                    int timeSection = TimeHelper.GetNowSectionByWeight();
                    ChangeBgColor(timeSection);
                }
                catch (Exception)
                {
                }
                _timer          = new DispatcherTimer();
                _timer.Interval = TimeSpan.FromMinutes(1);
                _timer.Tick    += _timer_Tick;
                _timer.Start();
            }
        }