private void InitCells() { _calendar[,] tmp = new _calendar[6,7]; for (int i = 0; i < tmp.GetUpperBound(0); i++) { int[] n = mHelper.GetDigitsForRow(i); for(int d=0; d<n.Length; d++) { if(mHelper.IsWithinCurrentMonth(i, d)) tmp[i,d] = new _calendar(n[d], true); else tmp[i,d] = new _calendar(n[d]); } } DateTime today = DateTime.Now; int thisDay = 0; mToday = null; if(mHelper.Year == today.Year && mHelper.Month == today.Month) thisDay = today.Day; // build cells Rect Bound = new Rect(CELL_MARGIN_LEFT, CELL_MARGIN_TOP, CELL_WIDTH+CELL_MARGIN_LEFT, CELL_HEIGH+CELL_MARGIN_TOP); int bound0 = mCells.GetUpperBound(0); int bound1 = mCells.GetUpperBound(1); for (int week = 0; week < bound0; week++) { for (int day = 0; day < bound1; day++) { if(tmp[week,day].thisMonth) { if(day==0 || day==6 ) mCells[week,day] = new RedCell(tmp[week,day].day, new Rect(Bound), CELL_TEXT_SIZE); else mCells[week,day] = new Cell(tmp[week,day].day, new Rect(Bound), CELL_TEXT_SIZE); } else { mCells[week,day] = new GrayCell(tmp[week,day].day, new Rect(Bound), CELL_TEXT_SIZE); } Bound.Offset(CELL_WIDTH, 0); // move to next column // get today if(tmp[week,day].day==thisDay && tmp[week,day].thisMonth) { mToday = mCells[week,day]; mDecoration.SetBounds(mToday.Bounds.Left, mToday.Bounds.Top, mToday.Bounds.Right, mToday.Bounds.Bottom); } } Bound.Offset(0, CELL_HEIGH); // move to next row and first column Bound.Left = CELL_MARGIN_LEFT; Bound.Right = CELL_MARGIN_LEFT+CELL_WIDTH; } }
private void InitCells() { _calendar[,] tmp = new _calendar[6, 7]; for (int i = 0; i < tmp.GetUpperBound(0); i++) { int[] n = mHelper.GetDigitsForRow(i); for (int d = 0; d < n.Length; d++) { if (mHelper.IsWithinCurrentMonth(i, d)) { tmp[i, d] = new _calendar(n[d], true); } else { tmp[i, d] = new _calendar(n[d]); } } } DateTime today = DateTime.Now; int thisDay = 0; mToday = null; if (mHelper.Year == today.Year && mHelper.Month == today.Month) { thisDay = today.Day; } // build cells Rect Bound = new Rect(CELL_MARGIN_LEFT, CELL_MARGIN_TOP, CELL_WIDTH + CELL_MARGIN_LEFT, CELL_HEIGH + CELL_MARGIN_TOP); int bound0 = mCells.GetUpperBound(0); int bound1 = mCells.GetUpperBound(1); for (int week = 0; week < bound0; week++) { for (int day = 0; day < bound1; day++) { if (tmp[week, day].thisMonth) { if (day == 0 || day == 6) { mCells[week, day] = new RedCell(tmp[week, day].day, new Rect(Bound), CELL_TEXT_SIZE); } else { mCells[week, day] = new Cell(tmp[week, day].day, new Rect(Bound), CELL_TEXT_SIZE); } } else { mCells[week, day] = new GrayCell(tmp[week, day].day, new Rect(Bound), CELL_TEXT_SIZE); } Bound.Offset(CELL_WIDTH, 0); // move to next column // get today if (tmp[week, day].day == thisDay && tmp[week, day].thisMonth) { mToday = mCells[week, day]; mDecoration.SetBounds(mToday.Bounds.Left, mToday.Bounds.Top, mToday.Bounds.Right, mToday.Bounds.Bottom); } } Bound.Offset(0, CELL_HEIGH); // move to next row and first column Bound.Left = CELL_MARGIN_LEFT; Bound.Right = CELL_MARGIN_LEFT + CELL_WIDTH; } }