Пример #1
0
        public void DeleteTask()
        {
            object o = SlayerTasksView.SelectedItem;

            if (o == null)
            {
                return;
            }
            if (o is DailySlayerTaskList l)
            {
                MessageBoxResult result = MessageBox.Show("Are you sure you want to delete the daily?", "Delete Daily", MessageBoxButton.YesNo);
                if (result == MessageBoxResult.Yes)
                {
                    mainWindow.DailySlayerTasks.Remove(l);
                    SlayerTasksView.UpdateLayout();
                    TaskInfo.Text = "";
                }
            }
            if (o is SlayerTask task)
            {
                MessageBoxResult result = MessageBox.Show("Are you sure you want to delete this item?", "Delete", MessageBoxButton.YesNo);
                if (result == MessageBoxResult.Yes)
                {
                    task.GetOwner().Remove(task);
                    SlayerTasksView.UpdateLayout();
                    TaskInfo.Text = "";
                }
            }
        }
Пример #2
0
        public DailySlayerTaskList AddDaily()
        {
            string dateString = DateUtils.GetTodaysDate();// String.Format("{0}/{1}/{2}", dt.Day < 10 ? "0" + dt.Day.ToString() : dt.Day.ToString(), dt.Month < 10 ? "0" + dt.Month.ToString() : dt.Month.ToString(), dt.Year);

            foreach (var entry in SlayerTasksView.Items)
            {
                if (entry is DailySlayerTaskList list)
                {
                    if (list.TaskDate == dateString)
                    {
                        return(list);
                    }
                }
            }
            var newDaily = new DailySlayerTaskList();
            var tempList = new List <DailySlayerTaskList>(mainWindow.DailySlayerTasks);

            tempList.Add(newDaily);
            tempList = tempList.OrderByDescending(s => s.TaskDate).ToList();
            mainWindow.DailySlayerTasks = new System.Collections.ObjectModel.ObservableCollection <DailySlayerTaskList>(tempList);
            SlayerTasksView.ItemsSource = mainWindow.DailySlayerTasks;
            SlayerTasksView.UpdateLayout();
            return(newDaily);
        }