Example #1
0
 private void FillHolidayBackgroundColor(Graphics g)
 {
     if (grid.GridDisplayType != GridType.YearMonthWeekNoDayType)
     {
         return;
     }
     //고정 컬럼이 없을 경우
     if (colFixed == 0)
     {
         int startX = leftHeaderWidth;
         for (int i = firstVisibleCol; i <= lastVisibleCol; i++)
         {
             YearMonthWeekNoDayHeader yearMonthHeader = grid.GridHeaderList[i] as YearMonthWeekNoDayHeader;
             if (yearMonthHeader.IsHoliday)
             {
                 g.FillRectangle(holidayColorBrush, startX + 1, topHeaderHeight + 1, yearMonthHeader.Width, allRowsHeight - (rowHeight * firstVisibleRow) + 1);
             }
             startX += yearMonthHeader.Width;
         }
     }
     else
     {
         int startX = leftHeaderWidth + GetFixedColWidth();
         for (int i = firstVisibleCol + colFixed; i <= lastVisibleCol && i < grid.GridHeaderList.Count; i++)
         {
             YearMonthWeekNoDayHeader yearMonthHeader = grid.GridHeaderList[i] as YearMonthWeekNoDayHeader;
             if (yearMonthHeader.IsHoliday)
             {
                 g.FillRectangle(holidayColorBrush, startX + 1, topHeaderHeight + 1, yearMonthHeader.Width, allRowsHeight - (rowHeight * firstVisibleRow) + 1);
             }
             startX += grid.GridHeaderList[i].Width;
         }
     }
 }
Example #2
0
        /// <summary>
        /// Control의 Backgroud 그리기
        /// </summary>
        /// <param name="g"></param>
        /// <param name="rc"></param>
        private void DrawBackground(Graphics g, Rectangle rc)
        {
            g.DrawRectangle(new Pen(SystemColors.Control, 2), 0, 0, rc.Width, rc.Height);
            rc.Inflate(-1, -1);
            g.FillRectangle(new SolidBrush(SystemColors.ControlLightLight), rc);

            int lastFixedCol = GetLastFixedCol();

            if (lastFixedCol == -1)
            {
                DrawDefaultWANIGridControl(g, rc);
                return;
            }

            int enableFixCol = 0;

            for (int i = 0; i <= lastFixedCol; i++)
            {
                YearMonthWeekNoDayHeader yearMonthHeader = grid.GridHeaderList[i] as YearMonthWeekNoDayHeader;
                if (yearMonthHeader != null && yearMonthHeader.GetDateTime <= DateTime.MinValue)
                {
                    enableFixCol = i;
                }
            }
            if (enableFixCol > 0 && lastFixedCol > enableFixCol)
            {
                lastFixedCol = enableFixCol;
            }

            //선택된 컬럼의 Background를 그린다.
            SelectedColChangeBackground(g, lastFixedCol);

            //선택된 행(Row)의 Background를 그린다.
            SelectedRowChangeBackground(g, lastFixedCol);

            //휴일 색상을 그린다
            FillHolidayBackgroundColor(g);
        }
Example #3
0
        /// <summary>
        /// Grid의 내용 그리기
        /// </summary>
        /// <param name="g"></param>
        /// <param name="rc"></param>
        /// <param name="controlWidth"></param>
        private void DrawContent(Graphics g, Rectangle rc, int controlWidth)
        {
            SolidBrush brush = new SolidBrush(SystemColors.ControlLight);
            Pen        pen   = new Pen(Color.LightGray);

            if (rows.Count <= 0)
            {
                return;
            }
            g.Clip = new Region(new Rectangle(1, topHeaderHeight, Width - ysclWidth + 2, Height - xsclHeight - topHeaderHeight));

            int columnStartY = topHeaderHeight;

            for (int i = firstVisibleRow; i <= lastVisibleRow && i < rows.Count; i++)
            {
                if (rows[i].Hidden)
                {
                    continue;
                }
                int columnStartX = 0;
                int columnWidth  = 0;

                //고정 컬럼이 없을 경우
                if (colFixed == 0)
                {
                    g.FillRectangle(brush, 1, columnStartY + 1, leftHeaderWidth, rowHeight);
                    g.DrawRectangle(pen, 1, columnStartY + 1, leftHeaderWidth, rowHeight);
                    columnStartX += leftHeaderWidth;  //첫 시작컬럼의 폭을 leftHeaderWidth 만큼 설정

                    for (int j = firstVisibleCol; j <= lastVisibleCol; j++)
                    {
                        Col    col     = new Col(this.grid.HeaderGen.GetHeaders(), rows[i].DataRow);
                        string content = col.GetColText(j);

                        if (!grid.GridHeaderList[j].Visible)
                        {
                            continue;
                        }

                        //보여지는 컬럼의 폭이 컨트롤의 폭 보다 클경우
                        if (columnStartX + grid.GridHeaderList[j].Width > controlWidth)
                        {
                            columnWidth = controlWidth - columnStartX - 3;
                            g.DrawRectangle(pen, columnStartX + 1, columnStartY + 1, columnWidth, rowHeight);
                            Rectangle rec = new Rectangle(columnStartX + 2, columnStartY + 2, columnWidth - 2, rowHeight);
                            DrawStringAlignment(content, rec, g, col.Alignment);
                        }
                        else
                        {
                            columnWidth = grid.GridHeaderList[j].Width;
                            g.DrawRectangle(pen, columnStartX + 1, columnStartY + 1, columnWidth, rowHeight);
                            Rectangle rec = new Rectangle(columnStartX + 2, columnStartY + 2, columnWidth - 2, rowHeight);
                            DrawStringAlignment(content, rec, g, col.Alignment);
                        }
                        columnStartX += columnWidth;
                    }

                    columnStartY += rowHeight;
                }
                else  //고정 컬럼이 있을 경우
                {
                    int fixCol = GetLastFixedCol();
                    Col col    = new Col(this.grid.HeaderGen.GetHeaders(), rows[i].DataRow);
                    for (int index = 0; index <= fixCol; index++)
                    {
                        if (index == 0)
                        {
                            g.FillRectangle(brush, 1, columnStartY + 1, leftHeaderWidth, rowHeight);
                            g.DrawRectangle(pen, 1, columnStartY + 1, leftHeaderWidth, rowHeight);
                            columnStartX += leftHeaderWidth;  //첫 시작컬럼의 폭을 leftHeaderWidth 만큼 설정
                        }

                        if (!col.ColHeaders[index].Visible)
                        {
                            continue;
                        }

                        string content = col.GetColText(index);

                        //보여지는 컬럼의 폭이 컨트롤의 폭 보다 클경우
                        if (columnStartX + grid.GridHeaderList[index].Width > controlWidth)
                        {
                            columnWidth = controlWidth - columnStartX - 3;
                            //고정컬럼 Backgroud 색상을 colFixBrush로 채운다
                            g.FillRectangle(colFixBrush, columnStartX + 1, columnStartY + 1, columnWidth, rowHeight);
                            g.DrawRectangle(pen, columnStartX + 1, columnStartY + 1, columnWidth, rowHeight);
                            Rectangle rec = new Rectangle(columnStartX + 2, columnStartY + 2, columnWidth - 2, rowHeight);
                            DrawStringAlignment(content, rec, g, col.Alignment);
                        }
                        else
                        {
                            columnWidth = grid.GridHeaderList[index].Width;
                            //고정컬럼 Backgroud 색상을 colFixBrush로 채운다
                            g.FillRectangle(colFixBrush, columnStartX + 1, columnStartY + 1, columnWidth, rowHeight);
                            g.DrawRectangle(pen, columnStartX + 1, columnStartY + 1, columnWidth, rowHeight);
                            Rectangle rec = new Rectangle(columnStartX + 2, columnStartY + 2, columnWidth - 2, rowHeight);
                            DrawStringAlignment(content, rec, g, col.Alignment);
                        }
                        YearMonthWeekNoDayHeader yearMonthHeader = grid.GridHeaderList[index] as YearMonthWeekNoDayHeader;
                        columnStartX += columnWidth;
                    }

                    int lastFixCol = fixCol + 1;
                    for (int j = firstVisibleCol + lastFixCol; j <= lastVisibleCol && j < grid.GridHeaderList.Count; j++)
                    {
                        col = new Col(this.grid.HeaderGen.GetHeaders(), rows[i].DataRow);
                        string content = col.GetColText(j);
                        if (j == firstVisibleCol)
                        {
                            g.FillRectangle(brush, 1, columnStartY + 1, leftHeaderWidth, rowHeight);
                            g.DrawRectangle(pen, 1, columnStartY + 1, leftHeaderWidth, rowHeight);
                            columnStartX += leftHeaderWidth;  //첫 시작컬럼의 폭을 leftHeaderWidth 만큼 설정
                        }

                        if (!grid.GridHeaderList[j].Visible)
                        {
                            continue;
                        }

                        //보여지는 컬럼의 폭이 컨트롤의 폭 보다 클경우
                        if (columnStartX + grid.GridHeaderList[j].Width > controlWidth)
                        {
                            columnWidth = controlWidth - columnStartX - 3;
                            g.DrawRectangle(pen, columnStartX + 1, columnStartY + 1, columnWidth, rowHeight);
                            Rectangle rec = new Rectangle(columnStartX + 2, columnStartY + 2, columnWidth - 2, rowHeight);
                            DrawStringAlignment(content, rec, g, col.Alignment);
                        }
                        else
                        {
                            columnWidth = grid.GridHeaderList[j].Width;
                            g.DrawRectangle(pen, columnStartX + 1, columnStartY + 1, columnWidth, rowHeight);
                            Rectangle rec = new Rectangle(columnStartX + 2, columnStartY + 2, columnWidth - 2, rowHeight);
                            DrawStringAlignment(content, rec, g, col.Alignment);
                        }
                        columnStartX += columnWidth;
                    }

                    columnStartY += rowHeight;
                }
            }
        }