public static void MergeListsForSearch() { if (AllVisualContenders == null) { AllVisualContenders = new List <VisualContender>(); } IsMerged = true; AllVisualContenders = VisualBracketsList.SelectMany(x => x.VisualCont).Select(y => y).ToList(); // add the unplaced foreach (VisualContender c in VisualUnplacedBracketsList) { AllVisualContenders.Add(c); } }
/// <summary> /// add contender to visual bracket or to unplaced list /// </summary> /// <param name="sysid"></param> /// <param name="b">if null contender is moving to uplaced list</param> public static void AddContender(int sysid, VisualBracket b = null) { var VisualContender = AllVisualContenders.AsEnumerable().Where(x => x.Contender.SystemID == sysid).Single(); // first remove from current bracket if contender is not from unplaced panel RemoveContender(sysid); // TODO: DISCOVER BUG: there is a very rare unknown bug, probably somthing with the drag and drop, // the bug creates contender that exist twice, in the GUI the user dont see it, but in the lists he exist twice // very rare bug and its hard to dicover it // the if steatment should solve it as a quick fix if (VisualBracketsList.SelectMany(x => x.Bracket.ContendersList).Any(x => x.SystemID == sysid) == true) { return; } if (b == null) { // add to unplaced list VisualUnplacedBracketsList.Add(VisualContender); } else { // moving to a bracket b.VisualCont.Add(VisualContender); b.Bracket.ContendersList.Add(VisualContender.Contender); // refresh the new bracket if (b.Refresh() != null) { // the user moved the last contender from the bracket, bracket will be removed VisualBracketsList.Remove(b.Refresh()); } } // update GUI Clocks FormObj.UpdateClocks(); }