示例#1
0
        private void stepsLogListBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < 0)
            {
                return;
            }

            ListBox listBox = (ListBox)sender;

            OthelloStepResult step = (OthelloStepResult)listBox.Items[e.Index];

            Rectangle rect = e.Bounds;

            rect.Height -= 2;
            rect.Width   = rect.Height;
            rect.X++;
            rect.Y++;
            e.Graphics.FillEllipse(step.Player == CellValue.WhiteChip ? Player1Brush : Player2Brush, rect);
            e.Graphics.DrawEllipse(step.Player == CellValue.WhiteChip ? Player2Pen : Player1Pen, rect);

            string message = string.Format("r: {0}, c: {1}", step.Row + 1, step.Col + 1);

            if (step.Error != null)
            {
                message += string.Format(", {0}", step.Error);
            }
            if (step.Comment != null)
            {
                message += string.Format(", {0}", step.Comment);
            }

            rect    = e.Bounds;
            rect.X += rect.Height + 5;
            Brush brush = step.Error == null ? Brushes.Black : Brushes.Red;

            e.Graphics.DrawString(message, e.Font, brush, rect.Location);
        }
示例#2
0
 private void AddStep(OthelloStepResult stepResult)
 {
     steps.Add(stepResult);
 }