void OnResultChanged(object sender, BaseChangedData.ChangedEventsArgs e) { if (((ResultStruct)e._new).Born != ((ResultStruct)e._old).Born) { this.Invalidate(); } else if (((ResultStruct)e._old).Quantity != ((ResultStruct)e._new).Quantity) { Graphics g = this.CreateGraphics(); RectangleF rf, rf2; rf = SmallHelper.StringInMiddle(g, new Rectangle(m_rect_QuantityDecreaseBounds.Right, m_rect_QuantityDecreaseBounds.Top, m_rect_QuantityIncreaseBounds.Left - m_rect_QuantityDecreaseBounds.Right, m_rect_QuantityDecreaseBounds.Height), ((ResultStruct)e._old).ToString(), this.Font); rf2 = SmallHelper.StringInMiddle(g, new Rectangle(m_rect_QuantityDecreaseBounds.Right, m_rect_QuantityDecreaseBounds.Top, m_rect_QuantityIncreaseBounds.Left - m_rect_QuantityDecreaseBounds.Right, m_rect_QuantityDecreaseBounds.Height), ((ResultStruct)e._new).ToString(), this.Font); this.Invalidate(new Rectangle((int)rf.X, (int)rf.Y, (int)rf.Width, (int)rf.Height)); this.Invalidate(new Rectangle((int)rf2.X, (int)rf2.Y, (int)rf2.Width, (int)rf2.Height)); g.Dispose(); if (((ResultStruct)e._new).Quantity > ((ResultStruct)e._old).Quantity && ((ResultStruct)e._old).IsMin) { this.Invalidate(m_rect_QuantityDecreaseBounds); } if (((ResultStruct)e._new).Quantity < ((ResultStruct)e._old).Quantity && ((ResultStruct)e._old).IsMax) { this.Invalidate(m_rect_QuantityIncreaseBounds); } } }
protected override void OnPaint(PaintEventArgs pe) { base.OnPaint(pe); Graphics g = pe.Graphics; // рамка SmallHelper.DrawRect(g, ContractSelector.m_pen_MainBounds2, m_rect_MainBorderBounds); m_rect_MainBorderBounds.Inflate(-1, -1); SmallHelper.DrawRect(g, ContractSelector.m_pen_MainBounds1, m_rect_MainBorderBounds); m_rect_MainBorderBounds.Inflate(1, 1); if (m_result == null) { return; } if (!this.m_result.IsDefined() || this.m_result.IsContractNo()) { // надпись [контракт не определён] или [контракт не установлен] String s1 = "Контракт"; String s2 = (!this.m_result.IsDefined() ? "не определён!" : "не установлен"); SizeF sf1 = g.MeasureString(s1, font2); SizeF sf2 = g.MeasureString(s2, font2); int y_distance = -8; g.DrawString(s1, font2, (!this.m_result.IsDefined() ? ContractSelector.m_brush_String_RED : ContractSelector.m_brush_String_BLACK), m_rect_MainBorderBounds.X + (m_rect_MainBorderBounds.Width - sf1.Width) / 2, m_rect_MainBorderBounds.Y + (m_rect_MainBorderBounds.Height - sf1.Height - sf2.Height - y_distance) / 2); g.DrawString(s2, font2, (!this.m_result.IsDefined() ? ContractSelector.m_brush_String_RED : ContractSelector.m_brush_String_BLACK), m_rect_MainBorderBounds.X + (m_rect_MainBorderBounds.Width - sf2.Width) / 2, m_rect_MainBorderBounds.Y + (m_rect_MainBorderBounds.Height - sf1.Height - sf2.Height - y_distance) / 2 + sf1.Height + y_distance); } else { // кнопка [<] SmallHelper.DrawRect(g, (!this.m_result.IsMin) ? (CapturedArea == Area.ArrowLeft && StickArea == CapturedArea ? ContractSelector.m_pen_Arrows_SELECTED : ContractSelector.m_pen_Arrows_ACTIVE) : ContractSelector.m_pen_Arrows_NONACTIVE, m_rect_QuantityDecreaseBounds); SmallHelper.FillRectInside(g, (!this.m_result.IsMin) ? (CapturedArea == Area.ArrowLeft && StickArea == CapturedArea ? ContractSelector.m_brush_Arrows_SELECTED : ContractSelector.m_brush_Arrows_ACTIVE) : ContractSelector.m_brush_Arrows_NONACTIVE, m_rect_QuantityDecreaseBounds); SmallHelper.DrawBmpTransp(g, (!this.m_result.IsMin) ? ContractSelector.m_bmp_Arrow_Left : ContractSelector.m_bmp_Arrow_Left_Passive, new Point(m_rect_QuantityDecreaseBounds.Right - arrow_offset - ContractSelector.m_bmp_Arrow_Left.Width, m_rect_QuantityDecreaseBounds.Top + (m_rect_QuantityDecreaseBounds.Height - ContractSelector.m_bmp_Arrow_Left.Height) / 2)); // кнопка [>] SmallHelper.DrawRect(g, (!this.m_result.IsMax) ? (CapturedArea == Area.ArrowRight && StickArea == CapturedArea ? ContractSelector.m_pen_Arrows_SELECTED : ContractSelector.m_pen_Arrows_ACTIVE) : ContractSelector.m_pen_Arrows_NONACTIVE, m_rect_QuantityIncreaseBounds); SmallHelper.FillRectInside(g, (!this.m_result.IsMax) ? (CapturedArea == Area.ArrowRight && StickArea == CapturedArea ? ContractSelector.m_brush_Arrows_SELECTED : ContractSelector.m_brush_Arrows_ACTIVE) : ContractSelector.m_brush_Arrows_NONACTIVE, m_rect_QuantityIncreaseBounds); SmallHelper.DrawBmpTransp(g, (!this.m_result.IsMax) ? ContractSelector.m_bmp_Arrow_Right : ContractSelector.m_bmp_Arrow_Right_Passive, new Point(m_rect_QuantityIncreaseBounds.Left + arrow_offset, m_rect_QuantityIncreaseBounds.Top + (m_rect_QuantityIncreaseBounds.Height - ContractSelector.m_bmp_Arrow_Right.Height) / 2)); // цифра RectangleF rf = SmallHelper.StringInMiddle(g, new Rectangle(m_rect_QuantityDecreaseBounds.Right, m_rect_QuantityDecreaseBounds.Top, m_rect_QuantityIncreaseBounds.Left - m_rect_QuantityDecreaseBounds.Right, m_rect_QuantityDecreaseBounds.Height), this.m_result.ToString(), this.Font); g.DrawString(this.m_result.ToString(), this.Font, this.m_result.Quantity >= 0 ? ContractSelector.m_brush_String_GREEN : ContractSelector.m_brush_String_RED, rf /*m_rect_QuantityNumber.X, m_rect_QuantityNumber.Y*/); } }
protected override void OnPaint(PaintEventArgs pe) { base.OnPaint(pe); Graphics g = pe.Graphics; // [delme!!!] Заполнить чем-то всю область g.FillRectangle(new SolidBrush(Color.Gray), this.ClientRectangle); // Граница SmallHelper.DrawRect(g, m_pen_Black, new Rectangle(0, 0, total_width, total_height)); SmallHelper.FillRectInside(g, m_brush, new Rectangle(0, 0, total_width, total_height)); // Элементы Rectangle r = new Rectangle(); RectangleF rf; int jw = 1, jh = 1; bool jf = false; object o; for (int i = 0; i < DATA__arr.Count; i++) { for (int j = 0; j < DATA__columns; j++) { if (GetJoinInfo(j, i, out jf, out jw, out jh) == true) { if (!jf) { continue; } } r.Width = (jw - 1) * PAINT__border_delay + 2 * jw; for (int x = j; x < (j + jw); x++) { r.Width += PAINT__columns_widths[x]; } r.Height = (jh - 1) * PAINT__border_delay + 2 * jh; for (int x = i; x < (i + jh); x++) { r.Height += (x < PAINT__columns_heights.Count ? PAINT__columns_heights[x] : PAINT__data_height); } r.X = (1 + PAINT__border_delay); for (int x = 0; x < j; x++) { r.X += (PAINT__columns_widths[x] + 1 + PAINT__border_delay + 1); } r.Y = (1 + PAINT__border_delay); for (int x = 0; x < i; x++) { r.Y += (x < PAINT__columns_heights.Count ? PAINT__columns_heights[x] : PAINT__data_height) + 1 + PAINT__border_delay + 1; } SmallHelper.DrawRect(g, m_pen_Black, r); bool isHeader = (i < PAINT__headerLinesUp) || (j < PAINT__headerLinesLeft); SmallHelper.FillRectInside(g, (isHeader ? m_brushH : ((i - PAINT__headerLinesUp) % 2 == 0 ? m_brush1 : m_brush2)), r); o = ((ArrayList)DATA__arr[i])[j]; rf = SmallHelper.StringInMiddle(g, r, (o == null ? "" : o.ToString()), (isHeader ? this.FontBold : this.Font)); SmallHelper.DrawMultiString(g, r, (o == null ? "" : o.ToString()), (isHeader ? this.FontBold : this.Font), m_brush_Font, StringAlignment.Center, StringAlignment.Center, StringAlignment.Center, 0, 0, -5); //g.DrawString((o == null ? "" : o.ToString()), (isHeader ? this.FontBold : this.Font), m_brush_Font, rf); } } g.Dispose(); }
void OnContractChanged(object sender, BaseChangedData.ChangedEventsArgs e) { if (((ContractStruct)e._old).Quantity != ((ContractStruct)e._new).Quantity) { Graphics g = this.CreateGraphics(); RectangleF rf, rf2; rf = SmallHelper.StringInMiddle(g, new Rectangle(m_rect_QuantityDecreaseBounds.Right, m_rect_QuantityDecreaseBounds.Top, m_rect_QuantityIncreaseBounds.Left - m_rect_QuantityDecreaseBounds.Right, m_rect_QuantityDecreaseBounds.Height), ((ContractStruct)e._old).GetString1(), quantityNum_font); rf2 = SmallHelper.StringInMiddle(g, new Rectangle(m_rect_QuantityDecreaseBounds.Right, m_rect_QuantityDecreaseBounds.Top, m_rect_QuantityIncreaseBounds.Left - m_rect_QuantityDecreaseBounds.Right, m_rect_QuantityDecreaseBounds.Height), ((ContractStruct)e._new).GetString1(), quantityNum_font); this.Invalidate(new Rectangle((int)rf.X, (int)rf.Y, (int)rf.Width, (int)rf.Height)); this.Invalidate(new Rectangle((int)rf2.X, (int)rf2.Y, (int)rf2.Width, (int)rf2.Height)); g.Dispose(); if (((ContractStruct)e._new).Quantity == 0 || ((ContractStruct)e._old).Quantity == 0) { this.Invalidate(m_rect_QuantityDecreaseBounds); this.Invalidate(m_rect_QuantityIncreaseBounds); } else { if (((ContractStruct)e._new).Quantity > ((ContractStruct)e._old).Quantity && ((ContractStruct)e._old).Quantity == 1) { this.Invalidate(m_rect_QuantityDecreaseBounds); } if (((ContractStruct)e._new).Quantity < ((ContractStruct)e._old).Quantity && ((ContractStruct)e._old).Quantity == 7) { this.Invalidate(m_rect_QuantityIncreaseBounds); } } } if (((ContractStruct)e._old).Trump != ((ContractStruct)e._new).Trump) { switch (((ContractStruct)e._old).Trump) { case CardTrump.Clubs: this.Invalidate(m_rect_ClubsBounds); break; case CardTrump.Diamonds: this.Invalidate(m_rect_DiamondsBounds); break; case CardTrump.Hearts: this.Invalidate(m_rect_HeartsBounds); break; case CardTrump.Spades: this.Invalidate(m_rect_SpadesBounds); break; case CardTrump.NT: this.Invalidate(m_rect_NTBounds); break; } } if (((ContractStruct)e._old).Contra != ((ContractStruct)e._new).Contra) { this.Invalidate(new Rectangle(m_rect_ContraBounds.Left + check_offset_img.X, m_rect_ContraBounds.Top + check_offset_img.Y, m_bmp_Check_True.Width, m_bmp_Check_True.Height)); } if (((ContractStruct)e._old).ReContra != ((ContractStruct)e._new).ReContra) { this.Invalidate(new Rectangle(m_rect_ReContraBounds.Left + check_offset_img.X, m_rect_ReContraBounds.Top + check_offset_img.Y, m_bmp_Check_True.Width, m_bmp_Check_True.Height)); } if (((ContractStruct)e._old).NoContract != ((ContractStruct)e._new).NoContract) { this.Invalidate(m_rect_NOCONTRACT); } }
protected override void OnPaint(PaintEventArgs pe) { base.OnPaint(pe); Graphics g = pe.Graphics; RectangleF rf, rf2; // рамка SmallHelper.DrawRect(g, m_pen_MainBounds2, m_rect_MainBorderBounds); m_rect_MainBorderBounds.Inflate(-1, -1); SmallHelper.DrawRect(g, m_pen_MainBounds1, m_rect_MainBorderBounds); m_rect_MainBorderBounds.Inflate(1, 1); if (this.m_contract == null) { return; } // кнопка [<] SmallHelper.DrawRect(g, (this.m_contract.Quantity > 1) ? (CapturedArea == Area.ArrowLeft && StickArea == CapturedArea ? m_pen_Arrows_SELECTED : m_pen_Arrows_ACTIVE) : m_pen_Arrows_NONACTIVE, m_rect_QuantityDecreaseBounds); SmallHelper.FillRectInside(g, (this.m_contract.Quantity > 1) ? (CapturedArea == Area.ArrowLeft && StickArea == CapturedArea ? m_brush_Arrows_SELECTED : m_brush_Arrows_ACTIVE) : m_brush_Arrows_NONACTIVE, m_rect_QuantityDecreaseBounds); SmallHelper.DrawBmpTransp(g, (this.m_contract.Quantity > 1) ? m_bmp_Arrow_Left : m_bmp_Arrow_Left_Passive, new Point(m_rect_QuantityDecreaseBounds.Right - arrow_offset - m_bmp_Arrow_Left.Width, m_rect_QuantityDecreaseBounds.Top + (m_rect_QuantityDecreaseBounds.Height - m_bmp_Arrow_Left.Height) / 2)); // кнопка [>] SmallHelper.DrawRect(g, (this.m_contract.Quantity < 7 && this.m_contract.Quantity != 0) ? (CapturedArea == Area.ArrowRight && StickArea == CapturedArea ? m_pen_Arrows_SELECTED : m_pen_Arrows_ACTIVE) : m_pen_Arrows_NONACTIVE, m_rect_QuantityIncreaseBounds); SmallHelper.FillRectInside(g, (this.m_contract.Quantity < 7 && this.m_contract.Quantity != 0) ? (CapturedArea == Area.ArrowRight && StickArea == CapturedArea ? m_brush_Arrows_SELECTED : m_brush_Arrows_ACTIVE) : m_brush_Arrows_NONACTIVE, m_rect_QuantityIncreaseBounds); SmallHelper.DrawBmpTransp(g, (this.m_contract.Quantity < 7 && this.m_contract.Quantity != 0) ? m_bmp_Arrow_Right : m_bmp_Arrow_Right_Passive, new Point(m_rect_QuantityIncreaseBounds.Left + arrow_offset, m_rect_QuantityIncreaseBounds.Top + (m_rect_QuantityIncreaseBounds.Height - m_bmp_Arrow_Right.Height) / 2)); // цифра rf = SmallHelper.StringInMiddle(g, new Rectangle(m_rect_QuantityDecreaseBounds.Right, m_rect_QuantityDecreaseBounds.Top, m_rect_QuantityIncreaseBounds.Left - m_rect_QuantityDecreaseBounds.Right, m_rect_QuantityDecreaseBounds.Height), this.m_contract.GetString1(), quantityNum_font); g.DrawString(this.m_contract.GetString1(), quantityNum_font, m_brush_String, rf /*m_rect_QuantityNumber.X, m_rect_QuantityNumber.Y*/); // козыри rf = SmallHelper.StringInMiddle(g, new Rectangle(m_rect_ClubsBounds.X, m_rect_ClubsBounds.Y, m_bmp_CuteBtn.Width, m_bmp_CuteBtn.Height), "♣", suits_font); SmallHelper.DrawBmpTransp(g, (this.m_contract.Trump == CardTrump.Clubs || CapturedArea == Area.Clubs && StickArea == CapturedArea) ? m_bmp_CuteBtn_Selected : m_bmp_CuteBtn, m_rect_ClubsBounds.Location); g.DrawString("♣", suits_font, (this.m_contract.Trump == CardTrump.Clubs || CapturedArea == Area.Clubs && StickArea == CapturedArea) ? m_brush_String_ANTIBLACK : m_brush_String_BLACK, rf.X, rf.Y); rf = SmallHelper.StringInMiddle(g, new Rectangle(m_rect_SpadesBounds.X, m_rect_SpadesBounds.Y, m_bmp_CuteBtn.Width, m_bmp_CuteBtn.Height), "♠", suits_font); SmallHelper.DrawBmpTransp(g, (this.m_contract.Trump == CardTrump.Spades || CapturedArea == Area.Spades && StickArea == CapturedArea) ? m_bmp_CuteBtn_Selected : m_bmp_CuteBtn, m_rect_SpadesBounds.Location); g.DrawString("♠", suits_font, (this.m_contract.Trump == CardTrump.Spades || CapturedArea == Area.Spades && StickArea == CapturedArea) ? m_brush_String_ANTIBLACK : m_brush_String_BLACK, rf.X, rf.Y); rf = SmallHelper.StringInMiddle(g, new Rectangle(m_rect_HeartsBounds.X, m_rect_HeartsBounds.Y, m_bmp_CuteBtn.Width, m_bmp_CuteBtn.Height), "♥", suits_font); SmallHelper.DrawBmpTransp(g, (this.m_contract.Trump == CardTrump.Hearts || CapturedArea == Area.Hearts && StickArea == CapturedArea) ? m_bmp_CuteBtn_Selected : m_bmp_CuteBtn, m_rect_HeartsBounds.Location); g.DrawString("♥", suits_font, (this.m_contract.Trump == CardTrump.Hearts || CapturedArea == Area.Hearts && StickArea == CapturedArea) ? m_brush_String_ANTIRED : m_brush_String_RED, rf.X, rf.Y); rf = SmallHelper.StringInMiddle(g, new Rectangle(m_rect_DiamondsBounds.X, m_rect_DiamondsBounds.Y, m_bmp_CuteBtn.Width, m_bmp_CuteBtn.Height), "♦", suits_font); SmallHelper.DrawBmpTransp(g, (this.m_contract.Trump == CardTrump.Diamonds || CapturedArea == Area.Diamonds && StickArea == CapturedArea) ? m_bmp_CuteBtn_Selected : m_bmp_CuteBtn, m_rect_DiamondsBounds.Location); g.DrawString("♦", suits_font, (this.m_contract.Trump == CardTrump.Diamonds || CapturedArea == Area.Diamonds && StickArea == CapturedArea) ? m_brush_String_ANTIRED : m_brush_String_RED, rf.X, rf.Y); rf = SmallHelper.StringInMiddle(g, new Rectangle(m_rect_NTBounds.X, m_rect_NTBounds.Y, m_bmp_CuteBtn_Twice.Width, m_bmp_CuteBtn_Twice.Height), "N", nt_font); rf2 = SmallHelper.StringInMiddle(g, new Rectangle(m_rect_NTBounds.X, m_rect_NTBounds.Y, m_bmp_CuteBtn_Twice.Width, m_bmp_CuteBtn_Twice.Height), "T", nt_font); float nt_height = rf.Height + n_t_distance + rf2.Height; float n_y = m_rect_NTBounds.Y + (m_bmp_CuteBtn_Twice.Height - nt_height) / 2; float t_y = n_y + rf.Height + n_t_distance; SmallHelper.DrawBmpTransp(g, (this.m_contract.Trump == CardTrump.NT || CapturedArea == Area.NT && StickArea == CapturedArea) ? m_bmp_CuteBtn_Twice_Selected : m_bmp_CuteBtn_Twice, m_rect_NTBounds.Location); g.DrawString("N", nt_font, (this.m_contract.Trump == CardTrump.NT || CapturedArea == Area.NT && StickArea == CapturedArea) ? m_brush_String_ANTIBLACK : m_brush_String_BLACK, rf.X, n_y /*m_rect_NTBounds.X + nt_offset[0].X, m_rect_NTBounds.Y + nt_offset[0].Y*/); g.DrawString("T", nt_font, (this.m_contract.Trump == CardTrump.NT || CapturedArea == Area.NT && StickArea == CapturedArea) ? m_brush_String_ANTIBLACK : m_brush_String_BLACK, rf2.X, t_y /*m_rect_NTBounds.X + nt_offset[1].X, m_rect_NTBounds.Y + nt_offset[1].Y*/); // контра SmallHelper.DrawBmpTransp(g, (CapturedArea == Area.Contra && StickArea == CapturedArea) ? m_bmp_Check_Half : (this.m_contract.Contra ? m_bmp_Check_True : m_bmp_Check_False), new Point(m_rect_ContraBounds.Left + check_offset_img.X, m_rect_ContraBounds.Top + check_offset_img.Y)); g.DrawString("Double", re_contra_font, m_brush_String, m_rect_ContraBounds.Left + check_offset_img.X + m_bmp_Check_False.Width + check_offset_text.X, m_rect_ContraBounds.Top + check_offset_text.Y); // реконтра SmallHelper.DrawBmpTransp(g, (CapturedArea == Area.ReContra && StickArea == CapturedArea) ? m_bmp_Check_Half : (this.m_contract.ReContra ? m_bmp_Check_True : m_bmp_Check_False), new Point(m_rect_ReContraBounds.Left + check_offset_img.X, m_rect_ReContraBounds.Top + check_offset_img.Y)); g.DrawString("Redouble", re_contra_font, m_brush_String, m_rect_ReContraBounds.Left + check_offset_img.X + m_bmp_Check_False.Width + check_offset_text.X, m_rect_ReContraBounds.Top + check_offset_text.Y); // неконтракт rf = SmallHelper.StringInMiddle(g, m_rect_NOCONTRACT, "ВСЕ ПАС", NO_font); SmallHelper.DrawBmpTransp(g, (CapturedArea == Area.NOCONTRACT && StickArea == CapturedArea) ? (this.m_contract.NoContract == true ? m_bmp_CuteBtn_Long : m_bmp_CuteBtn_Long_Selected) : (this.m_contract.NoContract == true ? m_bmp_CuteBtn_Long_Selected : m_bmp_CuteBtn_Long), m_rect_NOCONTRACT.Location); g.DrawString("ВСЕ ПАС", NO_font, (CapturedArea == Area.NOCONTRACT && StickArea == CapturedArea) ? (this.m_contract.NoContract == true ? m_brush_String_RED : m_brush_String_ANTIRED) : (this.m_contract.NoContract == true ? m_brush_String_ANTIRED : m_brush_String_RED), rf.X, rf.Y); }
protected override void OnPaint(PaintEventArgs pe) { base.OnPaint(pe); if (m_robber == null) { return; } Graphics g = pe.Graphics; Rectangle rf1 = new Rectangle(); RectangleF rf2 = new RectangleF(); Pen pen_Black = new Pen(Color.Black); Pen pen_BorderBetween = new Pen(Color.Blue); int ValidDealsCount = m_robber.GetValidDealsCount(); int CompletedDealsCount = m_robber.WhereCompleted() + 1; if (m_robber.WhereCompleted() != -1 && CompletedDealsCount < ValidDealsCount) { ValidDealsCount = CompletedDealsCount; } // V Разделитель int bonus_lines = 0, bonus_lines_ns = 0, bonus_lines_ew = 0; for (int i = 0; i < ValidDealsCount; i++) { if (m_robber.ScoreArray[i].NS_up != null && m_robber.ScoreArray[i].NS_up.Length != 0) { bonus_lines_ns += m_robber.ScoreArray[i].NS_up.Length; } if (m_robber.ScoreArray[i].EW_up != null && m_robber.ScoreArray[i].EW_up.Length != 0) { bonus_lines_ew += m_robber.ScoreArray[i].EW_up.Length; } } bonus_lines += (bonus_lines_ns > bonus_lines_ew ? bonus_lines_ns : bonus_lines_ew); int usual_lines = 0, usual_lines_ns = 0, usual_lines_ew = 0; int iNS = 0, iEW = 0; for (int i = 0; i < ValidDealsCount; i++) { if (m_robber.ScoreArray[i].EW_down != 0) { usual_lines_ew++; iEW += m_robber.ScoreArray[i].EW_down; } else if (m_robber.ScoreArray[i].NS_down != 0) { usual_lines_ns++; iNS += m_robber.ScoreArray[i].NS_down; } if (iNS >= 100 || iEW >= 100) { usual_lines += (usual_lines_ns > usual_lines_ew ? usual_lines_ns : usual_lines_ew); usual_lines_ew = usual_lines_ns = 0; iNS = iEW = 0; } } usual_lines += (usual_lines_ns > usual_lines_ew ? usual_lines_ns : usual_lines_ew); int total_lines = bonus_lines + usual_lines; int separators = 1 + m_robber.HowManyValidGames(); bool is_main_separator_half = (usual_lines == 0 || bonus_lines == 0); bool is_closing_separator_half = (ValidDealsCount > 0 ? m_robber.IsClearAfterGame(ValidDealsCount - 1) : false); int total_height = total_lines * (int)size1.Height + separators * (1 + 2 * spaceV_Boundary); if (m_robber.IsCompleted()) { total_height -= spaceV_Boundary; } if (total_lines > 0) { total_height += (total_lines - 1 - separators + (is_main_separator_half ? 1 : 0) + (is_closing_separator_half ? 1 : 0)) * space.Height; } // Посчитать, влезают ли все очки по вертикали: bool use_compact_bonuses = false; // сжать бонусы? int robber_line_full_height = offset.Height * 2 + (height_Header + spaceV_Header) + total_height; //полная высота if (robber_line_full_height > ClientSize.Height) { use_compact_bonuses = true; } if (bonus_lines == 0) { use_compact_bonuses = false; } // Сжать бонусы if (use_compact_bonuses) { bonus_lines = 1; total_lines = bonus_lines + usual_lines; total_height = total_lines * (int)size1.Height + separators * (1 + 2 * spaceV_Boundary); if (m_robber.IsCompleted()) { total_height -= spaceV_Boundary; } if (total_lines > 0) { total_height += (total_lines - 1 - separators + (is_main_separator_half ? 1 : 0) + (is_closing_separator_half ? 1 : 0)) * space.Height; } } g.DrawLine(pen_Black, offset.Width + (int)size1.Width + 1 * space.Width, offset.Height + (height_Header + spaceV_Header), offset.Width + (int)size1.Width + 1 * space.Width, offset.Height + (height_Header + spaceV_Header) + total_height - 1); //добавить +1 за толстую черту // заголовок: NS и EW rf1.X = offset.Width; rf1.Y = offset.Height; rf1.Width = (int)size1.Width; rf1.Height = height_Header; rf2 = SmallHelper.StringInMiddle(g, rf1, "NS", this.fontHeader); g.DrawString("NS", this.fontHeader, this.brushHeader, rf2); rf1.X = offset.Width + (int)size1.Width + 2 * space.Width + 1; rf2 = SmallHelper.StringInMiddle(g, rf1, "EW", this.fontHeader); g.DrawString("EW", this.fontHeader, this.brushHeader, rf2); // Бонусы if (!use_compact_bonuses) { bonus_lines_ns = 0; bonus_lines_ew = 0; rf1.Width = (int)size1.Width; rf1.Height = (int)size1.Height; for (int i = 0; i < ValidDealsCount; i++) { if (m_robber.ScoreArray[i].NS_up != null && m_robber.ScoreArray[i].NS_up.Length != 0) { for (int j = 0; j < m_robber.ScoreArray[i].NS_up.Length; j++) { bonus_lines_ns++; rf1.X = offset.Width; rf1.Y = offset.Height + (height_Header + spaceV_Header) + (bonus_lines - bonus_lines_ns) * ((int)size1.Height + space.Height); rf2 = SmallHelper.StringInMiddle(g, rf1, m_robber.ScoreArray[i].NS_up[j].ToString(), this.Font); g.DrawString(m_robber.ScoreArray[i].NS_up[j].ToString(), this.Font, this.brushText, rf2); } } if (m_robber.ScoreArray[i].EW_up != null && m_robber.ScoreArray[i].EW_up.Length != 0) { for (int j = 0; j < m_robber.ScoreArray[i].EW_up.Length; j++) { bonus_lines_ew++; rf1.X = offset.Width + (int)size1.Width + 2 * space.Width + 1; rf1.Y = offset.Height + (height_Header + spaceV_Header) + (bonus_lines - bonus_lines_ew) * ((int)size1.Height + space.Height); rf2 = SmallHelper.StringInMiddle(g, rf1, m_robber.ScoreArray[i].EW_up[j].ToString(), this.Font); g.DrawString(m_robber.ScoreArray[i].EW_up[j].ToString(), this.Font, this.brushText, rf2); } } } } else { int total_bonuses_NS = 0, total_bonuses_EW = 0; for (int i = 0; i < ValidDealsCount; i++) { if (m_robber.ScoreArray[i].NS_up != null && m_robber.ScoreArray[i].NS_up.Length != 0) { for (int j = 0; j < m_robber.ScoreArray[i].NS_up.Length; j++) { total_bonuses_NS += m_robber.ScoreArray[i].NS_up[j]; } } if (m_robber.ScoreArray[i].EW_up != null && m_robber.ScoreArray[i].EW_up.Length != 0) { for (int j = 0; j < m_robber.ScoreArray[i].EW_up.Length; j++) { total_bonuses_EW += m_robber.ScoreArray[i].EW_up[j]; } } } rf1.Width = (int)size1.Width; rf1.Height = (int)size1.Height; rf1.X = offset.Width; rf1.Y = offset.Height + (height_Header + spaceV_Header); rf2 = SmallHelper.StringInMiddle(g, rf1, total_bonuses_NS.ToString(), this.Font); g.DrawString(total_bonuses_NS.ToString(), this.Font, this.brushText, rf2); rf1.X = offset.Width + (int)size1.Width + 2 * space.Width + 1; rf2 = SmallHelper.StringInMiddle(g, rf1, total_bonuses_EW.ToString(), this.Font); g.DrawString(total_bonuses_EW.ToString(), this.Font, this.brushText, rf2); } // Черта между бонусами и основным счетом: int yBorder = offset.Height + (height_Header + spaceV_Header) + spaceV_Boundary; if (bonus_lines > 0) { yBorder += bonus_lines * (int)size1.Height + (bonus_lines - 1) * space.Height; } g.DrawLine(pen_BorderBetween, offset.Width, yBorder, this.Width - offset.Width - 1, yBorder); //g.DrawLine(pen_Black, offset.Width, yBorder + 1, this.Width - offset.Width - 1, yBorder + 1); //тостая черта // Основные очки usual_lines = 0; usual_lines_ns = 0; usual_lines_ew = 0; iNS = 0; iEW = 0; separators = 1; for (int i = 0; i < ValidDealsCount; i++) { if (m_robber.ScoreArray[i].NS_down != 0) { iNS += m_robber.ScoreArray[i].NS_down; usual_lines_ns++; rf1.X = offset.Width; rf1.Y = offset.Height + (height_Header + spaceV_Header) + (bonus_lines + usual_lines + usual_lines_ns - 1) * (int)size1.Height + separators * (1 + 2 * spaceV_Boundary); //rf1.Y++; // для толстой черты if (bonus_lines + usual_lines + usual_lines_ns > 0) { rf1.Y += (bonus_lines + usual_lines + usual_lines_ns - 1 - separators + (is_main_separator_half ? 1 : 0)) * space.Height; } rf2 = SmallHelper.StringInMiddle(g, rf1, m_robber.ScoreArray[i].NS_down.ToString(), this.Font); g.DrawString(m_robber.ScoreArray[i].NS_down.ToString(), this.Font, this.brushText, rf2); } else if (m_robber.ScoreArray[i].EW_down != 0) { iEW += m_robber.ScoreArray[i].EW_down; usual_lines_ew++; rf1.X = offset.Width + (int)size1.Width + 2 * space.Width + 1; rf1.Y = offset.Height + (height_Header + spaceV_Header) + (bonus_lines + usual_lines + usual_lines_ew - 1) * (int)size1.Height + separators * (1 + 2 * spaceV_Boundary); //rf1.Y++; // для толстой черты if (bonus_lines + usual_lines + usual_lines_ew > 0) { rf1.Y += (bonus_lines + usual_lines + usual_lines_ew - 1 - separators + (is_main_separator_half ? 1 : 0)) * space.Height; } rf2 = SmallHelper.StringInMiddle(g, rf1, m_robber.ScoreArray[i].EW_down.ToString(), this.Font); g.DrawString(m_robber.ScoreArray[i].EW_down.ToString(), this.Font, this.brushText, rf2); } if (iEW >= 100 || iNS >= 100) { usual_lines += (usual_lines_ns > usual_lines_ew ? usual_lines_ns : usual_lines_ew); usual_lines_ew = usual_lines_ns = 0; iNS = iEW = 0; // Черта после гейма: yBorder = offset.Height + (height_Header + spaceV_Header) + (bonus_lines + usual_lines) * (int)size1.Height + separators * (1 + 2 * spaceV_Boundary) + spaceV_Boundary; //yBorder++; // для толстой черты if (bonus_lines + usual_lines > 0) { yBorder += (bonus_lines + usual_lines - 1 - separators + (is_main_separator_half ? 1 : 0)) * space.Height; } g.DrawLine(pen_Black, offset.Width, yBorder, this.Width - offset.Width - 1, yBorder); separators++; } } pen_Black.Dispose(); }