internal static void CreateNewBracket(int ContID) { // first check unplacedList to remove if (VisualUnplacedBracketsList.Any(x => x.SystemID == ContID) == true) { var cont = VisualUnplacedBracketsList.Where(x => x.SystemID == ContID).Select(c => c).Single(); // remove from unplaced area VisualUnplacedBracketsList.Remove(cont); } else { // remove from Bracket area RemoveContender(ContID); } // the old visual contender will be disposd in order to remove from GUI var NewBracketVisualContToDispose = AllVisualContenders.Where(x => x.SystemID == ContID).Select(c => c).Single(); // new visual contender will be created for the new bracket var NewBracketCont = AllVisualContenders.Where(x => x.SystemID == ContID).Select(c => c.Contender).Single(); // remove from AllvisualContenders list (will be created again later) AllVisualContenders.Remove(NewBracketVisualContToDispose); // dispose old visual contender and he will dissapear from his old place in GUI NewBracketVisualContToDispose.Vcontender.Dispose(); NewBracketVisualContToDispose = null; // create a new bracket MartialArts.Bracket newBracket = new MartialArts.Bracket(NewBracketCont.AgeCategory, NewBracketCont.Belt, NewBracketCont.WeightCategory); newBracket.AddSingleContender(NewBracketCont); // create a new visual bracket VisualBracket newVisualBracket = new VisualBracket(newBracket); newVisualBracket.Init(); // add to bracket list VisualBracketsList.Add(newVisualBracket); // add to panel FormObj.BracktsFPanel.Controls.Add(newVisualBracket.Vbracket); // add the"new" visual contender to AllContenderList (he was removed) in order to find him in searches AllVisualContenders.Add(newVisualBracket.VisualCont[0]); // scroll to end of the panel to show the user the new bracket, first wait for weak graphic cards System.Threading.Thread.Sleep(50); FormObj.BracktsFPanel.VerticalScroll.Value = FormObj.BracktsFPanel.VerticalScroll.Maximum; // refresh clocks FormObj.UpdateClocks(); }
public static bool IsSutibleForBracket(VisualContender v, VisualBracket b, out double finalgrade) { finalgrade = v.Contender.Grade; bool IsSuitable = false; if (Math.Floor(v.Contender.Grade) == Math.Floor(b.Bracket.AverageGrade) && MartialArts.BracketsBuilder.ReturnBinaryGender(b.Bracket) == v.Contender.IsMale) { finalgrade = v.Contender.Grade; IsSuitable = true; } else if (Math.Floor(v.Contender.Score_WeightFactor) == Math.Floor(b.Bracket.AverageGrade) && MartialArts.BracketsBuilder.ReturnBinaryGender(b.Bracket) == v.Contender.IsMale) { finalgrade = v.Contender.Score_WeightFactor; IsSuitable = true; } else if (Math.Floor(v.Contender.Score_BeltFactor) == Math.Floor(b.Bracket.AverageGrade) && MartialArts.BracketsBuilder.ReturnBinaryGender(b.Bracket) == v.Contender.IsMale) { finalgrade = v.Contender.Score_BeltFactor; IsSuitable = true; } else if (Math.Floor(v.Contender.Score_AgeFactor) == Math.Floor(b.Bracket.AverageGrade) && v.Contender.IsChild == true && MartialArts.BracketsBuilder.ReturnBinaryGender(b.Bracket) == v.Contender.IsMale) { finalgrade = v.Contender.Score_AgeFactor; IsSuitable = true; } else if (Math.Floor(v.Contender.Score_Weight_Belt_Factor) == Math.Floor(b.Bracket.AverageGrade) && MartialArts.BracketsBuilder.ReturnBinaryGender(b.Bracket) == v.Contender.IsMale) { finalgrade = v.Contender.Score_Weight_Belt_Factor; IsSuitable = true; } else if (Math.Floor(v.Contender.Score_Weight_Age_Factor) == Math.Floor(b.Bracket.AverageGrade) && v.Contender.IsChild == true && MartialArts.BracketsBuilder.ReturnBinaryGender(b.Bracket) == v.Contender.IsMale) { finalgrade = v.Contender.Score_Weight_Age_Factor; IsSuitable = true; } else if (Math.Floor(v.Contender.Score_AllFactors) == Math.Floor(b.Bracket.AverageGrade) && v.Contender.IsChild == true && MartialArts.BracketsBuilder.ReturnBinaryGender(b.Bracket) == v.Contender.IsMale) { finalgrade = v.Contender.Score_AllFactors; IsSuitable = true; } return(IsSuitable); }
/// <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(); }
public static void AddVisualBracket(VisualBracket vbracket) { VisualBracketsList.Add(vbracket); }