protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (RS == null) { return; } Point cell; if (MouseToCell(e.Location, out cell) && (RS.Players.Count > cell.Y) && (RS.Competitions.Count > cell.X) && (cell.X - ViewColFrom < VisibleColCount)) { Point loc = Rect_Results.Location; loc.Offset((cell.X - ViewColFrom + 1) * ColWidth_C - ColWidth_C / 2, (cell.Y - ViewRowFrom) * Height_Row + 2 - pnlInfo.Height); //lblCellInfo.Text = String.Format("{0}x{1}", cell.X, cell.Y); pnlInfo.Location = loc; int playerId = FPlayers[cell.Y].Id; CompetitionInfo comp = RS.Competitions[cell.X]; if (comp.Results.ContainsKey(playerId)) { PlayersCompetitionResult res = comp.Results[playerId]; lblInfoRatingBegin.Text = res.RatingBegin.ToString(); lblInfoDelta.Text = res.Delta.ToString(); lblInfoPenalty.Text = (res.Penalty == 0) ? "-" : res.Penalty.ToString(); lblInfoRating.Text = (res.RatingBegin + res.Delta).ToString(); pnlInfo.Visible = true; pnlInfo.BringToFront(); } else { pnlInfo.Visible = false; } } else { pnlInfo.Visible = false; } }
public void Draw(Image image, int viewRowFrom, int visibleRowCount, int viewColFrom, int visibleColCount) { Graphics gr = Graphics.FromImage(image); gr.FillRectangle(FPlayersBrush, Rect_Players); gr.FillRectangle(FResultBkBrush, Rect_Results); gr.FillRectangle(FHeaderBkBrush, Rect_Header_C); gr.FillRectangle(FRatingBkBrush, Rect_RatingBegin); gr.FillRectangle(FRatingBkBrush, Rect_Rating); gr.FillRectangle(Brushes.WhiteSmoke, Rect_Footer); gr.DrawString(Localizator.Dictionary.GetString("PLAYER_LIST"), Font, FPlayersFontBrush, new Rectangle(0, 0, ColWidth_P, Height_Header), sf_center); gr.DrawString(Localizator.Dictionary.GetString("START_RATING"), Font, FPlayersFontBrush, new Rectangle(ColWidth_P, 0, ColWidth_RB, Height_Header), sf_center); Rectangle header_caption_rect = new Rectangle(ColWidth_P + ColWidth_RB, 0, Rect_Results.Width, Height_Header / 2); gr.DrawRectangle(FLinePen, header_caption_rect); gr.DrawString(Localizator.Dictionary.GetString("TOURNAMENT_RESULTS"), Font, FPlayersFontBrush, header_caption_rect, sf_center); gr.DrawRectangle(FLinePen, Rect_RatingBegin.Left, Rect_RatingBegin.Top, Rect_RatingBegin.Width, Height_Header); gr.DrawRectangle(FLinePen, Rect_Players.Left, Rect_Players.Top, Rect_Players.Width, Height_Header); if (RS != null) { Rectangle player_rect = new Rectangle(0, Height_Header, ColWidth_P, Height_Row); Rectangle rating_begin_rect = new Rectangle(ColWidth_P, Height_Header, ColWidth_RB, Height_Row); Rectangle rating_rect = new Rectangle(image.Width - ColWidth_R, Height_Header, ColWidth_R, Height_Row); Rectangle comp_rect = new Rectangle(new Point(ColWidth_P, Height_Header), new Size(ColWidth_C, Height_Row)); for (int p = viewRowFrom; p < FPlayers.Length && p < viewRowFrom + visibleRowCount; p++) { PlayerRating player = FPlayers[p]; gr.DrawRectangle(FLinePen, player_rect); gr.DrawRectangle(FLinePen, new Rectangle(player_rect.Location, new Size(image.Width, Height_Row))); gr.DrawString(player.Name, Font, FPlayersFontBrush, player_rect, sf_left); gr.DrawString(player.Country, Font, FPlayersFontBrush, new Rectangle(player_rect.X + player_rect.Width - ColWidth_Cntry, player_rect.Y, ColWidth_Cntry, player_rect.Height), sf_left); gr.DrawRectangle(FLinePen, rating_begin_rect); //gr.DrawRectangle(FLinePen, new Rectangle(player_rect.Location, new Size(Width, Height_Row))); gr.DrawString(player.RatingBegin.ToString(), Font, FPlayersFontBrush, rating_begin_rect, sf_right); comp_rect.X = ColWidth_P + ColWidth_RB; comp_rect.Y = player_rect.Y; Rectangle header_rect = new Rectangle(comp_rect.X, Height_Header / 2, ColWidth_C, Height_Header / 2); for (int i = viewColFrom; (i < RS.Competitions.Count) && (i - viewColFrom < visibleColCount); i++) { gr.DrawRectangle(FLinePen, header_rect); gr.DrawString(RS.Competitions[i].Date.ToString("dd.MM.yyyy"), Font, FHeaderBrush, header_rect, sf_center); header_rect.Offset(header_rect.Width, 0); gr.DrawRectangle(FLinePen, comp_rect); if (RS.Competitions[i].Results.ContainsKey(player.Id)) { PlayersCompetitionResult res = RS.Competitions[i].Results[player.Id]; if (res.Penalty != 0) { gr.DrawString((-res.Penalty).ToString(), Font, FPenaltyBrush, comp_rect, sf_left); } string delta = res.Delta.ToString(); if (res.Delta > 0) { delta = "+" + delta; } gr.DrawString(delta, Font, FDeltaBrush, comp_rect, sf_right); } comp_rect.Offset(comp_rect.Width, 0); } gr.FillRectangle(FRatingBkBrush, rating_rect); gr.DrawRectangle(FLinePen, rating_rect); gr.DrawString(player.Rating.ToString(), Font, FRatingFontBrush, rating_rect, sf_left); player_rect.Offset(0, player_rect.Height); rating_rect.Offset(0, rating_rect.Height); rating_begin_rect.Offset(0, rating_rect.Height); } } Rectangle rating_header_rect = new Rectangle(image.Width - ColWidth_R, 0, ColWidth_R, Height_Header); gr.FillRectangle(FRatingBkBrush, rating_header_rect); gr.DrawRectangle(FLinePen, rating_header_rect); string date_str = String.Format(Localizator.Dictionary.GetString("RATING_AT"), FRatingDate.ToString("dd.MM.yyyy")); gr.DrawString(date_str, Font, FRatingFontBrush, rating_header_rect, sf_center); //gr.DrawString(hScrollBar.Value.ToString(), Font, FRatingFontBrush, rating_header_rect, sf_center); Point pointA = new Point(0, Height_Header - 8); switch (SortedBy) { case SortBy.Name: pointA.X = ColWidth_P / 2; break; case SortBy.Rating: pointA.X = image.Width - ColWidth_R / 2; break; } Point pointB = new Point(pointA.X - 4, pointA.Y + 5); Point pointC = new Point(pointA.X + 4, pointA.Y + 5); gr.FillPolygon(FHeaderBrush, new Point[] { pointA, pointB, pointC }); }