コード例 #1
0
        public NotesControl(TaskControl inParentTaskControl, Workspace.Task inTask)
        {
            mParentTaskControl = inParentTaskControl;
            mTask = inTask;

            InitializeComponent();
        }
コード例 #2
0
        public ExternalLinkControl(TaskControl inParentTask, Workspace.ExternalLink inExternalLink)
        {
            mExternalLink      = inExternalLink;
            mParentTaskControl = inParentTask;

            InitializeComponent();
        }
コード例 #3
0
        private void TaskControl_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left && mIsDragging)
            {
                Control control = sender as Control;
                OnDragTaskControlStopped(mClickedTaskControl);
                control.ReleaseMouseCapture();
                mIsDragging         = false;
                mClickedTaskControl = null;

                e.Handled = true;
            }
        }
コード例 #4
0
        public void MoveTaskControlToPileControl(TaskControl inTaskControl, PileControl inDestinationPileControl, int inDestinationTaskControlIndex)
        {
            // Remove from this pile
            this.stackPanel.Children.Remove(inTaskControl);
            this.mPile.RemoveTask(inTaskControl.Task);

            // Add to destination pile (at the correct position)
            inDestinationPileControl.stackPanel.Children.Insert(inDestinationTaskControlIndex, inTaskControl);
            inDestinationPileControl.mPile.InsertTask(inDestinationTaskControlIndex - 2, inTaskControl.Task);

            // Set new parent pile
            inTaskControl.ParentPileControl = inDestinationPileControl;
        }
コード例 #5
0
        private void TaskControl_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                Control control = sender as Control;
                mClickedTaskControl = GetOwnerTaskControlFromControl(control);
                mClickedPileControl = null;
                mClickedPosition    = e.GetPosition(Parent as IInputElement);
                mIsDragging         = true;
                OnDragTaskControlStarted(mClickedTaskControl);
                control.CaptureMouse();

                e.Handled = true;
            }
        }
コード例 #6
0
        private void MoveButton_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                mClickedTaskControl = null;
                mClickedPileControl = this;
                mClickedPosition    = e.GetPosition(Parent as IInputElement);

                mIsDragging = true;
                (sender as Label).CaptureMouse();

                OnDragPileControlStarted(mClickedPileControl);

                e.Handled = true;
            }
        }
コード例 #7
0
        private TaskControl AddNewTaskControl(Workspace.Task inTask)
        {
            int index = mPile.Tasks.IndexOf(inTask);

            if (index < 0)
            {
                index = mPile.Tasks.Count;
            }

            TaskControl task_control = new TaskControl(this, inTask);

            stackPanel.Children.Insert(2 + index, task_control);

            task_control.moveButton.MouseDown += TaskControl_MouseDown;
            task_control.moveButton.MouseUp   += TaskControl_MouseUp;
            task_control.moveButton.MouseMove += TaskControl_MouseMove;

            return(task_control);
        }
コード例 #8
0
        private void Pile_OnDragTaskStopped(TaskControl inTask)
        {
            if (!mDragging)
            {
                return;
            }

            Cursor = mDragPreviousCursor;

            foreach (PileControl pile in PileControls)
            {
                foreach (TaskControl task in pile.TaskControls)
                {
                    task.DragState = TaskControl.EDragState.NoDraggingActive;
                }
            }

            mDragging = false;
        }
コード例 #9
0
        private void Pile_OnDragTaskStarted(TaskControl inTask)
        {
            mDraggedTask = inTask;

            //mDraggedTask.CaptureMouse();
            mDragPreviousCursor = Cursor;
            Cursor = Cursors.Hand;

            // Update dragging state of all tasks
            foreach (PileControl pile in PileControls)
            {
                foreach (TaskControl task in pile.TaskControls)
                {
                    task.DragState = (task == mDraggedTask) ? TaskControl.EDragState.IsBeingDragged : TaskControl.EDragState.IsNotBeingDragged;
                }
            }

            mDragging = true;
        }
コード例 #10
0
 public void DeleteTaskAndControl(TaskControl inTaskControl)
 {
     mPile.RemoveTask(inTaskControl.Task);
     stackPanel.Children.Remove(inTaskControl);
 }
コード例 #11
0
        private void Pile_OnDragTaskMoved(TaskControl inTask, Point inPosition)
        {
            if (!mDragging)
            {
                return;
            }

            // Determine from which pile we're dragging
            int         current_pile_index = -1;
            PileControl current_pile       = null;

            for (int j = 0; j < stackPanel.Children.Count - 1; ++j)
            {
                PileControl pile = stackPanel.Children[j] as PileControl;
                if (pile.stackPanel.Children.Contains(mDraggedTask))
                {
                    current_pile_index = j;
                    current_pile       = pile;
                    break;
                }
            }

            // Determine which task we're dragging
            int current_task_ctrl_index = current_pile.stackPanel.Children.IndexOf(mDraggedTask);

            // Find out where to place our task
            Point mouse_pos = inPosition;

            // Determine pile to place task in
            double pile_width = (stackPanel.Children[0] as PileControl).Width; // Child 0 is always the header of the pile
            int    num_piles  = stackPanel.Children.Count - 1;

            int         preferred_pile_index = Math.Min((int)(mouse_pos.X / pile_width), num_piles - 1);
            PileControl preferred_pile       = stackPanel.Children[preferred_pile_index] as PileControl;

            // Determine task index we're trying to move our task to
            int preferred_task_ctrl_index = -1;

            if (preferred_pile.stackPanel.Children.Count >= 3)
            {
                if (preferred_pile_index == current_pile_index)
                {
                    double cur_top_y = mDraggedTask.TransformToAncestor(current_pile.stackPanel).Transform(new Point(0, 0)).Y;
                    double cur_h     = mDraggedTask.ActualHeight;

                    // If our mouse is still within the task that we're dragging, no need to move it.
                    if (mouse_pos.Y >= cur_top_y && mouse_pos.Y < cur_top_y + cur_h)
                    {
                        preferred_task_ctrl_index = current_task_ctrl_index;
                    }
                }

                if (preferred_task_ctrl_index < 0)
                {
                    double top_y = preferred_pile.stackPanel.Children[2].TransformToAncestor(stackPanel).Transform(new Point(0, 0)).Y;
                    preferred_task_ctrl_index = 2;

                    for (int i = 2; i < preferred_pile.stackPanel.Children.Count; ++i)
                    {
                        UIElement element = preferred_pile.stackPanel.Children[i];
                        if (element == mDraggedTask)
                        {
                            continue;
                        }

                        double h = (preferred_pile.stackPanel.Children[i] as FrameworkElement).ActualHeight;

                        if (mouse_pos.Y < top_y + h && mouse_pos.Y >= top_y)
                        {
                            break;
                        }

                        top_y += h;
                        preferred_task_ctrl_index++;
                    }
                }
            }
            // Our destination pile is still empty, add task to bottom.
            else
            {
                preferred_task_ctrl_index = preferred_pile.stackPanel.Children.Count;
            }

            // Move dragged task to a different pile? Or move dragged task to different spot in same pile?
            if (current_pile_index != preferred_pile_index || current_task_ctrl_index != preferred_task_ctrl_index)
            {
                current_pile.MoveTaskControlToPileControl(mDraggedTask, preferred_pile, preferred_task_ctrl_index);
            }
        }