private void flowLayoutPanelBoardList_DragDrop(object sender, DragEventArgs e) { Boards element = e.Data.GetData("Object") as Boards; if (element == null) { return; } Point p = flowLayoutPanelBoardList.PointToClient(new Point(e.X, e.Y)); Boards item = flowLayoutPanelBoardList.GetChildAtPoint(p) as Boards; if (item == null) { item = listBoards[listBoards.Count - 1]; } int indexi = flowLayoutPanelBoardList.Controls.GetChildIndex(item, false); int indexe = flowLayoutPanelBoardList.Controls.GetChildIndex(element, false); flowLayoutPanelBoardList.Controls.SetChildIndex(element, indexi); flowLayoutPanelBoardList.Controls.SetChildIndex(item, indexe); indexi = listBoards.IndexOf(item); indexe = listBoards.IndexOf(element); Boards temp = listBoards[indexi]; listBoards[indexi] = listBoards[indexe]; listBoards[indexe] = temp; ResetBoardPosition(); }
private void CardListPanel_DragDrop(object sender, DragEventArgs e) { Card element = e.Data.GetData("Object") as Card; Point p = CardListPanel.PointToClient(new Point(e.X, e.Y)); Card item = CardListPanel.GetChildAtPoint(p) as Card; if (element == null) { return; } if (element == item) { return; } if (element.Parent as FlowLayoutPanel == CardListPanel) { if (item == null) { item = listCard[listCard.Count - 1]; } int indexi = CardListPanel.Controls.GetChildIndex(item, false); int indexe = CardListPanel.Controls.GetChildIndex(element, false); CardListPanel.Controls.SetChildIndex(element, indexi); CardListPanel.Controls.SetChildIndex(item, indexe); indexi = listCard.IndexOf(item); indexe = listCard.IndexOf(element); Card temp = listCard[indexi]; listCard[indexi] = listCard[indexe]; listCard[indexe] = temp; ResetCardPosition(); } else { if (IsObserve == true) { element.BackColor = Color.Yellow; } else { element.BackColor = Color.White; } if (item == null) { Data.CardProp _cardProp = new Data.CardProp(); _cardProp.Card_Name = element.cardProp.Card_Name; _cardProp.Card_Observing = IsObserve; _cardProp.Card_Description = element.cardProp.Card_Description; _cardProp.List_ID = listProp.List_ID; _cardProp.Card_ID = element.cardProp.Card_ID; ((element.Parent as FlowLayoutPanel).Parent as Lists).listCard.Remove(element); listCard.Add(element); CardListPanel.Controls.Clear(); for (int i = 0; i < listCard.Count; i++) { CardListPanel.Controls.Add(listCard[i]); listCard[i].Deleted += Card_Deleted; } CardListPanel.Controls.Add(ButtonAddCard); _cardProp.Card_Position = CardListPanel.Controls.GetChildIndex(listCard[listCard.Count - 1]); Data.DataService.UpdateCard(_cardProp); } else { listCard.Add(element); element.Deleted += Card_Deleted; ((element.Parent as FlowLayoutPanel).Parent as Lists).listCard.Remove(element); List <Card> temp = new List <Card>(); for (int i = 0; i < listCard.Count; i++) { if (i < listCard.IndexOf(item)) { temp.Add(listCard[i]); } else if (i > listCard.IndexOf(item)) { temp.Add(listCard[i - 1]); } else { temp.Add(element); } } listCard.Clear(); listCard = temp; CardListPanel.Controls.Remove(ButtonAddCard); CardListPanel.Controls.Clear(); for (int i = 0; i < listCard.Count; i++) { CardListPanel.Controls.Add(listCard[i]); } CardListPanel.Controls.Add(ButtonAddCard); } } }