/// <summary> /// 디자인 시에 WANIGrid Control을 WinForm 위에 올렸을 때 보여지는 WANIGrid Control의 외형을 그린다. /// </summary> /// <param name="g"></param> /// <param name="rc"></param> private void DrawDefaultWANIGridControl(Graphics g, Rectangle rc) { //WANIGrid Control의 폭과 높이에 해당하는 row와 column의 갯수를 구한다. (컬럼 폭은 80으로 고정) int cols = (rc.Width / 80) + 1; int rows = (rc.Height / rowHeight) + 1; SolidBrush brush = new SolidBrush(SystemColors.ControlLight); Pen pen = new Pen(Color.LightGray); int columnStartX = 0; g.FillRectangle(brush, columnStartX + 1, 1, leftHeaderWidth, topHeaderHeight); g.DrawRectangle(pen, columnStartX + 1, 1, leftHeaderWidth, topHeaderHeight); columnStartX += leftHeaderWidth; //첫 시작컬럼의 폭을 leftHeaderWidth 만큼 설정 for (int i = 0; i < cols; i++) { int headerWidth = 80; //i 번째 컬럼의 폭을 설정 //Grid Header를 그린다. DrawTextUtil.DrawGridHeaderRectangleAndText(g, brush, blackBrush, pen, null, headerFont, i, columnStartX, headerWidth, topHeaderHeight); columnStartX += headerWidth; } vScrollBar.Visible = true; for (int i = 0; i < rows; i++) { columnStartX = 0; g.FillRectangle(brush, columnStartX + 1, i * rowHeight, leftHeaderWidth, topHeaderHeight); g.DrawRectangle(pen, columnStartX + 1, i * rowHeight, leftHeaderWidth, topHeaderHeight); columnStartX += leftHeaderWidth; for (int j = 0; j < cols; j++) { int colWidth = 80; g.DrawRectangle(pen, columnStartX + 1, i * rowHeight, colWidth, rowHeight); Rectangle rec = new Rectangle(columnStartX + 2, (i * rowHeight) + 2, columnStartX - 2, rowHeight); columnStartX += colWidth; } } hScrollBar.Visible = true; }
/// <summary> /// 고정 컬럼이 없을 경우 Header 그리기 /// </summary> /// <param name="firstVisibleCol"></param> /// <param name="lastVisibleCol"></param> /// <param name="controlWidth"></param> /// <param name="graphics"></param> /// <param name="rect"></param> public override void DrawHeaders(int firstVisibleCol, int lastVisibleCol, int controlWidth, Graphics graphics, Rectangle rect) { SolidBrush brush = new SolidBrush(SystemColors.ControlLight); Pen pen = new Pen(Color.LightGray); int columnStartX = 0; graphics.FillRectangle(brush, columnStartX + 1, 1, leftHeaderWidth, topHeaderHeight); graphics.DrawRectangle(pen, columnStartX + 1, 1, leftHeaderWidth, topHeaderHeight); columnStartX += leftHeaderWidth; //첫 시작컬럼의 폭을 leftHeaderWidth 만큼 설정 for (int i = firstVisibleCol; i <= lastVisibleCol; i++) { if (!this._headers[i].Visible) { continue; } int headerWidth = this._headers[i].Width; //i 번째 컬럼의 폭을 설정 //보여지는 컬럼의 폭이 컨트롤의 폭 보다 클경우 if (columnStartX + headerWidth > controlWidth) { headerWidth = controlWidth - columnStartX - 3; if (lastVisibleCol == (this._headers.Count - 1)) { IsLargeLastCol = true; } } else { IsLargeLastCol = false; } //Grid Header를 그린다. DrawTextUtil.DrawGridHeaderRectangleAndText(graphics, brush, blackBrush, pen, this._headers, headerFont, i, columnStartX, headerWidth, topHeaderHeight); columnStartX += headerWidth; } }
public override void DrawHeaders(int firstVisibleCol, int lastVisibleCol, int controlWidth, Graphics graphics, Rectangle rect) { SolidBrush brush = new SolidBrush(SystemColors.ControlLight); Pen pen = new Pen(Color.LightGray); int columnStartX = 0; int calendarStartX = 0; graphics.FillRectangle(brush, columnStartX + 1, 1, leftHeaderWidth, topHeaderHeight); graphics.DrawRectangle(pen, columnStartX + 1, 1, leftHeaderWidth, topHeaderHeight); columnStartX += leftHeaderWidth; //첫 시작컬럼의 폭을 leftHeaderWidth 만큼 설정 //주차 기간을 저장하기 위한 Dictionary - width 계산을 위해 필요 Dictionary <int, List <int> > dicWeekNo = new Dictionary <int, List <int> >(); //년월 기간을 저장하기 위한 Dictionary - width 계산을 위해 필요 Dictionary <string, List <int> > dicYearMonth = new Dictionary <string, List <int> >(); for (int i = firstVisibleCol; i <= lastVisibleCol; i++) { if (!this._headers[i].Visible) { continue; } int headerWidth = this._headers[i].Width; //i 번째 컬럼의 폭을 설정 //보여지는 컬럼의 폭이 컨트롤의 폭 보다 클경우 if (columnStartX + headerWidth > controlWidth) { headerWidth = controlWidth - columnStartX - 3; if (lastVisibleCol == (this._headers.Count - 1)) { IsLargeLastCol = true; } } else { IsLargeLastCol = false; } YearMonthWeekNoDayHeader yearMonthHeader = this._headers[i] as YearMonthWeekNoDayHeader; if (yearMonthHeader.GetDateTime <= DateTime.MinValue) { //Grid Header를 그린다. DrawTextUtil.DrawGridHeaderRectangleAndText(graphics, brush, blackBrush, pen, this._headers, headerFont, i, columnStartX, headerWidth, topHeaderHeight); } else //Calendar 날짜 형태의 컬럼을 그리기 위한 사전 준비 { if (calendarStartX == 0) { calendarStartX = columnStartX; } //Calendar 날짜 형태의 컬럼 Header 그리기(일) DrawTextUtil.DrawGridHeaderCalendarRectangleAndText(graphics, brush, blackBrush, pen, this._headers, headerFont, i, columnStartX, headerWidth); if (!dicWeekNo.ContainsKey(yearMonthHeader.WeekNumber)) { dicWeekNo.Add(yearMonthHeader.WeekNumber, new List <int>()); } if (yearMonthHeader.Visible) { dicWeekNo[yearMonthHeader.WeekNumber].Add(yearMonthHeader.Width); } if (!dicYearMonth.ContainsKey(yearMonthHeader.YearMonth)) { dicYearMonth.Add(yearMonthHeader.YearMonth, new List <int>()); } if (yearMonthHeader.Visible) { dicYearMonth[yearMonthHeader.YearMonth].Add(yearMonthHeader.Width); } } columnStartX += headerWidth; } //Calendar 날짜 형태의 컬럼 Header 그리기(주차/년월) DrawTextUtil.DrawGridHeaderCalendarWeekNumberRectangleAndText(graphics, brush, blackBrush, pen, headerFont, dicWeekNo, calendarStartX); DrawTextUtil.DrawGridHeaderCalendarYearMonthRectangleAndText(graphics, brush, blackBrush, pen, headerFont, dicYearMonth, calendarStartX); }