示例#1
0
 public void ClearRound()
 {
     MiscHelpers.ClearContainer(vboxTeams);
     NumTeams = 0;
     MiscHelpers.ClearContainer(vboxJudges);
     NumJudges = 0;
 }
示例#2
0
文件: Room.cs 项目: julmaxi/opdtab
        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();
                }
            }
        }