예제 #1
0
 public void TestCompareTo()
 {
     ScoreRow row1 = new ScoreRow("7", "foo", new int[] { 50, 200, 100 });
       ScoreRow row2 = new ScoreRow("7", "foo", new int[] { 200, 200, 50 });
       ScoreRow row3 = new ScoreRow("7", "foo", new int[] { 200, 200, 200 });
       ScoreRow row4 = new ScoreRow("8", "foo", new int[] { 200, 200, 200 });
       ScoreRow row5 = new ScoreRow("7", "fob", new int[] { 200, 200, 200 });
       ScoreRow row6 = new ScoreRow("5", "bar", new int[] { 200, 300, 200 });
       ScoreRow row7 = new ScoreRow("4", "baz", new int[] { 50, 50, 100 });
       ScoreRow row8 = new ScoreRow("3", "baz", new int[] { -1, -1, -1 });
       ScoreRow row9 = new ScoreRow("3", "baz", new int[] { 0, 0, 0 });
       ScoreRow row10 = new ScoreRow("3", "baz", new int[] { 0, -1, -1 });
       ScoreRow row11 = new ScoreRow("9", "baz", new int[] { 50, 100, 50 });
       ScoreRow row12 = new ScoreRow("10", "baz", new int[] { 100, 50, 50 });
       List<ScoreRow> list = new List<ScoreRow>(
       new ScoreRow[] {row1, row2, row3, row4, row5, row6, row7, row8, row9,
                   row10, row11, row12
                  });
       list.Sort();
       Assert.AreEqual(row6, list[0]);
       Assert.AreEqual(row5, list[1]);
       Assert.AreEqual(row3, list[2]);
       Assert.AreEqual(row4, list[3]);
       Assert.AreEqual(row2, list[4]);
       Assert.AreEqual(row1, list[5]);
       Assert.AreEqual(row7, list[6]);
       Assert.AreEqual(row11, list[7]);
       Assert.AreEqual(row12, list[8]);
       Assert.AreEqual(row9, list[9]);
       Assert.AreEqual(row10, list[10]);
       Assert.AreEqual(row8, list[11]);
 }
예제 #2
0
        public void TestCompareTo()
        {
            ScoreRow        row1  = new ScoreRow("7", "foo", new int[] { 50, 200, 100 });
            ScoreRow        row2  = new ScoreRow("7", "foo", new int[] { 200, 200, 50 });
            ScoreRow        row3  = new ScoreRow("7", "foo", new int[] { 200, 200, 200 });
            ScoreRow        row4  = new ScoreRow("8", "foo", new int[] { 200, 200, 200 });
            ScoreRow        row5  = new ScoreRow("7", "fob", new int[] { 200, 200, 200 });
            ScoreRow        row6  = new ScoreRow("5", "bar", new int[] { 200, 300, 200 });
            ScoreRow        row7  = new ScoreRow("4", "baz", new int[] { 50, 50, 100 });
            ScoreRow        row8  = new ScoreRow("3", "baz", new int[] { -1, -1, -1 });
            ScoreRow        row9  = new ScoreRow("3", "baz", new int[] { 0, 0, 0 });
            ScoreRow        row10 = new ScoreRow("3", "baz", new int[] { 0, -1, -1 });
            ScoreRow        row11 = new ScoreRow("9", "baz", new int[] { 50, 100, 50 });
            ScoreRow        row12 = new ScoreRow("10", "baz", new int[] { 100, 50, 50 });
            List <ScoreRow> list  = new List <ScoreRow>(
                new ScoreRow[] { row1, row2, row3, row4, row5, row6, row7, row8, row9,
                                 row10, row11, row12 });

            list.Sort();
            Assert.AreEqual(row6, list[0]);
            Assert.AreEqual(row5, list[1]);
            Assert.AreEqual(row3, list[2]);
            Assert.AreEqual(row4, list[3]);
            Assert.AreEqual(row2, list[4]);
            Assert.AreEqual(row1, list[5]);
            Assert.AreEqual(row7, list[6]);
            Assert.AreEqual(row11, list[7]);
            Assert.AreEqual(row12, list[8]);
            Assert.AreEqual(row9, list[9]);
            Assert.AreEqual(row10, list[10]);
            Assert.AreEqual(row8, list[11]);
        }
예제 #3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = Graphics.FromImage(buffer_);

            g.Clear(Color.White);

            int length = scores_.Length;
            int width  = Width - 1;
            int height = Height;
            int bottom = Math.Min(height, top_ + (1 + length) * row_height_);

            g.DrawRectangle(pen_, 1, top_, width - 1, bottom - top_);
            DrawLine(g, rank_width_, top_, bottom);

            int rounds = (length == 0) ? 3 : scores_[0].Scores.Length;

            for (int i = 1; i <= rounds; ++i)
            {
                DrawLine(g, width - i * score_width_, top_, bottom);
            }

            for (int i = 0; i <= length; ++i)
            {
                int scrolled_index = (i + length + 1 - scroll_) % (length + 1);
                int top            = top_ + (scrolled_index + 1) * row_height_;
                if (top > height)
                {
                    continue;
                }

                if (i == length)
                {
                    if (row_count_ < length)
                    {
                        g.DrawLine(pen_, 0, top + row_height_, width, top + row_height_);
                    }
                }
                else
                {
                    ScoreRow row = scores_[i];
                    DrawCell(g, body_, top, width, i, row.Rank.ToString(), row.ToString(),
                             row.GetAllPoints(), row.GetBestRound());
                }
            }

            string[] round_headers = new string[rounds];
            for (int i = 0; i < rounds; ++i)
            {
                round_headers[i] = (i + 1).ToString();
            }
            DrawCell(g, bold_, top_, width, -1, "Rank", "Team Name", round_headers,
                     0);

            e.Graphics.DrawImageUnscaled(buffer_, 0, 0);
        }
예제 #4
0
 public bool IsScoreEqual(ScoreRow other)
 {
     int[] thisScores = GetSortedScores();
     int[] rowScores  = other.GetSortedScores();
     for (int i = 0; i < thisScores.Length; ++i)
     {
         if (thisScores[i] != rowScores[i])
         {
             return(false);
         }
     }
     return(true);
 }
예제 #5
0
        public int CompareTo(object other)
        {
            if (!(other is ScoreRow))
            {
                throw new ArgumentException("Can only compare with other ScoreRows.");
            }
            ScoreRow row = (ScoreRow)other;

            int[] thisScores = GetSortedScores();
            int[] rowScores  = row.GetSortedScores();
            for (int i = thisScores.Length - 1; i >= 0; --i)
            {
                int comp = thisScores[i].CompareTo(rowScores[i]);
                if (comp != 0)
                {
                    return(-comp);
                }
            }

            return(TeamNameComparer.Compare(Number, Name, row.Number, row.Name));
        }
예제 #6
0
 public void TestCompareToInvalid()
 {
     ScoreRow row1 = new ScoreRow("7", "foo", new int[] {200, 100, 50});
       row1.CompareTo(null);
 }
예제 #7
0
 public bool IsScoreEqual(ScoreRow other)
 {
     int[] thisScores = GetSortedScores();
       int[] rowScores = other.GetSortedScores();
       for (int i = 0; i < thisScores.Length; ++i) {
     if (thisScores[i] != rowScores[i])
       return false;
       }
       return true;
 }
예제 #8
0
        public void TestCompareToInvalid()
        {
            ScoreRow row1 = new ScoreRow("7", "foo", new int[] { 200, 100, 50 });

            row1.CompareTo(null);
        }