Ejemplo n.º 1
0
 public RoundResultSetBest(RoundResultSetBest member, int i)
 {
     this.Build();
     index       = i;
     radiobutton = new RadioButton(member == null ? null : member.radiobutton, null);
     radiobutton.FocusOnClick = false;
     hbox.Add(radiobutton);
     radiobutton.Toggled += delegate(object sender, EventArgs e) {
         UpdateGui();
         if (Toggled != null)
         {
             Toggled(this, EventArgs.Empty);
         }
     };
     UpdateGui();
 }
Ejemplo n.º 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
    }