Пример #1
0
        void SetupTableRow(Table table, Widget w, List <RankingDataItem> items, int i)
        {
            RankingDataItem item = items[i];
            uint            row  = (uint)i + 1;
            string          pos  = row.ToString();

            // check for equal points
            if (i > 0 && items[i - 1].TotalPoints == item.TotalPoints)
            {
                uint off = row % 2;
                table.Attach(MakeResolveBtn(table, i),
                             3 + off, 3 + off + 1,
                             row - 1, row + 1,
                             AttachOptions.Fill, AttachOptions.Fill, 0, 0);
            }
            if (!item.Resolved)
            {
                pos += "?";
            }

            // insert widgets in table,
            // always in EventBox for marking with Backgrounds...
            Label lblPos = new Label(pos);

            lblPos.Yalign = 0.5f;
            table.Attach(MiscHelpers.MakeBackground(lblPos),
                         0, 1, row, row + 1,
                         AttachOptions.Fill, AttachOptions.Fill, 0, 0);
            table.Attach(MiscHelpers.MakeBackground(w),
                         1, 2, row, row + 1,
                         AttachOptions.Fill, AttachOptions.Fill, 0, 0);
            Label lblPoints = new Label();

            lblPoints.Markup = item.TotalPoints < 0 ?
                               "<big><b>?</b></big>" :
                               "<b><big>" + OPDtabData.MiscHelpers.FmtDecimal(item.TotalPoints) + "</big></b>";
            table.Attach(MiscHelpers.MakeBackground(lblPoints),
                         2, 3, row, row + 1,
                         AttachOptions.Fill, AttachOptions.Fill, 0, 0);
        }
Пример #2
0
        void SetupTable()
        {
            // set size
            table.NColumns = 11;

            // INTEGER LABELS
            // Headers
            uint avgColOff = table.NColumns - 8;           // starting column offset

            AttachHeaderLabel("Gov", avgColOff);
            AttachHeaderLabel("Opp", avgColOff + 1);
            AttachHeaderLabel("Free", avgColOff + 2);
            lblBestSpeaker = AttachConflictLabel("?", avgColOff + 3, 0);

            // averages for speakers
            labels   = new List <MyNumberLabel>();
            bestOnes = new List <RoundResultSetBest>();
            for (int i = 0; i < debaterRows.Length; i++)
            {
                for (uint k = 0; k < 3; k++)
                {
                    uint          col   = avgColOff + k;
                    Gdk.Color     color = colBgNone;
                    MyNumberLabel lbl   = null;
                    if (k == RoundResultData.PosToRoleType[i])
                    {
                        lbl = new MyNumberLabel(true);
                        labels.Add(lbl);
                        color = colBg[k];
                    }
                    table.Attach(MiscHelpers.MakeBackground(lbl, color),
                                 col, col + 1, debaterRows[i], debaterRows[i] + 1,
                                 AttachOptions.Fill, AttachOptions.Fill, 0, 0);
                }
                // add also radiobuttons, they are one group
                // but only for speakers, not for teams
                if (i < 9)
                {
                    RoundResultSetBest rb = new RoundResultSetBest(
                        bestOnes.Count > 0 ? bestOnes[0] : null, i);
                    rb.Toggled += delegate(object sender, EventArgs e) {
                        if (rb.Active && roomData != null)
                        {
                            roomData.BestSpeaker = (sender as RoundResultSetBest).Index;
                        }
                    };
                    bestOnes.Add(rb);
                    table.Attach(rb,
                                 avgColOff + 3, avgColOff + 4,
                                 debaterRows[i], debaterRows[i] + 1,
                                 AttachOptions.Shrink, AttachOptions.Shrink, 0, 0);
                }
            }

            // PLUS
            AttachBigLabel("+", table.NColumns - 5, table.NRows - 2);
            AttachBigLabel("+", table.NColumns - 5, table.NRows - 1);

            // SPEAKER SUM
            AttachSumLabel(table.NColumns - 4, table.NRows - 2, colBg[0], posGov);
            AttachSumLabel(table.NColumns - 4, table.NRows - 1, colBg[1], posOpp);

            // EQUALS
            AttachBigLabel("=", table.NColumns - 3, table.NRows - 2);
            AttachBigLabel("=", table.NColumns - 3, table.NRows - 1);

            // TOTAL
            AttachSumLabel(table.NColumns - 2, table.NRows - 2, colBg[0], 9, 11);
            AttachSumLabel(table.NColumns - 2, table.NRows - 1, colBg[1], 10, 12);


            // connect to intLabels to update completeFlags
            foreach (int i in new int[] { 4, 5, 6, 13, 14 })
            {
                labels[i].NumberChanged += delegate(object sender, EventArgs e) {
                    CheckCompleteFlags();
                }
            }
            ;

            // Win? Label
            lblBestTeam = AttachConflictLabel("?", table.NColumns - 1, table.NRows - 4);

            // complete bestOnes with Team buttons
            RoundResultSetBest rbGov = new RoundResultSetBest(null, 9);
            RoundResultSetBest rbOpp = new RoundResultSetBest(rbGov, 10);

            rbGov.Toggled += delegate(object sender, EventArgs e) {
                if (rbGov.Active && roomData != null)
                {
                    roomData.BestTeam = 0;
                    UpdateBestSpeaker();
                }
            };
            rbOpp.Toggled += delegate(object sender, EventArgs e) {
                if (rbOpp.Active && roomData != null)
                {
                    roomData.BestTeam = 1;
                    UpdateBestSpeaker();
                }
            };
            bestOnes.Add(rbGov);
            bestOnes.Add(rbOpp);

            table.Attach(rbGov,
                         table.NColumns - 1, table.NColumns,
                         table.NRows - 2, table.NRows - 1,
                         AttachOptions.Shrink, AttachOptions.Shrink,
                         12, 0);
            table.Attach(rbOpp,
                         table.NColumns - 1, table.NColumns,
                         table.NRows - 1, table.NRows,
                         AttachOptions.Shrink, AttachOptions.Shrink,
                         12, 0);

            // connect to intLabels to update bestOnes
            for (int i = 0; i < 9; i++)
            {
                labels[i].NumberChanged += delegate(object sender, EventArgs e) {
                    UpdateBestSpeaker();
                };
            }
            labels[13].NumberChanged += delegate(object sender, EventArgs e) {
                UpdateBestOnes();
            };
            labels[14].NumberChanged += delegate(object sender, EventArgs e) {
                UpdateBestOnes();
            };


            // COLOR DEBATER BACKGROUNDS
            ebGov1.ModifyBg(StateType.Normal, colBg[0]);
            ebGov2.ModifyBg(StateType.Normal, colBg[0]);
            ebGov3.ModifyBg(StateType.Normal, colBg[0]);
            ebTeamGov.ModifyBg(StateType.Normal, colBg[0]);

            ebOpp1.ModifyBg(StateType.Normal, colBg[1]);
            ebOpp2.ModifyBg(StateType.Normal, colBg[1]);
            ebOpp3.ModifyBg(StateType.Normal, colBg[1]);
            ebTeamOpp.ModifyBg(StateType.Normal, colBg[1]);

            ebFree1.ModifyBg(StateType.Normal, colBg[2]);
            ebFree2.ModifyBg(StateType.Normal, colBg[2]);
            ebFree3.ModifyBg(StateType.Normal, colBg[2]);

            // GRIDLINES
            // vertical
            MyGridLine.V(table, 1, 1, colBlack);
            MyGridLine.V(table, table.NColumns - 9, 1, colBlack);

            // horizontal
            MyGridLine.H(table, 1, table.NColumns - 5, 2, colBlack);
            MyGridLine.H(table, table.NRows - 3, table.NColumns - 5, 2, colBlack);
        }

        void AttachHeaderLabel(string text, uint col)
        {
            Label lbl = new Label();

            lbl.Markup = "<b>" + text + "</b>";
            table.Attach(lbl, col, col + 1, 0, 1, AttachOptions.Shrink, AttachOptions.Shrink, 6, 0);
        }

        void AttachSumLabel(uint col, uint row, Gdk.Color color, params int[] w)
        {
            MyNumberLabel sumSpeaker = new MyNumberLabel(false);

            foreach (int i in w)
            {
                sumSpeaker.AddParent(labels[i]);
            }

            labels.Add(sumSpeaker);
            table.Attach(MiscHelpers.MakeBackground(sumSpeaker, color),
                         col, col + 1,
                         row, row + 1,
                         AttachOptions.Fill, AttachOptions.Fill,
                         0, 0);
        }

        void AttachBigLabel(string text, uint col, uint row)
        {
            AttachLabel("<big><big><big>" + text + "</big></big></big>", col, row);
        }

        Label AttachConflictLabel(string text, uint col, uint row)
        {
            return(AttachLabel("<big><big><span foreground=\"red\">" + text + "</span></big></big>", col, row));
        }

        Label AttachLabel(string text, uint col, uint row)
        {
            Label lbl = new Label();

            lbl.Markup = text;
            table.Attach(lbl, col, col + 1, row, row + 1,
                         AttachOptions.Shrink, AttachOptions.Shrink,
                         12, 0);
            return(lbl);
        }

        #endregion
    }
Пример #3
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++;
            }
        }