Ejemplo n.º 1
0
        internal static void CreateLines(OlympicPaintersGroup painters)
        {
            MatchPainter winner_view;

            painters.BrokenLinePainters.Clear();
            foreach (OlympicMatchPainter painter in painters.MatchPainters.Values)
            {
                if (painter.Match.Winner_Match != null)
                {
                    winner_view = painters.MatchPainters[painter.Match.Winner_Match.Id];
                    Point      A    = new Point(painter.Left + OlympicMatchPainter.Size.Width, painter.Top + OlympicMatchPainter.Size.Height / 2);
                    Point      B    = new Point(winner_view.Left, winner_view.Top + OlympicMatchPainter.Size.Height / 2);
                    BrokenLine line = BrokenLine.CreateLine(A, B);
                    line.Visible = painter.Visible;
                    painters.BrokenLinePainters.Add(line);
                }
            }
        }
Ejemplo n.º 2
0
        internal static void CreateOlympicGrid(MatchList matches, OlympicPaintersGroup painters, float scale, Point location, out Size size, OnMatchPainterEvent AfterMatchEdit)
        {
            OlympicPainterSettings.Scale = scale;
            Size bitmap_size = new Size(0, 0);

            size = bitmap_size;
            Point     div_pos = location;
            int       round_left = div_pos.X;
            const int DIFF = 4; const int OFFSET = 20;
            Size      label_size = new Size(OlympicMatchPainter.Size.Width, (int)(OlympicMatchPainter.Size.Height * 1.5));
            double    div_height = 0.0; double k = 0.0;

            painters.MatchPainters.Clear();
            painters.RoundLabels.Clear();
            int              current_division = 1;
            int              current_round    = 1;
            double           first            = 0.0;
            List <MatchInfo> round_matches    = new List <MatchInfo>();

            foreach (MatchInfo match in matches.Values)
            {
                if (match.Label.Division != current_division || match.Label.Round != current_round)
                {
                    // формируем матчи раунда
                    if (div_height == 0.0)
                    {
                        k          = label_size.Height + DIFF;
                        div_height = round_matches.Count * k;
                    }
                    else
                    {
                        k = div_height / round_matches.Count;
                    }
                    first = div_pos.Y + k / 2.0;
                    for (int i = 0; i < round_matches.Count; i++)
                    {
                        //OlympicMatchPainter painter = (OlympicMatchPainter)GetMatchPainter();
                        OlympicMatchPainter painter = new OlympicMatchPainter();
                        painter.TopF       = first + k * i + label_size.Height / 2.0;
                        bitmap_size.Height = Math.Max(bitmap_size.Height, Convert.ToInt32(painter.TopF) + label_size.Height + 50);

                        painter.Left         = round_left;
                        painter.Match        = round_matches[i];
                        painter.OnAfterEdit += new OnMatchPainterEvent(AfterMatchEdit);
                        painters.MatchPainters.Add(painter.Match.Id, painter);
                    }
                    round_left       += label_size.Width + OFFSET;
                    bitmap_size.Width = Math.Max(bitmap_size.Width, round_left + label_size.Width + 50);
                    // Обнуляем список для следующего раунда
                    round_matches.Clear();
                    current_round = match.Label.Round;
                    round_matches.Add(match);
                    if (current_division != match.Label.Division)
                    {
                        // формируем новый дивизион
                        current_division = match.Label.Division;
                        div_pos.Y       += Convert.ToInt32(div_height) + 50;
                        div_height       = 0.0;
                        round_left       = div_pos.X;
                    }
                }
                else
                {
                    round_matches.Add(match);
                }
            }
            //Добавляем последний матч
            if (div_height == 0.0)
            {
                k          = label_size.Height + DIFF;
                div_height = round_matches.Count * k;
            }
            else
            {
                k = div_height / round_matches.Count;
            }
            first = div_pos.Y + k / 2.0;
            for (int i = 0; i < round_matches.Count; i++)
            {
                //OlympicMatchPainter painter = (OlympicMatchPainter)GetMatchPainter();
                OlympicMatchPainter painter = new OlympicMatchPainter();
                painter.TopF       = first + k * i + label_size.Height / 2.0;
                bitmap_size.Height = Math.Max(bitmap_size.Height, Convert.ToInt32(painter.TopF) + label_size.Height + 50);

                painter.Left         = round_left;
                painter.Match        = round_matches[i];
                painter.OnAfterEdit += new OnMatchPainterEvent(AfterMatchEdit);
                painters.MatchPainters.Add(painter.Match.Id, painter);
            }
            if (current_division == 1) // Для олимпийской системы добавляем labels к матчам
            {
                int i = 1;
                while (current_round > 0)
                {
                    RoundLabel label = new RoundLabel();
                    label.Left      = round_left;
                    label.Top       = div_pos.Y + OlympicPainterSettings.MatchSize.Heihgt;
                    label.LabelText = TA.Utils.Utils.GetRoundsLabelText(i++);
                    painters.RoundLabels.Add(label);
                    round_left -= label_size.Width + OFFSET;
                    current_round--;
                }
            }
            bitmap_size.Width = Math.Max(bitmap_size.Width, round_left + label_size.Width + 50);
            CreateLines(painters);
            size = bitmap_size;
        }