Esempio n. 1
0
        /// <summary>
        /// Обработка события прокрутки влево или вправо.
        /// </summary>
        /// <param name="sender">источник вызова</param>
        /// <param name="e">дополнительные параметры</param>
        private async void OnSwipeEnded(object sender, EventArgs e)
        {
            //Удаление задачи для прокрутки вправо
            if ((e as SwipeEndedEventArgs).SwipeDirection == SwipeDirection.Right)
            {
                bool accept = await DisplayAlert("Удалить задачу?", "Задача будет удалена из Вашего списка.", "ОК", "Отмена");

                if (accept)
                {
                    IsCheckBoxEventExecuted = false;
                    Task task = ((sender as SwipeView).Parent as ViewCell).BindingContext as Task;
                    TasksList.Remove(task);
                    User.Tasks.Remove(task);
                    User.DeletedTasks.Add(task);
                    RefreshCategories();
                }
            }
            //Редактирование задачи для прокрутки влево
            else if ((e as SwipeEndedEventArgs).SwipeDirection == SwipeDirection.Left)
            {
                if ((((sender as SwipeView).Parent as ViewCell).BindingContext as Task).IsCompleted)
                {
                    await DisplayAlert("Вы уже выполнили задачу", "Нельзя изменить завершенную задачу", "OK");
                }
                else
                {
                    await Navigation.PushAsync(new EditTaskPage(((sender as SwipeView).Parent as ViewCell).BindingContext as Task));
                }
            }
            (sender as SwipeView).Close();
            IsCheckBoxEventExecuted = true;
        }
        internal async System.Threading.Tasks.Task RemoveTaskAsync(Model.Task task)
        {
            var result = await Client.HttpClient.DeleteAsync("http://localhost:65177/api/Task/" + task.Id);

            if (result.IsSuccessStatusCode)
            {
                TasksList.Remove(task);
            }
            //TODO Backend implementation
        }
 private void DeteleTaskButton_Click(object sender, RoutedEventArgs e)
 {
     if (SelectedTask != null)
     {
         if (MessageBox.Show("Are you sure you want to delete this task?", "Delete task",
                             MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
         {
             TasksList.Remove(SelectedTask);
         }
     }
 }
Esempio n. 4
0
        private void RemoveTask(ITask taskToRemove)
        {
            var parentTask = TaskHelper.FindParentTask(TasksList, taskToRemove);

            if (parentTask != null)
            {
                parentTask.SubTasks.Remove(taskToRemove);
                return;
            }

            TasksList.Remove(taskToRemove);
        }
Esempio n. 5
0
        private async void DeleteTask(object taskObj)
        {
            TasksViewModel taskD = taskObj as TasksViewModel;

            if (taskD != null && taskD.isValid())
            {
                bool        delRes = false;
                TaskService ts     = new TaskService();
                delRes = await ts.DeleteAsync(taskD.task);

                if (delRes)
                {
                    TasksList.Remove(taskD);
                }
            }
            Back();
        }
 private void DeleteFromList(TasksViewModel t)
 {
     TasksList.Remove(t);
     TasksViewModel.WriteToTaskList(TasksList);
     ReadList();
 }