private void itemListPanel_DragDrop(object sender, DragEventArgs e) { CheckListItemUserControl data = (CheckListItemUserControl)e.Data.GetData(typeof(CheckListItemUserControl)); if (data == null) { return; } FlowLayoutPanel target = (FlowLayoutPanel)sender; FlowLayoutPanel source = (FlowLayoutPanel)data.Parent; if (source != target) { // Add control to panel target.Controls.Add(data); // Reorder Point p = target.PointToClient(new Point(e.X, e.Y)); var item = target.GetChildAtPoint(p); int index = target.Controls.GetChildIndex(item, false); target.Controls.SetChildIndex(data, index); CheckListUserControl checkListUserControl = target.Parent.Parent.Parent as CheckListUserControl; Board.Data.ItemProp _itemProp = new Board.Data.ItemProp(); _itemProp.Item_Checked = data.itemProp.Item_Checked; _itemProp.Item_Description = data.itemProp.Item_Description; _itemProp.Item_Position = index; _itemProp.CheckList_ID = checkListUserControl.checkListProp.CheckList_ID; _itemProp.Item_ID = data.itemProp.Item_ID; Board.Data.DataService.UpdateItem(_itemProp); OnReset(); // Invalidate to paint! target.Invalidate(); source.Invalidate(); } else { // Just add the control to the new panel. // No need to remove from the other panel, this changes the Control.Parent property. Point p = target.PointToClient(new Point(e.X, e.Y)); var item = target.GetChildAtPoint(p); int index = target.Controls.GetChildIndex(item, false); target.Controls.SetChildIndex(data, index); target.Invalidate(); ResetItemPosition(); } }
public void SpawnItem(Board.Data.ItemProp itemProp) { CheckListItemUserControl item = new CheckListItemUserControl(); item.ItemDone += OnItemDone; item.ItemDeleted += OnItemDeleted; item.LoadData(itemProp); itemListPanel.Controls.Add(item); itemListPanel.Controls.SetChildIndex(item, itemProp.Item_Position); roundedProgressBar.Denominator += 1; roundedProgressBar.Animate(); percentageNumberLabel.Text = Convert.ToInt32(roundedProgressBar.Value).ToString() + "%"; }