public override void DrawShadow(byte x, byte y, bool black) { using (var graphics = Graphics.FromImage(offScreenBuffer)) { if (!Simplified && GDIExtensions.AlphaBlendSupported) { var stone = black ? blackStone : whiteStone; var destination = CoordsToRectangle(x, y); GDIExtensions.AlphaBlend( graphics, stone, destination.X, destination.Y); } else { graphics.DrawEllipse(SelectPen(black), (int)(x * CellSize), (int)(y * CellSize), (int)CellSize, (int)CellSize); } } }
protected override void OnPaint(PaintEventArgs args) { base.OnPaint(args); var padding = 3; var target = ClientRectangle; target.Inflate(-padding, -padding); var selectionColor = Color.FromArgb(24, 224, 133); var selectionColor2 = Color.LightBlue; var blendColor = Color.FromArgb( (selectionColor2.R + 2 * BackColor.R) / 3, (selectionColor2.G + 2 * BackColor.G) / 3, (selectionColor2.B + 2 * BackColor.B) / 3); if (buffer == null || buffer.Size != ClientSize) { if (buffer != null) { buffer.Dispose(); } buffer = new Bitmap(ClientSize.Width, ClientSize.Height); } var graphics = Graphics.FromImage(buffer); graphics.Clear(BackColor); using (var pen = new Pen(SystemColors.WindowFrame)) { var border = ClientRectangle; border.Width -= 1; border.Height -= 1; graphics.DrawRectangle(pen, border); } using (var boldFont = new Font(Font.Name, Font.Size, FontStyle.Bold)) using (var selectionBrush = new SolidBrush(selectionColor)) using (var onlineBrush = new SolidBrush(Color.Goldenrod)) using (var offlineBrush = new SolidBrush(Color.DarkGray)) using (var statusBrush = new SolidBrush(Color.DarkSlateGray)) { var top = target.Top; for (var i = 0; i < items.Count; i++) { if (items[i] is FriendState) { var item = items[i] as FriendState; var observed = item.ObservedGames.Count > 0 ? item.ObservedGames[0] : 0; var played = item.PlayedGames.Count > 0 ? item.PlayedGames[0] : 0; var status = played > 0 ? ("Game " + played.ToString()) : observed > 0 ? ("Game " + observed.ToString()) : ""; var icon = played > 0 ? playIcon : observed > 0 ? observeIcon : null; var nameSize = graphics.MeasureString(item.Name, boldFont); var statusSize = graphics.MeasureString(status, Font); var height = Math.Max((int)Math.Ceiling(nameSize.Height), playIcon.Height); if (top + height > target.Top && top < target.Bottom) { if (SelectedIndex == i) { if (GDIExtensions.GradientFillSupported) { GDIExtensions.GradientFill( graphics, new Rectangle(target.Left, top, target.Width, height), blendColor, selectionColor, GradientDirection.Horizontal); } else { graphics.FillRectangle( selectionBrush, target.Left, top, target.Width, height); } } graphics.DrawString( item.Name, boldFont, item.Online ? onlineBrush : offlineBrush, target.Left, top); if (status != "") { graphics.DrawString( status, Font, statusBrush, target.Right - statusSize.Width - 2 * icon.Width, top); graphics.DrawIcon( icon, target.Right - icon.Width, top); } } top += height; } } } args.Graphics.DrawImage(buffer, 0, 0); }