Beispiel #1
0
        void DrawLeftMargin(Graphics graphics)
        {
            var XCoord = 0;

            //Draws header fill rect
            var rect = new Rectangle(0, Height / 2, _leftMargin, Height / 2);

            if (HeaderStyleMode == HeaderStyle.Aqua)
            {
                using (LinearGradientBrush gradientBrush = WeekPlannerColorTable.HeaderGradientBackBrush(rect, _headerFillLeftMarginColor))
                {
                    graphics.FillRectangle(gradientBrush, rect);
                }
            }
            else
            {
                using (var gradientBrush = new SolidBrush(_headerFillLeftMarginColor))
                {
                    graphics.FillRectangle(gradientBrush, rect);
                }
            }



            for (int i = 0; i < _columns.Count; i++)
            {
                int rectWidth = _columns[i].Width;
                if (i == Columns.Count - 1)
                {
                    rectWidth = LeftMargin - XCoord;
                }
                Rectangle Rect = new Rectangle(XCoord, Height / 2, rectWidth, Height / 2);

                //Draws item text
                StringFormat sf = new StringFormat();
                sf.Alignment     = StringAlignment.Center;
                sf.LineAlignment = StringAlignment.Center;
                using (Brush brush = new SolidBrush(Color.Black))
                {
                    graphics.DrawString(Columns[i].Text, _headerColumnsFont, brush, Rect, sf);
                }

                //Draws vertical lines
                XCoord += Columns[i].Width;
                Point p1 = new Point(XCoord, Height / 2);
                Point p2 = new Point(XCoord, Height - 2);
                using (Pen pen = new Pen(BorderColor))
                {
                    if (i < Columns.Count - 1)
                    {
                        graphics.DrawLine(pen, p1, p2);
                    }
                }
            }
        }
Beispiel #2
0
        private void DrawHeader(Graphics graphics)
        {
            int step = (Width - _leftMargin) / _dayCount;

            int oldXCoord = _leftMargin;
            int XCoord    = _leftMargin;

            DateTime dt = CurrentDate;

            int week    = GetWeekNumber(_currentDate);
            int weekNew = GetWeekNumber(_currentDate);


            int modeFirstCoord  = _leftMargin;
            int modeSecondCoord = _leftMargin;

            //Draws header fill rect
            var Rect = new Rectangle(_leftMargin, Height / 2, Width - _leftMargin, Height / 2);

            if (HeaderStyleMode == HeaderStyle.Aqua)
            {
                using (LinearGradientBrush gradientBrush = WeekPlannerColorTable.HeaderGradientBackBrush(Rect, _headerFillColor))
                {
                    graphics.FillRectangle(gradientBrush, Rect);
                }
            }
            else
            {
                using (var gradientBrush = new SolidBrush(_headerFillColor))
                {
                    graphics.FillRectangle(gradientBrush, Rect);
                }
            }



            //Draws header border rect
            using (Pen pen = new Pen(BorderColor))
            {
                graphics.DrawLine(pen, new Point(0, Height / 2), new Point(Width, Height / 2));
                graphics.DrawLine(pen, new Point(0, Height - 1), new Point(Width, Height - 1));
            }

            for (int i = 0; i < _dayCount; i++)
            {
                //Draws Week Days and Dates
                using (Brush brush = new SolidBrush(Color.Black))
                {
                    string _date;
                    var    sf   = new StringFormat();
                    var    rect = new Rectangle();

                    sf.Alignment     = StringAlignment.Center;
                    sf.LineAlignment = StringAlignment.Center;
                    //Draws vertical lines
                    Point p1 = new Point(XCoord, Height / 2);
                    Point p2 = new Point(XCoord, Height - 2);
                    using (Pen pen = new Pen(BorderColor))
                    {
                        if (i == 0)
                        {
                            p1 = new Point(XCoord, 0);
                        }
                        graphics.DrawLine(pen, p1, p2);
                    }

                    if (i == 0)
                    {
                        _date = dt.AddDays(i).Day + " " + dt.AddDays(i).ToString("MMM");
                    }
                    else
                    {
                        _date = dt.AddDays(i).Day.ToString();
                    }

                    if (DatesIntervalMode == WeekPlannerMode.Daily)
                    {
                        //Draws day of week
                        graphics.DrawString(dt.AddDays(i).DayOfWeek.ToString().Substring(0, 3), _headerDatesFont, brush, XCoord, 2);

                        //Draws daily mode vertical lines
                        p1 = new Point(XCoord, 1);
                        p2 = new Point(XCoord, Height - 2);
                        using (Pen pen = new Pen(BorderColor))
                        {
                            graphics.DrawLine(pen, p1, p2);
                        }
                    }

                    //Draws week numbes
                    if (DatesIntervalMode == WeekPlannerMode.Weekly)
                    {
                        weekNew = GetWeekNumber(dt.AddDays(i));

                        if (week != weekNew)
                        {
                            modeSecondCoord = XCoord;
                            rect            = new Rectangle(modeFirstCoord, 0, modeSecondCoord - modeFirstCoord, Height / 2);

                            //Draws weekly mode vertical lines
                            graphics.DrawString("Week:" + week, _headerDatesFont, brush, rect, sf);
                            using (Pen pen = new Pen(BorderColor))
                            {
                                graphics.DrawLine(pen, modeSecondCoord, 0, modeSecondCoord, Height / 2);
                            }
                            week           = weekNew;
                            modeFirstCoord = XCoord;
                        }

                        if (i == _dayCount - 1)
                        {
                            modeSecondCoord = Width;
                            rect            = new Rectangle(modeFirstCoord, 0, modeSecondCoord - modeFirstCoord, Height / 2);

                            graphics.DrawString("Week:" + week, _headerDatesFont, brush, rect, sf);
                        }
                    }


                    oldXCoord = XCoord;
                    XCoord   += step;

                    //Draws dates
                    rect = new Rectangle(oldXCoord, Height / 2, XCoord - oldXCoord, Height / 2);
                    graphics.DrawString(_date, _headerDatesFont, brush, rect, sf);
                }
            }
        }