Example #1
0
        public TaskListViewModel()
        {
            OnPropertyChanged(nameof(Items));

            RefreshCommand = new RelayCommand(() => Refresh());

            if (IoCContainer.Get <ApplicationViewModel>().Tasks.Count >= 0)
            {
                foreach (var task in IoCContainer.Get <ApplicationViewModel>().Tasks)
                {
                    Items.Add(
                        new TaskListItemViewModel
                    {
                        Task     = task,
                        Title    = task.Title,
                        Contents = task.Contents,
                        EndDate  = task.EndDate,
                        Priority = task.Priority
                    });
                }
            }

            var AVM = IoCContainer.Get <ApplicationViewModel>();

            AVM.Tasks.CollectionChanged += (s, e) => Refresh();
        }
        public void ChangeList(object parameter)
        {
            TaskState p = (TaskState)(Convert.ToInt32(parameter));

            IoCContainer.Get <ApplicationViewModel>().CurrentTaskType = p;
            IoCContainer.Get <ApplicationViewModel>().RefreshTasks();
        }
Example #3
0
        public void Delete()
        {
            SQLConnectionHandler.Instance.DeleteTask(ID);

            IoCContainer.Get <ApplicationViewModel>().CurrentTask = null;

            IoCContainer.Get <ApplicationViewModel>().RefreshTasks();

            IoCContainer.Get <ApplicationViewModel>().CurrentPage = ApplicationPage.Start;
        }
Example #4
0
        public void MoveTo(object p)
        {
            TaskState s = (TaskState)(Convert.ToInt32(p));

            SQLConnectionHandler.Instance.MoveTask(ID, s);

            IoCContainer.Get <ApplicationViewModel>().CurrentTaskType = s;
            IoCContainer.Get <ApplicationViewModel>().RefreshTasks();

            Refresh();
        }
        private void Add()
        {
            RequiredNotFilled = CheckRequired();

            if (!RequiredNotFilled)
            {
                Core.Priority p = Core.Priority.Normal;
                TaskState     s = TaskState.New;
                switch (Priority)
                {
                case 0:
                    p = Core.Priority.Low;
                    break;

                case 1:
                    p = Core.Priority.Normal;
                    break;

                case 2:
                    p = Core.Priority.High;
                    break;
                }
                switch (State)
                {
                case 0:
                    s = TaskState.New;
                    break;

                case 1:
                    s = TaskState.Progress;
                    break;

                case 2:
                    s = TaskState.Finished;
                    break;
                }

                Task toAdd = new Task(0, Title, Contents, DateTime.Today, End, p, s);

                SQLConnectionHandler.Instance.AddTask(toAdd);

                ApplicationViewModel AVM = IoCContainer.Get <ApplicationViewModel>();

                AVM.CurrentTaskType = toAdd.State;

                AVM.RefreshTasks();

                AVM.CurrentPage = ApplicationPage.Start;
            }
        }
        private void Save()
        {
            Priority  p = Core.Priority.Normal;
            TaskState s = TaskState.New;

            switch (Priority)
            {
            case 0:
                p = Core.Priority.Low;
                break;

            case 1:
                p = Core.Priority.Normal;
                break;

            case 2:
                p = Core.Priority.High;
                break;
            }
            switch (State)
            {
            case 0:
                s = TaskState.New;
                break;

            case 1:
                s = TaskState.Progress;
                break;

            case 2:
                s = TaskState.Finished;
                break;
            }

            Task toEdit = new Task(TaskID, Title, Contents, DateTime.Today, EndDate, p, s);

            SQLConnectionHandler.Instance.EditTask(toEdit);

            IoCContainer.Get <ApplicationViewModel>().CurrentTaskType = toEdit.State;

            IoCContainer.Get <ApplicationViewModel>().RefreshTasks();

            IoCContainer.Get <ApplicationViewModel>().CurrentTask = toEdit;

            IoCContainer.Get <ApplicationViewModel>().CurrentPage = ApplicationPage.Task;
        }
Example #7
0
 public void Refresh()
 {
     Items.Clear();
     if (IoCContainer.Get <ApplicationViewModel>().Tasks.Count > 0)
     {
         foreach (Task task in IoCContainer.Get <ApplicationViewModel>().Tasks)
         {
             Items.Add(
                 new TaskListItemViewModel
             {
                 Task     = task,
                 Title    = task.Title,
                 Contents = task.Contents,
                 EndDate  = task.EndDate,
                 Priority = task.Priority
             });
         }
     }
 }
Example #8
0
        void Refresh()
        {
            Task ct = IoCContainer.Get <ApplicationViewModel>().CurrentTask;

            IoCContainer.Get <ApplicationViewModel>().CurrentTaskViewModel = this;

            if (ct != null)
            {
                ID       = ct.ID;
                Title    = ct.Title;
                Contents = ct.Contents;
                Added    = ct.StartDate;
                End      = ct.EndDate;
                Priority = ct.Priority;
                State    = ct.State;

                RefreshNotes();
            }
        }
        public EditViewModel()
        {
            Task task = IoCContainer.Get <ApplicationViewModel>().CurrentTask;

            TaskID   = task.ID;
            Title    = task.Title;
            Contents = task.Contents;
            EndDate  = task.EndDate;
            Priority = (int)task.Priority;
            State    = (int)task.State;


            OnPropertyChanged(nameof(Title));
            OnPropertyChanged(nameof(Contents));
            OnPropertyChanged(nameof(EndDate));
            OnPropertyChanged(nameof(Priority));
            OnPropertyChanged(nameof(State));

            SaveCommand = new RelayCommand(() => Save());
        }
Example #10
0
        public TaskViewModel()
        {
            OnPropertyChanged(nameof(Title));
            OnPropertyChanged(nameof(Contents));
            OnPropertyChanged(nameof(Added));
            OnPropertyChanged(nameof(End));
            OnPropertyChanged(nameof(Priority));
            OnPropertyChanged(nameof(State));
            OnPropertyChanged(nameof(AddBtnVisiblity));
            OnPropertyChanged(nameof(NoteTBVisibility));
            OnPropertyChanged(nameof(NoteText));
            OnPropertyChanged(nameof(Notes));

            Refresh();

            AddNoteCommand  = new RelayCommand(() => AddNote());
            SaveNoteCommand = new RelayCommand(() => SaveNote());
            EditCommand     = new RelayCommand(() => Edit());
            DeleteCommand   = new RelayCommand(() => Delete());
            MoveToCommand   = new RelayParameterizedCommand((parameter) => MoveTo(parameter));

            IoCContainer.Get <ApplicationViewModel>().PropertyChanged += (s, e) => Refresh();
        }
 public void Sort()
 {
     IoCContainer.Get <ApplicationViewModel>().OrderType = Order;
     IoCContainer.Get <ApplicationViewModel>().SortTasks();
 }
 public void Add()
 {
     IoCContainer.Get <ApplicationViewModel>().CurrentPage = ApplicationPage.Adding;
 }
Example #13
0
        public void Delete()
        {
            SQLConnectionHandler.Instance.DeleteNote(ID);

            IoCContainer.Get <ApplicationViewModel>().CurrentTaskViewModel.RefreshNotes();
        }
Example #14
0
 public void Edit()
 {
     IoCContainer.Get <ApplicationViewModel>().CurrentPage = ApplicationPage.Editing;
 }