예제 #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);
                }
            }
        }
예제 #2
0
        // make an abbreviated and small version of this widget!

        public static DebaterWidget Small(RoundDebater d, bool canFocus)
        {
            DebaterWidget dw = new DebaterWidget(d, canFocus, true);

            dw.btnExpand.LabelText = d.Name.FirstName.Substring(0, 1) + ". " +
                                     d.Name.LastName.Substring(0, 1) + ". ";
            return(dw);
        }
예제 #3
0
        void SwapSpeakerFrameLabels(int i1, int i2)
        {
            DebaterWidget w1 = dataWidgets[i1] as DebaterWidget;
            DebaterWidget w2 = dataWidgets[i2] as DebaterWidget;
            Frame         f1 = w1.GetAncestor(Frame.GType) as Frame;
            Frame         f2 = w2.GetAncestor(Frame.GType) as Frame;
            // do it the hard way...
            string text1 = f1.Label;
            string text2 = f2.Label;

            (f1.LabelWidget as Label).Markup = "<i>" + text2 + "</i>";
            (f2.LabelWidget as Label).Markup = "<i>" + text1 + "</i>";
        }
예제 #4
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();
                }
            }
        }
예제 #5
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);
     }
 }
예제 #6
0
 void SetSpeakerFrameLabels()
 {
     foreach (int i in new int[] { 0, 1, 2, 3, 7, 8 })
     {
         DebaterWidget w = dataWidgets[i] as DebaterWidget;
         int           j = i;
         if (w.HasResult)
         {
             j = results[i].GetPosition();
         }
         Frame f = w.GetAncestor(Frame.GType) as Frame;
         RoundResultData.RoleType role;
         int index;
         RoundResultData.ParsePosition(j, out role, out index);
         (f.LabelWidget as Label).Markup = "<i>" + (index + 1) + ". " + role + "</i>";
     }
 }
예제 #7
0
파일: Room.cs 프로젝트: julmaxi/opdtab
 int GetJudgeVsSpeaker(Debater d, DebaterWidget dw)
 {
     if (d.ConflictsWith(dw.Debater) || dw.Debater.ConflictsWith(d))
     {
         return(-1);
     }
     else
     {
         int n = 0;
         MyDictionary <string, int> vr1 = d.VisitedRooms;
         MyDictionary <string, int> vr2 = dw.Debater.VisitedRooms;
         // we are only interested in the intersection of roundNames
         foreach (KVP <string, int> kvp1 in vr1.Store)
         {
             // skip if this room is in the round...
             if (roomData.RoundName == kvp1.Key)
             {
                 continue;
             }
             // skip if debater isn't in any room
             if (kvp1.Val < 0)
             {
                 continue;
             }
             KVP <string, int> kvp2;
             if (vr2.GetKVP(kvp1.Key, out kvp2))
             {
                 // skip if debater isn't in any room
                 if (kvp2.Val < 0)
                 {
                     continue;
                 }
                 // same roomIndex?
                 if (kvp1.Val == kvp2.Val)
                 {
                     n++;
                 }
             }
         }
         return(n);
     }
 }
예제 #8
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();
                }
            }
        }
예제 #9
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++;
            }
        }