/// <summary> /// 打开城市管理窗口 /// </summary> private void OpenAddCity() { if (addCity.IsOpen != true)//防止在(初次)设置时再打开设置 { askl = new AskLocation(true); askl.Width = Window.Current.Bounds.Width; askl.Height = Window.Current.Bounds.Height; addCity.Child = askl; addCity.IsOpen = true; } }
/// <summary> /// 在此页将要在 Frame 中显示时进行调用。 /// </summary> /// <param name="e">描述如何访问此页的事件数据。Parameter /// 属性通常用于配置页。</param> protected async override void OnNavigatedTo(NavigationEventArgs e) { Current = this; nowColor=GetColor(); background.Background = new SolidColorBrush(nowColor); if (e.NavigationMode == NavigationMode.New) { try { var file = await ApplicationData.Current.LocalFolder.GetFileAsync("save.data");//获取城市记录文件 string str = await FileIO.ReadTextAsync(file); saveWeather = JsonConvert.DeserializeObject<WeatherInfo>(str); await GetWeather(); UpdateInfo(); TimeSpan sp = DateTime.Now - saveWeather.UpdateTime; if (sp.Minutes>30) { await GetWeather(); } } catch (Exception)//第一次打开,文件未创建 { askl = new AskLocation(false); askl.Width = Window.Current.Bounds.Width; askl.Height = Window.Current.Bounds.Height; addCity.Child = askl; addCity.IsOpen = true; } } }