Ejemplo n.º 1
0
        void SetupTeamRow(Container c, object data, int i)
        {
            if (i > 8)
            {
                // a team is easy
                Team t = new Team((TeamData)data);
                MiscHelpers.AddToContainer(c, t);
                dataWidgets.Add(t);
            }
            else
            {
                DebaterWidget dw = new DebaterWidget((RoundDebater)data);
                dataWidgets.Add(dw);
                if (dw.HasResult)
                {
                    results.Add(dw.Debater.
                                GetRoundResult(roomData.RoundName, i, roomData.Judges.Count));
                }
                else
                {
                    results.Add(null);
                }

                uint type = RoundResultData.PosToRoleType[i];
                if (type != (uint)RoundResultData.RoleType.Free)
                {
                    string section = type == 0 ? "OnlyGov" : "OnlyOpp";
                    // Setup Drag Drop
                    dw.SetupDragDropSource(section, i);
                    // Container ATTACH
                    MiscHelpers.AddToContainer(c, dw);
                    // DragDrop DEST
                    DragDropHelpers.DestSet(dw,
                                            DestDefaults.All,
                                            DragDropHelpers.TgtFromString(section),
                                            Gdk.DragAction.Move);

                    dw.DragDataReceived += delegate(object s, DragDataReceivedArgs args) {
                        int j = (int)DragDropHelpers.Deserialize(args.SelectionData);
                        // Swap Rows
                        SwapTableRows(debaterRows[results[i].GetPosition()],
                                      debaterRows[results[j].GetPosition()]);
                        // backswap the labels of the frames...
                        SwapSpeakerFrameLabels(i, j);
                        // save this in results
                        int tmp = results[i].Index;
                        results[i].Index = results[j].Index;
                        results[j].Index = tmp;
                        // update infos
                        dataWidgets[i].UpdateInfo();
                        dataWidgets[j].UpdateInfo();
                    };
                }
                else
                {
                    MiscHelpers.AddToContainer(c, dw);
                }
            }
        }
Ejemplo n.º 2
0
        public void SetGuiToRound(RoundData rd)
        {
            ClearRound();
            // remember round name
            roundName = rd.RoundName;

            // Widgets for Teams
            foreach (TeamData td in rd.AllTeams)
            {
                Team w = new Team(td, SetDataTrigger);
                w.SetupDragDropSource("Team", td);

                w.Shown += delegate(object sender, EventArgs e) {
                    NumTeams++;
                };
                w.Hidden += delegate(object sender, EventArgs e) {
                    NumTeams--;
                };
                vboxTeams.Add(w);
                // this shows Team widget if necessary
                w.UpdateTeamMembers();
            }

            // Widgets for Judges
            foreach (RoundDebater d in rd.AllJudges)
            {
                DebaterWidget w = new DebaterWidget(d);

                w.SetupDragDropSource("Judge", d);
                w.SetDataTrigger += SetDataTrigger;

                w.Shown += delegate(object sender, EventArgs e) {
                    NumJudges++;
                };
                w.Hidden += delegate(object sender, EventArgs e) {
                    NumJudges--;
                };

                vboxJudges.Add(w);
                // show selection of judge state (avail, 1st, chair...)
                w.ShowJudgeState();
                w.JudgeStateChanged += delegate {
                    UpdateJudgeCounts();
                };
                // Judges are hidden by default
                if (d.IsShown)
                {
                    w.ShowAll();
                }
            }
        }
Ejemplo n.º 3
0
 void SetupTeamMembers(SetDataTriggerHandler dataHandler)
 {
     foreach (RoundDebater d in teamData)
     {
         DebaterWidget dw = new DebaterWidget(d);
         if (dataHandler != null)
         {
             dw.SetupDragDropSource("TeamMember", d);
             // notify owner of child's data
             dw.SetDataTrigger += delegate(Widget sender, object data) {
                 dataHandler(sender, data);
                 UpdateTeamMembers();
             };
         }
         vboxTeamMembers.PackStart(dw, false, false, 0);
     }
 }
Ejemplo n.º 4
0
        void SetupJudgeColumn(int i)
        {
            // Setup small DebaterWidget (keep colsize small...)
            DebaterWidget dw = DebaterWidget.Small(roomData.Judges[(int)i], false);

            // add to results, nJudges doesnt matter for judges
            resultsJudges.Add(dw.Debater.GetRoundResult(roomData.RoundName, i, -1));
            dataWidgets.Add(dw);
            // default position
            uint pos = (uint)(i + judgesOffset);

            // THE FOLLOWING ORDER FOR DRAG DROP IS IMPORTANT, see DragDropHelpers

            // DragDrop SOURCE
            // we send always the fixed index i

            if (roomData.Judges.Count > 1)
            {
                dw.SetupDragDropSource("Judge", i);
            }
            //DragDropHelpers.SourceSet(dw, "Judge", i);

            // Container ATTACH
            table.Attach(dw, pos, pos + 1, 0, 1,
                         AttachOptions.Shrink, AttachOptions.Shrink, 0, 0);

            // DragDrop DEST
            if (roomData.Judges.Count > 1)
            {
                DragDropHelpers.DestSet(dw,
                                        DestDefaults.All,
                                        DragDropHelpers.TgtFromString("Judge"),
                                        Gdk.DragAction.Move);

                dw.DragDataReceived += delegate(object o, DragDataReceivedArgs args) {
                    int j = (int)DragDropHelpers.Deserialize(args.SelectionData);
                    // Swap Columns
                    SwapTableCols((uint)(resultsJudges[i].Index + judgesOffset),
                                  (uint)(resultsJudges[j].Index + judgesOffset));
                    // save this in results
                    int tmp = resultsJudges[i].Index;
                    resultsJudges[i].Index = resultsJudges[j].Index;
                    resultsJudges[j].Index = tmp;
                    // update infos
                    dataWidgets[i + 11].UpdateInfo();
                    dataWidgets[j + 11].UpdateInfo();
                };
            }

            // Setup Spinbuttons
            int k = 0;

            foreach (uint row in debaterRows)
            {
                Alignment al = null;
                if (dataWidgets[k].HasResult)
                {
                    // k denotes speaker position
                    // k=9, k=10 are team points
                    // i denotes judgeIndex
                    MySpinButton sb = k < 9 ? SetupSbSpeaker(i, k) :
                                      SetupSbTeam(i, k);
                    // spinbuttons are parents for avg labels..
                    labels[k].AddParent(sb);
                    // nice alignment
                    al              = new Alignment(0f, 0f, 1f, 1f);
                    al.LeftPadding  = 6;
                    al.RightPadding = 6;
                    al.Add(sb);
                }
                table.Attach(MiscHelpers.MakeBackground(al, colBg[RoundResultData.PosToRoleType[k]]),
                             pos, pos + 1, row, row + 1,
                             AttachOptions.Fill, AttachOptions.Fill, 0, 0);
                k++;
            }
        }