Example #1
0
        public void Add()
        {
            var itemWindow = new ToDoItemWindow(_projectId);

            if (this is TodayToDoItemOperations)
            {
                itemWindow.ShowDialog(DateTime.Today);
            }
            else
            {
                itemWindow.ShowDialog();
            }

            if (itemWindow.DialogResult == false)
            {
                return;
            }

            itemWindow.Item.ProjectId = _projectId;

            ItemService.Add(itemWindow.Item);

            if (itemWindow.Item.Id != -1 && IsCorrect(itemWindow.Item))
            {
                _toDoItemsCollection.Add(itemWindow.Item);
            }
            else if (itemWindow.Item.Id == -1)
            {
                return;
            }

            _tagService.ReplaceItemsTags(itemWindow.Item.Id, itemWindow.SelectedTagsId);
        }
        private void OpenToDoItemWindow(object obj)
        {
            if (toDoWindow != null)
            {
                toDoWindow.Activate();
                return;
            }
            //Open Selected ToDoItem or Add New ToDoItem if not selected
            ToDoItem item = obj as ToDoItem ?? new ToDoItem();

            toDoWindow             = new ToDoItemWindow();
            toDoWindow.Closed     += (o, e) => toDoWindow = null;
            toDoWindow.DataContext = new ToDoItemVM(item, LoadToDoItems);
            toDoWindow.Show();
        }
Example #3
0
        public void Selected()
        {
            var index = _toDoItemsListView.SelectedIndex;

            if (index == -1)
            {
                return;
            }

            var item       = _toDoItemsCollection[index];
            var itemWindow = new ToDoItemWindow(_projectId, item);

            _toDoItemsListView.SelectedItem = null;

            itemWindow.ShowDialog();

            if (itemWindow.ToDelete)
            {
                if (ItemService.Remove(item))
                {
                    _toDoItemsCollection.Remove(item);
                }

                return;
            }

            // User closed a window.
            if (itemWindow.DialogResult == false)
            {
                return;
            }

            itemWindow.Item.ProjectName = item.ProjectName;

            ItemService.Update(itemWindow.Item);

            if (IsCorrect(itemWindow.Item))
            {
                _toDoItemsCollection[index] = itemWindow.Item;
            }
            else
            {
                _toDoItemsCollection.Remove(item);
            }

            _tagService.ReplaceItemsTags(item.Id, itemWindow.SelectedTagsId);
        }