Ejemplo n.º 1
0
        private void ControlBoxAddItem_Click(object sender, RoutedEventArgs e)
        {
            var addItemDialog = new AddItemDialog();

            addItemDialog.OkButton.Click += (okSender, args) =>
            {
                var card = trelloService.CreateCard(addItemDialog.TaskTitle.Text);
                TaskList.Add(new TaskItem(TaskList, card, addItemDialog.TaskTitle.Text, trelloService)
                {
                    TaskDescription = addItemDialog.TaskDescription.Text
                });
                addItemDialog.Close();
            };
            addItemDialog.ShowDialog();
        }
Ejemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();
            this.Title = "Work Horse";

            this.ControlBoxAddItem.Click += ControlBoxAddItem_Click;

            new ListViewDragDropManager <TaskItem>(this.TaskListBox);
            this.TaskListBox.MouseRightButtonUp += (sender, args) =>
            {
                var clickedTaskItem =
                    (TaskItem)
                    ((FrameworkElement)args.OriginalSource).DataContext;

                var editDlg = new AddItemDialog();
                editDlg.TaskTitle.Text       = clickedTaskItem.TaskName;
                editDlg.TaskDescription.Text = clickedTaskItem.TaskDescription;

                editDlg.OkButton.Click += (o, eventArgs) =>
                {
                    clickedTaskItem
                    .TaskDescription =
                        editDlg.TaskDescription
                        .Text;
                    clickedTaskItem
                    .TaskName =
                        editDlg.TaskTitle.Text;

                    editDlg.Close();
                };
                editDlg.ShowDialog();
            };

            TaskList = new ObservableCollection <TaskItem>();

            TaskList.CollectionChanged += (sender, args) =>
            {
                if (!initialLoadComplete)
                {
                    return;
                }

                if (args.Action == NotifyCollectionChangedAction.Remove)
                {
                    foreach (var oldItem in args.OldItems.Cast <TaskItem>())
                    {
                        trelloService.MoveCardToDone(oldItem.Card);
                    }
                }

                if (args.Action == NotifyCollectionChangedAction.Move)
                {
                    if (TaskList.Count == 1)
                    {
                        return;
                    }

                    var taskItem = args.OldItems.Cast <TaskItem>().Single();

                    double newPos;
                    if (args.NewStartingIndex == 0)
                    {
                        newPos = TaskList[1].Card.Pos / 2;
                    }
                    else if (args.NewStartingIndex == TaskList.Count - 1)
                    {
                        newPos = TaskList[args.NewStartingIndex - 1].Card.Pos + 10;
                    }
                    else
                    {
                        newPos = (TaskList[args.NewStartingIndex - 1].Card.Pos +
                                  TaskList[args.NewStartingIndex + 1].Card.Pos) / 2;
                    }

                    trelloService.ChangeCardPos(taskItem.Card, newPos);
                }
            };

            Dispatcher.BeginInvoke(DispatcherPriority.ContextIdle, new Action(onFinishedLoading));
        }
Ejemplo n.º 3
0
        public MainWindow()
        {
            InitializeComponent();
            this.Title = "Work Horse";

            this.ControlBoxAddItem.Click += ControlBoxAddItem_Click;

            new ListViewDragDropManager<TaskItem>(this.TaskListBox);
            this.TaskListBox.MouseRightButtonUp += (sender, args) =>
                                                       {
                                                           var clickedTaskItem =
                                                               (TaskItem)
                                                               ((FrameworkElement) args.OriginalSource).DataContext;

                                                           var editDlg = new AddItemDialog();
                                                           editDlg.TaskTitle.Text = clickedTaskItem.TaskName;
                                                           editDlg.TaskDescription.Text = clickedTaskItem.TaskDescription;

                                                           editDlg.OkButton.Click += (o, eventArgs) =>
                                                                                         {
                                                                                             clickedTaskItem
                                                                                                 .TaskDescription =
                                                                                                 editDlg.TaskDescription
                                                                                                        .Text;
                                                                                             clickedTaskItem
                                                                                                 .TaskName =
                                                                                                 editDlg.TaskTitle.Text;

                                                                                             editDlg.Close();
                                                                                         };
                                                           editDlg.ShowDialog();
                                                       };

            TaskList = new ObservableCollection<TaskItem>();

            TaskList.CollectionChanged += (sender, args) =>
                                              {
                                                  if (!initialLoadComplete) return;

                                                  if (args.Action == NotifyCollectionChangedAction.Remove)
                                                  {
                                                      foreach (var oldItem in args.OldItems.Cast<TaskItem>())
                                                      {
                                                          trelloService.MoveCardToDone(oldItem.Card);
                                                      }
                                                  }

                                                  if (args.Action == NotifyCollectionChangedAction.Move)
                                                  {
                                                      if (TaskList.Count == 1) return;

                                                      var taskItem = args.OldItems.Cast<TaskItem>().Single();

                                                      double newPos;
                                                      if (args.NewStartingIndex == 0)
                                                      {
                                                          newPos = TaskList[1].Card.Pos/2;
                                                      }
                                                      else if (args.NewStartingIndex == TaskList.Count - 1)
                                                      {
                                                          newPos = TaskList[args.NewStartingIndex - 1].Card.Pos + 10;
                                                      }
                                                      else
                                                      {
                                                          newPos = (TaskList[args.NewStartingIndex - 1].Card.Pos +
                                                                    TaskList[args.NewStartingIndex + 1].Card.Pos)/2;
                                                      }

                                                      trelloService.ChangeCardPos(taskItem.Card, newPos);
                                                  }
                                              };

            Dispatcher.BeginInvoke(DispatcherPriority.ContextIdle, new Action(onFinishedLoading));
        }
Ejemplo n.º 4
0
 private void ControlBoxAddItem_Click(object sender, RoutedEventArgs e)
 {
     var addItemDialog = new AddItemDialog();
     addItemDialog.OkButton.Click += (okSender, args) =>
                                         {
                                             var card = trelloService.CreateCard(addItemDialog.TaskTitle.Text);
                                             TaskList.Add(new TaskItem(TaskList, card, addItemDialog.TaskTitle.Text, trelloService){ TaskDescription = addItemDialog.TaskDescription.Text});
                                             addItemDialog.Close();
                                         };
     addItemDialog.ShowDialog();
 }