Exemplo n.º 1
0
        void UpdateTeamsAndSpeakers()
        {
            // teams
            teams = ranking.GetTeamRanking(availRounds);
            MiscHelpers.ClearTable(tableTeams);
            for (int i = 0; i < teams.Count; i++)
            {
                SetupTableRow(tableTeams,
                              new Team((TeamData)teams[i].Data),
                              teams,
                              i);
            }
            tableTeams.ShowAll();
            (cTeamsFilter.Child as Entry).Text = "";

            // speakers
            speakers = ranking.GetSpeakerRanking(availRounds);
            MiscHelpers.ClearTable(tableSpeakers);
            for (int i = 0; i < speakers.Count; i++)
            {
                SetupTableRow(tableSpeakers,
                              new DebaterWidget((RoundDebater)speakers[i].Data),
                              speakers,
                              i);
            }
            tableSpeakers.ShowAll();
            (cSpeakersFilter.Child as Entry).Text = "";

            // reset marking, this also rebuilds the combobox, just to be sure
            UpdateCbSelectMarking();
        }
Exemplo n.º 2
0
        void UpdateJudges()
        {
            RoundResultData.UpdateStats();
            MiscHelpers.ClearTable(tableJudges);
            List <Debater> judges = new List <Debater>();

            foreach (Debater d in Tournament.I.Debaters)
            {
                if (d.Role.IsJudge)
                {
                    judges.Add(d);
                }
            }
            judges.Sort(delegate(Debater a, Debater b) {
                return(b.StatsAvg[0].CompareTo(a.StatsAvg[0]));
            });
            for (uint pos = 0; pos < judges.Count; pos++)
            {
                Debater j = judges[(int)pos];
                tableJudges.Attach(new DebaterWidget(new RoundDebater(j)),
                                   0, 1,
                                   2 * pos + 1, 2 * pos + 2,
                                   AttachOptions.Fill, AttachOptions.Fill, 0, 0);
                Label lbl1 = new Label();
                lbl1.Markup = "<big><b>" +
                              RoundResultData.StatAsString(j.StatsAvg[0]) + "&#177;" +
                              RoundResultData.ErrAsString(j.StatsAvg[1]) + "</b></big>";
                lbl1.Xalign = 0;
                tableJudges.Attach(lbl1,
                                   1, 2,
                                   2 * pos + 1, 2 * pos + 2,
                                   AttachOptions.Fill, AttachOptions.Fill, 0, 0);
                Label lbl2 = new Label();
                lbl2.Markup = "<big><b>" +
                              RoundResultData.StatAsString(j.StatsAvg[2]) + "</b></big>";
                lbl2.Xalign = 0;
                tableJudges.Attach(lbl2,
                                   2, 3,
                                   2 * pos + 1, 2 * pos + 2,
                                   AttachOptions.Fill, AttachOptions.Fill, 0, 0);
                if (pos < judges.Count - 1)
                {
                    Debater jNext = judges[(int)(pos + 1)];
                    double  diff  = j.StatsAvg[0] - jNext.StatsAvg[0];
                    if (double.IsNaN(diff))
                    {
                        diff = 0;
                    }
                    int pixels = 5 * (int)Math.Round(diff * 10);
                    tableJudges.Attach(MyGridLine.H(pixels + 3),
                                       0, 3,
                                       2 * pos + 2, 2 * pos + 3,
                                       AttachOptions.Fill, AttachOptions.Fill, 0, 0);
                }
            }

            tableJudges.ShowAll();
        }
Exemplo n.º 3
0
        void UpdateGuiSection(string section, int i, object data)
        {
            Container c = (Container)GetField("c" + section);

            if (data == null)
            {
                SetDummyLabel(c, section);
            }
            else if (data is List <RoundDebater> )
            {
                // Judges or FreeSpeakers (variable number...)
                MiscHelpers.ClearContainer(c);
                List <RoundDebater> list = (List <RoundDebater>)data;
                if (list.Count == 0)
                {
                    SetDummyLabel(c, section);
                }
                else
                {
                    for (int j = 0; j < list.Count; j++)
                    {
                        UpdateGuiSection(section, j, list[j]);
                    }
                    // append label for adding by D&D
                    if (small)
                    {
                        if (section == "Judges")
                        {
                            SetDummyLabel(c, section, roomData.Judges.Count.ToString());
                        }
                        else if (section == "FreeSpeakers" && list.Count < 3)
                        {
                            SetDummyLabel(c, section, "F");
                        }
                    }
                    else if (section == "Judges" || list.Count < 3)
                    {
                        SetDummyLabel(c, section, "Drag here to add");
                    }
                }
            }
            else
            {
                IDragDropWidget w = null;

                if (data is TeamData)
                {
                    if (small)
                    {
                        w = Team.Small((TeamData)data);
                    }
                    else
                    {
                        w = new Team((TeamData)data, null);
                    }
                }
                else if (data is RoundDebater)
                {
                    if (small)
                    {
                        w = DebaterWidget.Small((RoundDebater)data, false);
                    }
                    else
                    {
                        w = new DebaterWidget((RoundDebater)data);
                    }
                }
                else
                {
                    throw new NotImplementedException("Don't know how to create widget for data");
                }

                // tell Debater the room for visitedRooms list..
                w.SetRoom(roomData.RoundName, roomData);

                w.SetupDragDropSource(section, data);
                w.SetDataTrigger += delegate(Widget sender, object data_) {
                    SetItem(section, i, data_);
                };

                // Add to container after source, but before Dest
                Widget wi = (Widget)w;
                MiscHelpers.AddToContainer(c, wi, small);

                // Drag drop DestSet, needs Container for scrolling support...
                DragDropHelpers.DestSet(wi,
                                        DestDefaults.All,
                                        DragDropHelpers.TgtFromString(section),
                                        Gdk.DragAction.Move);

                wi.DragDataReceived += delegate(object o, DragDataReceivedArgs args) {
                    object data_ =
                        DragDropHelpers.Deserialize(args.SelectionData);
                    // save data here
                    SetItem(section, i, data_);
                    // delete data there
                    MyButton b = (MyButton)Drag.GetSourceWidget(args.Context);
                    b.Owner.SetData(data);
                };
            }
            // show judge quality by icons
            if (section == "Judges" && !small)
            {
                int    nStars     = 0;
                double sumAvgSpkr = 0.0;
                double sumAvgTeam = 0.0;
                int    nAvgSpkr   = 0;
                int    nAvgTeam   = 0;

                foreach (RoundDebater rd in roomData.Judges)
                {
                    Debater d = Tournament.I.FindDebater(rd);
                    if (d == null)
                    {
                        continue;
                    }
                    nStars += d.Role.JudgeQuality;
                    if (!double.IsNaN(d.StatsAvg[0]))
                    {
                        sumAvgSpkr += d.StatsAvg[0];
                        nAvgSpkr++;
                    }
                    if (!double.IsNaN(d.StatsAvg[2]))
                    {
                        sumAvgTeam += d.StatsAvg[2];
                        nAvgTeam++;
                    }
                }

                lblJudgeStats.Markup = "JudgeStats: " +
                                       JudgeStatsToMarkup(sumAvgSpkr, nAvgSpkr, 2) + " " +
                                       JudgeStatsToMarkup(sumAvgTeam, nAvgTeam, 5);


                MiscHelpers.ClearTable(tableJudgeStars);
                tableJudgeStars.NRows = (uint)nStars / 5 + 1;

                for (int j = 0; j < nStars; j++)
                {
                    uint col = (uint)j % 5;
                    uint row = (uint)j / 5;

                    tableJudgeStars.Attach(new Image(MiscHelpers.LoadIcon("face-smile")),
                                           col, col + 1,
                                           row, row + 1,
                                           AttachOptions.Shrink, AttachOptions.Shrink,
                                           0, 0);
                }
                if (nStars == 0)
                {
                    tableJudgeStars.HideAll();
                }
                else
                {
                    tableJudgeStars.ShowAll();
                }
            }
        }
Exemplo n.º 4
0
        public void UpdateAll()
        {
            // first update judges (for correct stats...)
            UpdateJudges();
            // then teams and speakers stuff
            MiscHelpers.ClearTable(tableRounds);
            MiscHelpers.ClearTable(tableAvgPoints, false, true);
            ranking           = new RankingData();
            availRounds       = ranking.GetAvailRounds();
            tableRounds.NRows = (uint)availRounds.Count + 1;
            for (uint i = 0; i < availRounds.Count; i++)
            {
                KeyValuePair <string, bool> kvp = availRounds[(int)i];
                RoundData rd = Tournament.I.FindRound(kvp.Key);
                if (rd == null)
                {
                    continue;
                }
                kvp = new KeyValuePair <string, bool>(kvp.Key, rd.ItemCompleted);
                availRounds[(int)i] = kvp;
                // checkBox
                tableRounds.Attach(SetupCheckbutton(kvp, (int)i),
                                   0, 1, i + 1, i + 2,
                                   AttachOptions.Shrink, AttachOptions.Shrink, 0, 0);

                // Image completed?
                string imageStr = rd.ItemCompleted ? "gtk-yes" : "gtk-no";
                tableRounds.Attach(new Image(imageStr, IconSize.Menu),
                                   1, 2, i + 1, i + 2,
                                   AttachOptions.Shrink, AttachOptions.Shrink, 0, 0);
                // roundName
                Label lblName = new Label(kvp.Key);
                lblName.Xalign = 0;
                tableRounds.Attach(lblName,
                                   2, 3, i + 1, i + 2,
                                   AttachOptions.Fill, AttachOptions.Fill, 0, 0);
                // Stats: AvgPoints by Position
                double[] sumAvgPoints = new double[] { 0, 0, 0 };
                tableAvgPoints.Attach(new Label((i + 1).ToString()), 1 + i, 2 + i, 0, 1,
                                      AttachOptions.Shrink, AttachOptions.Shrink, 0, 0);
                for (uint j = 0; j < 11; j++)
                {
                    string text = "?";
                    if (rd.AvgPoints.Count == 11 && rd.AvgPoints[(int)j] >= 0)
                    {
                        text = OPDtabData.MiscHelpers.FmtDecimal(rd.AvgPoints[(int)j]);
                        sumAvgPoints[(int)RoundResultData.PosToRoleType[j]] += rd.AvgPoints[(int)j];
                    }
                    Label lblAvg = new Label();
                    lblAvg.Markup = "<small>" + text + "</small>";
                    tableAvgPoints.Attach(lblAvg,
                                          1 + i, 2 + i, 1 + j, 2 + j, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0);
                }

                // Stats: Gov/Opp wins, avgPoints Gov/Opp
                int nGov = 0;
                int nOpp = 0;
                foreach (RoomData room in rd.Rooms)
                {
                    if (room.BestTeam == 0)
                    {
                        nGov++;
                    }
                    else if (room.BestTeam == 1)
                    {
                        nOpp++;
                    }
                }
                Label lblStats = new Label();
                lblStats.Markup = "<b>" + nGov + "</b> <small>(" +
                                  OPDtabData.MiscHelpers.FmtDecimal(sumAvgPoints[0]) +
                                  ")</small> / <b>" + nOpp + "</b> <small>(" +
                                  OPDtabData.MiscHelpers.FmtDecimal(sumAvgPoints[1]) +
                                  ")</small>";
                tableRounds.Attach(lblStats,
                                   3, 4, i + 1, i + 2,
                                   AttachOptions.Shrink, AttachOptions.Shrink, 0, 0);
            }
            tableRounds.ShowAll();
            tableAvgPoints.ShowAll();
            UpdateTeamsAndSpeakers();
        }