private void Vbracket_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { System.Windows.Forms.Control c = e.Data.GetData(e.Data.GetFormats()[0]) as System.Windows.Forms.Control; // find parent control (Vcont FlowLayout Panel), max parent is "grandfather" System.Windows.Forms.Control Parent; if (c.Name.Contains("Cont")) { Parent = c; } else if (c.Parent.Name.Contains("Cont")) { Parent = c.Parent; } else { Parent = c.Parent.Parent; } // Extract Contender ID int ContID = (int)MartialArts.Helpers.extractNumberFromString(Parent.Name); // check if contender is allready belongs to this bracket if (Bracket.ContendersList.Any(x => x.SystemID == ContID)) { return; } // Extract cont VisualContender visualcont = VisualLeagueEvent.AllVisualContenders.Where(x => x.Contender.SystemID == ContID).Select(x => x).Single(); // check if the contender score is suitable for bracket of not promt the user if (CheckContTransffer(visualcont) == false) { return; } // Its the header ( Vbracket FlowLayoutPanel child, hence we use Parent.Controls.Add) ((System.Windows.Forms.Control)sender).Parent.Controls.Add(Parent); VisualLeagueEvent.AddContender(ContID, this); }
private void PasteVisualContender() { // Extract Contender ID int ContID = VisualLeagueEvent.ClipBoardValue; // check if contender is allready belongs to this bracket if (Bracket.ContendersList.Any(x => x.SystemID == ContID)) { return; } // Extract cont VisualContender visualcont = VisualLeagueEvent.AllVisualContenders.Where(x => x.Contender.SystemID == ContID).Select(x => x).Single(); // check if the contender score is suitable for bracket of not promt the user if (CheckContTransffer(visualcont) == false) { return; } // add to fpanel Vbracket.Controls.Add(visualcont.Vcontender); VisualLeagueEvent.AddContender(ContID, this); }