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; }
public async Task <GetColorRespose> GetColorAsync() { GetColorRespose respose = new GetColorRespose(); respose = await Weather.Utils.JsonSerializeHelper.JsonDeSerializeForFileAsync <GetColorRespose>("Color\\ColorConfig.json").ConfigureAwait(false); return(respose); }
public SettingPage() { this.InitializeComponent(); this.navigationHelper = new NavigationHelper(this); settingService = SettingService.GetInstance(); userService = UserService.GetInstance(); colorService = ColorService.GetInstance(); switchesRespose = new GetSettingSwitchesRespose(); autoUpdateTimeRepose = new GetSettingAutoUpdateTimeRepose(); userRespose = new GetUserRespose(); colorResponse = new GetColorRespose(); }
/// <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(); } }
public MainPage() { this.navigationHelper = new NavigationHelper(this); this.NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required; userService = UserService.GetInstance(); weatherService = WeatherService.GetInstance(); settingService = SettingService.GetInstance(); colorService = ColorService.GetInstance(); userRespose = new GetUserRespose(); userCityRespose = new GetUserCityRespose(); weatherRespose = new GetWeatherRespose(); weatherTypeRespose = new GetWeatherTypeRespose(); settingAutoUpdateTimeRepose = new GetSettingAutoUpdateTimeRepose(); colorResponse = new GetColorRespose(); homePageModel = new HomePageModel(); this.InitializeComponent(); Loaded += MainPage_Loaded; }
/// <summary> /// 获取初始化颜色Json格式 /// </summary> /// <returns></returns> public string GetColorJson() { GetColorRespose respose = new GetColorRespose(); respose = new GetColorRespose() { UserColors = new List <Model.UserColor>() { new Model.UserColor() { SingleColors = new List <Model.SingleColor>() { new Model.SingleColor() { colorStr = "0x324D5C" }, new Model.SingleColor() { colorStr = "0x46B29D" }, new Model.SingleColor() { colorStr = "0xF0CA4D" }, new Model.SingleColor() { colorStr = "0xE37B40" }, new Model.SingleColor() { colorStr = "0xDE5B49" }, new Model.SingleColor() { colorStr = "0x293841" }, }, isSelected = "1", Title = "标准心情" }, new Model.UserColor() { SingleColors = new List <Model.SingleColor>() { new Model.SingleColor() { colorStr = "0xFF91BD" }, new Model.SingleColor() { colorStr = "0x8793E8" }, new Model.SingleColor() { colorStr = "0x99FFC5" }, new Model.SingleColor() { colorStr = "0xE8DE7F" }, new Model.SingleColor() { colorStr = "0xFFAB8C" }, new Model.SingleColor() { colorStr = "0x293841" }, }, isSelected = "0", Title = "清新花季" }, new Model.UserColor() { SingleColors = new List <Model.SingleColor>() { new Model.SingleColor() { colorStr = "0x442D65" }, new Model.SingleColor() { colorStr = "0x775BA3" }, new Model.SingleColor() { colorStr = "0x91C5A9" }, new Model.SingleColor() { colorStr = "0xF8E1B4" }, new Model.SingleColor() { colorStr = "0xF98A5F" }, new Model.SingleColor() { colorStr = "0x293841" }, }, isSelected = "0", Title = "哥德情怀" }, new Model.UserColor() { SingleColors = new List <Model.SingleColor>() { new Model.SingleColor() { colorStr = "0x169CF4" }, new Model.SingleColor() { colorStr = "0x23A60A" }, new Model.SingleColor() { colorStr = "0xD88F09" }, new Model.SingleColor() { colorStr = "0xF0620B" }, new Model.SingleColor() { colorStr = "0xF3302F" }, new Model.SingleColor() { colorStr = "0x293841" }, }, isSelected = "0", Title = "浓郁夏午" }, } }; return(Utils.JsonSerializeHelper.JsonSerialize <GetColorRespose>(respose)); }
public async Task SaveColor(GetColorRespose getColorRespose) { await Weather.Utils.JsonSerializeHelper.JsonSerializeForFileAsync <GetColorRespose>(getColorRespose, "Color\\ColorConfig.json").ConfigureAwait(false); }