示例#1
0
        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);
            }
        }
示例#2
0
 private void TargetRemoved(object sender, SimpleTaskCard e)
 {
     if (!e.IsFinsh)
     {
         SimpleTaskCard card = (SimpleTaskCard)sender;
         _ = HttpApi.DeleteTask(card.Id);
     }
     todayTargetsList.Children.Remove(e);
 }
示例#3
0
        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);
            }
        }
示例#4
0
        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);
            }
        }
示例#5
0
        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");
            }
        }