private async Task InnerUpdateTile(ObservableCollection <ToDo> schedules) { try { //关闭了磁贴更新 if (!AppSettings.Instance.EnableTile) { UpdateTileHelper.ClearAllSchedules(); return; } CleanUpTileTemplate(); LargeBackGrd.Background = WideBackGrd.Background = MiddleBackGrd.Background = SmallBackGrd.Background = new SolidColorBrush(Colors.Transparent); List <string> undoList = new List <string>(); foreach (var sche in schedules) { if (!sche.IsDone) { undoList.Add(sche.Content); } } BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear(); LargeText0.Text = WideText0.Text = MiddleText0.Text = undoList.ElementAtOrDefault(0) ?? ""; LargeText1.Text = WideText1.Text = MiddleText1.Text = undoList.ElementAtOrDefault(1) ?? ""; LargeText2.Text = WideText2.Text = MiddleText2.Text = undoList.ElementAtOrDefault(2) ?? ""; LargeText3.Text = WideText3.Text = MiddleText3.Text = undoList.ElementAtOrDefault(3) ?? ""; LargeText4.Text = undoList.ElementAtOrDefault(4) ?? ""; LargeText5.Text = undoList.ElementAtOrDefault(5) ?? ""; LargeText6.Text = undoList.ElementAtOrDefault(6) ?? ""; LargeText7.Text = undoList.ElementAtOrDefault(7) ?? ""; LargeText8.Text = undoList.ElementAtOrDefault(8) ?? ""; LargeCount.Text = WideCount.Text = MiddleCount.Text = SmallCount.Text = undoList.Count.ToString(); if (undoList.Count == 0) { LargeText0.Text = WideText0.Text = MiddleText0.Text = "Enjoy your day ;-)"; } UpdateTileHelper.ClearAllSchedules(); //少于4个待办事项,不轮播 if (undoList.Count <= 4) { await UpdateTileHelper.UpdatePersonalTile(LargeGrid, WideGrid, MiddleGrid, SmallGrid, true, false); } else { //把前4条插入轮播 await UpdateTileHelper.UpdatePersonalTile(LargeGrid, WideGrid, MiddleGrid, SmallGrid, true, true); if (undoList.Count > 4) { WideText0.Text = MiddleText0.Text = undoList.ElementAtOrDefault(4) ?? ""; WideText1.Text = MiddleText1.Text = undoList.ElementAtOrDefault(5) ?? ""; WideText2.Text = MiddleText2.Text = undoList.ElementAtOrDefault(6) ?? ""; WideText3.Text = MiddleText3.Text = undoList.ElementAtOrDefault(7) ?? ""; //把5~8条加入轮播 await UpdateTileHelper.UpdatePersonalTile(LargeGrid, WideGrid, MiddleGrid, SmallGrid, false, true); } if (undoList.Count > 8) { WideText0.Text = MiddleText0.Text = undoList.ElementAtOrDefault(8) ?? ""; WideText1.Text = MiddleText1.Text = undoList.ElementAtOrDefault(9) ?? ""; WideText2.Text = MiddleText2.Text = undoList.ElementAtOrDefault(10) ?? ""; WideText3.Text = MiddleText3.Text = undoList.ElementAtOrDefault(11) ?? ""; //大于8的加入轮播 await UpdateTileHelper.UpdatePersonalTile(LargeGrid, WideGrid, MiddleGrid, SmallGrid, false, true); } } } catch (Exception e) { var task = Logger.LogAsync(e); } }
public async Task UpdateCustomeTile(ObservableCollection <ToDo> schedules) { try { if (LocalSettingHelper.GetValue("EnableTile") == "false") { UpdateTileHelper.ClearAllSchedules(); return; } CleanUpTileTemplate(); if (LocalSettingHelper.GetValue("TransparentTile") == "true") { backgrd1.Background = backgrd2.Background = backgrd3.Background = new SolidColorBrush(Colors.Transparent); } List <string> undoList = new List <string>(); foreach (var sche in schedules) { if (!sche.IsDone) { undoList.Add(sche.Content); } } Text0.Text = Text00.Text = undoList.ElementAtOrDefault(0) ?? ""; Text1.Text = Text01.Text = undoList.ElementAtOrDefault(1) ?? ""; Text2.Text = Text02.Text = undoList.ElementAtOrDefault(2) ?? ""; Text3.Text = Text03.Text = undoList.ElementAtOrDefault(3) ?? ""; Count1.Text = Count2.Text = Count3.Text = undoList.Count.ToString(); if (undoList.Count == 0) { Text0.Text = Text00.Text = "Enjoy your day ;-)"; } UpdateTileHelper.ClearAllSchedules(); if (undoList.Count <= 4) { await UpdateTileHelper.UpdatePersonalTile(WideGrid, MediumGrid, SmallGrid, false); } else { await UpdateTileHelper.UpdatePersonalTile(WideGrid, MediumGrid, SmallGrid, true); if (undoList.Count > 4) { Text0.Text = Text00.Text = undoList.ElementAtOrDefault(4) ?? ""; Text1.Text = Text01.Text = undoList.ElementAtOrDefault(5) ?? ""; Text2.Text = Text02.Text = undoList.ElementAtOrDefault(6) ?? ""; Text3.Text = Text03.Text = undoList.ElementAtOrDefault(7) ?? ""; await UpdateTileHelper.UpdatePersonalTile(WideGrid, MediumGrid, SmallGrid, true); } if (undoList.Count > 8) { Text0.Text = Text00.Text = undoList.ElementAtOrDefault(8) ?? ""; Text1.Text = Text01.Text = undoList.ElementAtOrDefault(9) ?? ""; Text2.Text = Text02.Text = undoList.ElementAtOrDefault(10) ?? ""; Text3.Text = Text03.Text = undoList.ElementAtOrDefault(11) ?? ""; await UpdateTileHelper.UpdatePersonalTile(WideGrid, MediumGrid, SmallGrid, true); } } } catch (Exception e) { var task = ExceptionHelper.WriteRecord(e); } }