private async void Button_Click(object sender, RoutedEventArgs e) { var region_selection = (string)region_box.SelectedItem; var department_selection = (string)department_box.SelectedItem; var domitory_selection = donitory_box.Text; var power_info_format = new Power(region_selection, department_selection, domitory_selection); if (power_info != null) { if (power_info.Equals(power_info_format)) { return; } } power_info = power_info_format; if (region_selection == null && department_selection == null && domitory_selection == "薛楠楠") { MainVM.Message = "你咋知道我家女神名字?"; } else if (region_selection == null && department_selection == null && domitory_selection == "楠楠") { MainVM.Message = "这个名字最好听了~"; } else if (region_selection == null && department_selection == null && domitory_selection == "楠宝") { MainVM.Message = "全称应该是可爱温柔楠楠大宝宝"; } else { MainVM.Message = ""; try { MainVM.PowerLists = await myhttp.GetPower(power_info); } catch { MainVM.PowerLists.Clear(); MainVM.Message = "该宿舍不存在"; return; } if (tile_enable) { TileNotificationHelper.UpdateTitleNotification(power_info, MainVM.PowerLists); } } }
private async void Page_Loading(FrameworkElement sender, object args) { start_mode = true; if (Data_storage.read_para("setting_save") != null) { setting_save = (bool)Data_storage.read_para("setting_save"); Save_box.IsChecked = setting_save; } if (Data_storage.read_para("tile_enable") != null) { tile_enable = (bool)Data_storage.read_para("tile_enable"); Tile_box.IsChecked = tile_enable; } if (!await MainVM.CheckNetwork()) { Button.IsEnabled = false; return; } MainVM.Region_Lists = await myhttp.GetList_region(); if (setting_save && Data_storage.read_power() != null) { power_info = (Power)Data_storage.read_power(); MainVM.PowerLists = await myhttp.GetPower(power_info); if (tile_enable) { TileNotificationHelper.UpdateTitleNotification(power_info, MainVM.PowerLists); } else { TileNotificationHelper.CleanTileNotification(); } MainVM.Department_Lists = await myhttp.GetList_dormitory(power_info.region); region_box.SelectedIndex = region_box.Items.IndexOf(power_info.region); department_box.SelectedIndex = department_box.Items.IndexOf(power_info.department_num); donitory_box.Text = power_info.domitory_num; } start_mode = false; }
public async void Run(IBackgroundTaskInstance taskInstance) { var deferral = taskInstance.GetDeferral(); // 获取数据,更新磁贴逻辑 if (Data_storage.read_para("setting_save") != null) { var setting_save = (bool)Data_storage.read_para("setting_save"); if (setting_save && Data_storage.read_power() != null) { Power power_info = Data_storage.read_power(); ObservableCollection <PowerList> powerLists = await myhttp.GetPower(power_info); if (Data_storage.read_para("tile_enable") != null && (bool)Data_storage.read_para("tile_enable") == true) { TileNotificationHelper.UpdateTitleNotification(power_info, powerLists); TileNotificationHelper.UpdateToastNotification(powerLists, 20); } } } deferral.Complete(); }