Ejemplo n.º 1
0
        public Room(RoomData rd, bool s)
        {
            this.Build();
            roomData = rd;
            settings = AppSettings.I.GenerateRound;
            penalty  = -1;
            small    = s;
            MyGridLine.H(tableSmall, 2, tableSmall.NColumns, 1, new Gdk.Color(0, 0, 0));

            // generate widget containers
            widgetsContainer = new List <Container>();
            cBig             = new List <Container>();
            cSmall           = new List <Container>();
            foreach (string sec in sections)
            {
                widgetsContainer.Add((Container)GetField("c" + sec));
                cBig.Add((Container)GetField("c" + sec + "Big"));
                cSmall.Add((Container)GetField("c" + sec + "Small"));
            }

            // Update Gui after Realized for scrolled window support...
            this.Realized += delegate(object sender, EventArgs e) {
                UpdateGui();
                // done by UpdateGui: UpdateConflicts();
            };
        }
Ejemplo n.º 2
0
        public static MyGridLine H(int h)
        {
            MyGridLine g = new MyGridLine();

            g.HeightRequest = h;
            return(g);
        }
Ejemplo n.º 3
0
        public static MyGridLine H(int h, Gdk.Color col)
        {
            MyGridLine g = new MyGridLine();

            g.ModifyBg(StateType.Normal, col);
            g.HeightRequest = h;
            return(g);
        }
Ejemplo n.º 4
0
        public static MyGridLine V(int w, Gdk.Color col)
        {
            MyGridLine g = new MyGridLine();

            g.ModifyBg(StateType.Normal, col);
            g.WidthRequest = w;
            return(g);
        }
Ejemplo n.º 5
0
        void UpdateJudges()
        {
            RoundResultData.UpdateStats();
            MiscHelpers.ClearTable(tableJudges);
            List <Debater> judges = new List <Debater>();

            foreach (Debater d in Tournament.I.Debaters)
            {
                if (d.Role.IsJudge)
                {
                    judges.Add(d);
                }
            }
            judges.Sort(delegate(Debater a, Debater b) {
                return(b.StatsAvg[0].CompareTo(a.StatsAvg[0]));
            });
            for (uint pos = 0; pos < judges.Count; pos++)
            {
                Debater j = judges[(int)pos];
                tableJudges.Attach(new DebaterWidget(new RoundDebater(j)),
                                   0, 1,
                                   2 * pos + 1, 2 * pos + 2,
                                   AttachOptions.Fill, AttachOptions.Fill, 0, 0);
                Label lbl1 = new Label();
                lbl1.Markup = "<big><b>" +
                              RoundResultData.StatAsString(j.StatsAvg[0]) + "&#177;" +
                              RoundResultData.ErrAsString(j.StatsAvg[1]) + "</b></big>";
                lbl1.Xalign = 0;
                tableJudges.Attach(lbl1,
                                   1, 2,
                                   2 * pos + 1, 2 * pos + 2,
                                   AttachOptions.Fill, AttachOptions.Fill, 0, 0);
                Label lbl2 = new Label();
                lbl2.Markup = "<big><b>" +
                              RoundResultData.StatAsString(j.StatsAvg[2]) + "</b></big>";
                lbl2.Xalign = 0;
                tableJudges.Attach(lbl2,
                                   2, 3,
                                   2 * pos + 1, 2 * pos + 2,
                                   AttachOptions.Fill, AttachOptions.Fill, 0, 0);
                if (pos < judges.Count - 1)
                {
                    Debater jNext = judges[(int)(pos + 1)];
                    double  diff  = j.StatsAvg[0] - jNext.StatsAvg[0];
                    if (double.IsNaN(diff))
                    {
                        diff = 0;
                    }
                    int pixels = 5 * (int)Math.Round(diff * 10);
                    tableJudges.Attach(MyGridLine.H(pixels + 3),
                                       0, 3,
                                       2 * pos + 2, 2 * pos + 3,
                                       AttachOptions.Fill, AttachOptions.Fill, 0, 0);
                }
            }

            tableJudges.ShowAll();
        }
Ejemplo n.º 6
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
    }