Exemple #1
0
        public TableStat(ChampionatConfig conf)
        {
            InitializeComponent();
            if (conf == null)
            {
                return;
            }
            var uchs = new SortedDictionary <int?, UchastChamp>();

            foreach (var uch in conf.UchastChamp)
            {
                uchs.Add(uch.OrderNum, uch);
            }
            var luch = new List <UchastChamp>();

            foreach (var u in uchs)
            {
                luch.Add(u.Value);
            }
            for (int i = 0, j = 1; i < 6; i += 3)
            {
                if (i > luch.Count - 1)
                {
                    break;
                }
                var tb = new TbGroup()
                {
                    conf = conf, OrderGroup = j++
                };
                tb.uch1 = luch[i];
                if (luch.Count > i + 1)
                {
                    tb.uch2 = luch[i + 1];
                }
                if (luch.Count > i + 2)
                {
                    tb.uch3 = luch[i + 2];
                }
                gr.Children.Add(new TableGroup(tb));
            }
            if (luch.Count > 3)
            {
                gr.Children.Add(new TableGroupWin(luch, conf));
            }
        }
Exemple #2
0
 public TableGroup(TbGroup tb)
 {
     DataContext = tb;
     InitializeComponent();
     if (tb.uch1 != null && tb.uch2 != null || tb.uch3 != null)
     {
         if (tb.uch2 != null)
         {
             Win12.Content = GetCountWinGroup(tb.uch1) != 0 ? tb.uch1.participants.Name : tb.uch2.participants.Name;
             Win21.Content = Win12.Content;
         }
         if (tb.uch3 != null)
         {
             Win13.Content = GetCountWinGroup(tb.uch1) != 0 ? tb.uch1.participants.Name : tb.uch3.participants.Name;
             Win31.Content = Win13.Content;
         }
         if (tb.uch2 != null && tb.uch3 != null)
         {
             Win23.Content = GetCountWinGroup(tb.uch2) != 0 ? tb.uch2.participants.Name : tb.uch3.participants.Name;
             Win32.Content = Win23.Content;
         }
         int GetCountWinGroup(UchastChamp uc) => uc.Sorevnovanie.Where(u => u.Winner == 0 && u.Red == uc.id_uchast || u.Winner == 1 && u.White == uc.id_uchast).Count();
     }
 }