private async void AddNewPlanTarget(object sender, RoutedEventArgs e) { if (!HasNotEmptySetting()) { ShowMessage("请填写用户信息", false); return; } newPlanTargetName.Text = newPlanTargetName.Text.Trim(); if (newPlanTargetName.Text == "") { return; } try { AppTask task = await HttpApi.CreateTask(newPlanTargetName.Text, AppTask.TypeToString(TaskType.Todo), date : newPlanTargetDeadline.SelectedDate?.AddDays(1).Date.ToString()); SimpleTaskCard card = task.ToSimpleTaskCard(false); card.CardRemove += TargetRemoved; card.StatusChange += TargetStatusChange; planTargetsList.Children.Add(card); planTargetsListScroll.ScrollToBottom(); newPlanTargetName.Text = ""; } catch (Exception exception) { ShowMessage(exception.Message, false); } }
private void TargetRemoved(object sender, SimpleTaskCard e) { if (!e.IsFinsh) { SimpleTaskCard card = (SimpleTaskCard)sender; _ = HttpApi.DeleteTask(card.Id); } todayTargetsList.Children.Remove(e); }
private void InitPlanTargetList() { List <AppTask> planTargetTasks = HttpApi.PlanTargetTaskFilter(Tasks, TodayTargetTag); foreach (AppTask task in planTargetTasks) { SimpleTaskCard card = task.ToSimpleTaskCard(true); card.CardRemove += TargetRemoved; card.StatusChange += TargetStatusChange; planTargetsList.Children.Add(card); } }
private void InitDailyTargetList() { List <AppTask> dailyTargetTasks = HttpApi.DailyTargetTaskFilter(Tasks); foreach (AppTask task in dailyTargetTasks) { SimpleTaskCard card = task.ToSimpleTaskCard(false); card.CardRemove += TargetRemoved; card.StatusChange += TargetStatusChange; dailyTargetsList.Children.Add(card); } }
private void TargetStatusChange(object sender, SimpleTaskCard.Status e) { SimpleTaskCard card = (SimpleTaskCard)sender; if (e == SimpleTaskCard.Status.Finish) { _ = HttpApi.ScoreTask(card.Id, "up"); } else if (e == SimpleTaskCard.Status.Process) { _ = HttpApi.ScoreTask(card.Id, "down"); } }