Ejemplo n.º 1
0
        public void ItemPreviewShow(KanbanColumn column)
        {
            if (this.DragDropPreviewShadow != null && this.DragDropPreviewShadow.Parent.Equals(column))
            {
                return;
            }
            Label itemPreviewShadow = GetItemPreviewShadow();

            column.Items.Insert(column.Items.Count, itemPreviewShadow);
            this.DragDropPreviewShadow = itemPreviewShadow;
        }
Ejemplo n.º 2
0
        public KanbanColumn AddColumn(StatusData status)
        {
            ColumnCount++;
            KanbanColumn column = new KanbanColumn(this, status);

            foreach (TaskData task in status.Tasks)
            {
                column.AddRow(task);
            }
            columns.Items.Add(column.AsBorderedColumn());
            return(column);
        }
Ejemplo n.º 3
0
        public void ItemPreviewShow(object sender, DragEventArgs e)
        {
            KanbanTaskCard target       = sender as KanbanTaskCard;
            Point          dropPosition = e.GetPosition(sender as IInputElement);
            bool           showBelow    = target.ActualHeight / 2 < dropPosition.Y;

            Label        itemPreviewShadow = GetItemPreviewShadow();
            KanbanColumn newColumn         = target.Parent as KanbanColumn;
            int          targetIndex       = newColumn.Items.IndexOf(target);

            newColumn.Items.Insert(showBelow ? targetIndex + 1 : targetIndex, itemPreviewShadow);
            this.DragDropPreviewShadow = itemPreviewShadow;
        }
Ejemplo n.º 4
0
        public void ItemPreviewRemove()
        {
            if (DragDropPreviewShadow == null)
            {
                return;
            }
            KanbanColumn column = DragDropPreviewShadow.Parent as KanbanColumn;

            if (column == null)
            {
                return;
            }
            column.Items.Remove(DragDropPreviewShadow);
            DragDropPreviewShadow = null;
        }
Ejemplo n.º 5
0
        public void ItemDrop(object sender, DragEventArgs e)
        {
            DragDropWindowRemove();
            if (DragDropPreviewShadow == null)
            {
                return;
            }

            KanbanColumn newColumn = DragDropPreviewShadow.Parent as KanbanColumn;
            int          index     = newColumn.Items.IndexOf(DragDropPreviewShadow);

            ItemPreviewRemove();
            if (e.Data.GetData(typeof(KanbanTaskCard)) is KanbanTaskCard cardItem && !cardItem.Equals(DragDropPreviewShadow))
            {
                MoveTaskCard(newColumn, cardItem, index);
            }
        }
Ejemplo n.º 6
0
        public void MoveTaskCard(KanbanColumn column, KanbanTaskCard item, int index)
        {
            KanbanColumn oldColumn = item.Parent as KanbanColumn;

            if (column.Equals(oldColumn) && column.Items.IndexOf(item) < index)
            {
                index--;
            }

            oldColumn.Items.Remove(item);
            column.AddRow(item.Data, index);
            item = null;

            oldColumn.UpdateHeader();
            column.UpdateHeader();

            oldColumn.SaveData();
            column.SaveData();
        }
Ejemplo n.º 7
0
        public KanbanTaskCard(KanbanBoard kanbanBoard, TaskData data)
        {
            Data             = data;
            this.kanbanBoard = kanbanBoard;

            Margin          = new Thickness(0);
            Padding         = new Thickness(3);
            BorderThickness = new Thickness(0);
            BorderBrush     = Brushes.SkyBlue;
            Selected       += (sender, e) => IsSelected = false;

            panel = new StackPanel
            {
                Orientation = Orientation.Vertical,
                MinHeight   = 20,
                MinWidth    = 240,
                Background  = Brushes.White
            };
            panel.MouseEnter           += (sender, e) => panel.Background = new SolidColorBrush(Color.FromArgb(255, 190, 230, 253));
            panel.MouseLeave           += (sender, e) => panel.Background = defaultBrush;
            panel.MouseRightButtonDown += (sender, e) => kanbanBoard.View.OpenCreateDialog(Data);

            if (Data.Status.IsBacklog)
            {
                Button button = new Button
                {
                    Content    = "Send to Board",
                    Margin     = new Thickness(5),
                    Padding    = new Thickness(5, 0, 5, 0),
                    Background = Brushes.LightSkyBlue
                };
                button.Click += (sender, e) =>
                {
                    KanbanColumn column = Parent as KanbanColumn;
                    column.Items.Remove(this);
                    column.UpdateHeader();

                    ProjectData project   = Data.Status.Project;
                    StatusData  newStatus = project.Statuses[0];

                    Data.Status.Tasks.Remove(Data);
                    newStatus.Tasks.Add(Data);
                    Data.Status = newStatus;

                    new TaskModel(Data).Save();
                };
                panel.Children.Add(data.GetBacklogGrid(button));
            }
            else
            {
                panel.Children.Add(data.GetNameGrid());
                panel.Children.Add(data.GetInfoGrid());
                panel.PreviewMouseLeftButtonDown += (sender, e) => ItemMouseDown(sender, e);
                PreviewDragOver += (sender, e) => kanbanBoard.ItemPreviewShow(sender, e);
                GiveFeedback    += (sender, e) => DragDropWindowUpdate();
                Drop            += (sender, e) => kanbanBoard.ItemDrop(sender, e);
                AllowDrop        = true;
            }
            panel.Children.Add(GetColorRectangle());
            Content = panel;
        }