예제 #1
0
        //private helper functions
        // copy the task list into an observable collection of list names
        private void UpdateView()
        {
            Log.Instance.LogDebug("DataGridViewModel.UpdateView");

            PropertyTasks.CollectionChanged -= OnViewChanged;

            PropertyTasks.Clear();

            if (CurrentTaskList >= 0)
            {
                for (int i = 0; i < TaskListGroup.NumTasks(CurrentTaskList); i++)
                {
                    TaskView tv = new TaskView(
                        TaskListGroup.GetTask(CurrentTaskList, i),
                        TaskListGroup.GetTaskColour(CurrentTaskList, i),
                        TaskListGroup.GetTaskNote(CurrentTaskList, i));
                    tv.PropertyChanged += OnTaskEdited;

                    PropertyTasks.Add(tv);
                }
            }

            PropertyTasks.CollectionChanged += OnViewChanged;

            RaisePropertyChanged("Tasks");
        }
예제 #2
0
        private void OnAddNewTask(object parameter)
        {
            Log.Instance.LogInfo(string.Format("DataGridViewModel.OnAddNewTask {0}", parameter));

            TextBox t = parameter as TextBox;

            if (t != null)
            {
                string s = t.Text;
                Log.Instance.LogInfo(string.Format("DataGridViewModel.OnAddNewTask {0}", s));

                t.Clear();

                if (TaskListGroup != null)
                {
                    if (s.Length > 0)
                    {
                        PropertyTasks.Insert(0, new TaskView(s, "Black", ""));
                        RaisePropertyChanged("Tasks");
                    }
                    else
                    {
                        Log.Instance.LogMsg("DataGridViewModel.OnAddNewTask - task is empty, skipping");
                    }
                }
                else
                {
                    Log.Instance.LogDebug("DataGridViewModel.OnAddNewTask - TaskListGroup is null, skipping");
                }
            }
            else
            {
                Log.Instance.LogError("DataGridViewModel.OnAddNewTask - parameter is not a TextBox");
            }
        }
예제 #3
0
        public void OnPreviewMouseMove(DataGrid dg, Canvas c, MouseEventArgs e)
        {
            if (IsLeftMouseDown && !IsEditingTask)
            {
                if (!IsDragging)
                {
                    if ((System.Math.Abs(MouseDownPosition.X - e.GetPosition(c).X) > SystemParameters.MinimumHorizontalDragDistance) ||
                        (System.Math.Abs(MouseDownPosition.Y - e.GetPosition(c).Y) > SystemParameters.MinimumVerticalDragDistance))
                    {
                        int index = getIndexUnderCursor(dg, c, MouseDownPosition);
                        if (index >= 0)
                        {
                            Log.Instance.LogInfo(string.Format("Started dragging"));

                            IsDragging       = true;
                            LastDragPosition = index;

                            Mouse.Capture(c);
                            dg.IsHitTestVisible = false;
                        }
                    }
                }
            }

            if (IsDragging)
            {
                int curDragPosition = getIndexUnderCursor(dg, c, e.GetPosition(c));

                if ((curDragPosition >= 0) && (curDragPosition != LastDragPosition))
                {
                    PropertyTasks.Move(LastDragPosition, curDragPosition);

                    LastDragPosition = curDragPosition;
                }
            }
        }
예제 #4
0
 public void DeleteTask(int taskIndex)
 {
     Log.Instance.LogDebug(string.Format("DataGridViewModel.DeleteTask - deleting task number {0}", taskIndex));
     PropertyTasks.RemoveAt(taskIndex);
     RaisePropertyChanged("Tasks");
 }