Exemplo n.º 1
0
        public void ItemChanged(TodoItem item)
        {
            try
            {
                _MainWindow._SyncContext.Send(state =>
                {
                    TodoItem found = _MainWindow._TodoItems.First<TodoItem>(x => x.ID == item.ID);

                    found.PropertyChanged -= _MainWindow.Item_PropertyChanged;

                    found.CreationDate = item.CreationDate;
                    found.CompletionDate = item.CompletionDate;
                    found.Description = item.Description;
                    found.DueDate = item.DueDate;
                    found.Title = item.Title;
                    found.Priority = item.Priority;
                    found.PercentComplete = item.PercentComplete;
                    found.Status = item.Status;
                    found.Tags = item.Tags;

                    found.PropertyChanged += _MainWindow.Item_PropertyChanged;
                }, null);
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
                
        }
Exemplo n.º 2
0
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // Prepare the task creation panel
            PriorityComboBox.ItemsSource = TodoItemFlags.PriorityFlags;
            _NewTodo = new TodoItem { Priority = PriorityFlag.Normal, DueDate = DateTime.Today };
            NewItemPanel.DataContext = _NewTodo;

            _Proxy = new TodoListServiceProxy("default");

            try
            {
                _ToDoItems = _Proxy.GetItems();
                foreach (TodoItem item in _ToDoItems)
                {
                    item.PropertyChanged += Item_PropertyChanged;
                }

                TodoDataGrid.ItemsSource = _ToDoItems;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());

                throw;
            }
        }
Exemplo n.º 3
0
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {

            // Prepare the task creation panel
            PriorityComboBox.ItemsSource = TodoItem.PriorityFlags;
            _NewTodo = new TodoItem { Priority = PriorityFlag.Normal, DueDate = DateTime.Today };
            NewItemPanel.DataContext = _NewTodo;

            InitializeProxy();
            GetData();
        }
Exemplo n.º 4
0
        public void ItemAdded(TodoItem item)
        {
            try
            {
                Trace.WriteLine(string.Format("ItemAdded callback on thread {0}", Thread.CurrentThread.GetHashCode()));

                _MainWindow._SyncContext.Send(state =>
                {
                    _MainWindow._TodoItems.Add(item);
                }, null);
                
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///  Add a TodoItem
        /// </summary>
        private void AddTodoButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            try
            {
                _NewTodo.CreationDate = DateTime.Today;
                _NewTodo.Description = DescriptionTextBox.Text;
                _NewTodo.DueDate = DueDatePicker.SelectedDate.GetValueOrDefault(DateTime.Today);
                _NewTodo.Title = TitleTextBox.Text;
                _NewTodo.Priority = (PriorityFlag) PriorityComboBox.SelectedItem;

                _NewTodo.ID = _Proxy.CreateItem(_NewTodo);

                _NewTodo.PropertyChanged += Item_PropertyChanged;
                _TodoItems.Add(_NewTodo);
                
                _NewTodo = new TodoItem { Priority = PriorityFlag.Normal, DueDate = DateTime.Today };
                NewItemPanel.DataContext = _NewTodo;

                
                TitleTextBox.Focus();
            }
            catch (Exception ex)
            {
                DescriptionTextBox.Text = _NewTodo.Description;
                TitleTextBox.Text = _NewTodo.Title;
                MessageBox.Show(ex.Message);
            }

        }