예제 #1
0
        private void DrawSchedule(Graphics g)
        {
            if (ScheduleLabels == null)
            {
                return;
            }
            int space = ScheduleLabelSpace;
            int stack = DayHeaderHeight;

            for (int i = 0; i < ScheduleLabels.Count(); i++)
            {
                ScheduleLabel scj = ScheduleLabels[i];
                if (scj == null)
                {
                    return;
                }
                int       Xp = ClientRectangle.X + PanelHeaderXSpace;
                int       Yp;
                Rectangle screct;
                Yp     = ClientRectangle.Y + ((LabelHeight + space) * i) + DayHeaderHeight + 1;
                screct = new Rectangle(Xp, Yp, ClientRectangle.Width - (PanelHeaderXSpace * 2) - 1, LabelHeight);
                stack += (int)screct.Height + space;
                scj.ClientRectangle = screct;
                scj.Paint(g, false);
            }
            this.Height = stack + space;
        }
예제 #2
0
        /// <summary>
        /// 日付の描画を行います
        /// </summary>
        /// <param name="g"></param>
        private void drawDate(Graphics g, Rectangle rc, bool isprint = false)
        {
            int xspace = 2;             // カレンダーの日付や予定の左側の遊び
            int yspace = 3;             // カレンダーの日付の上側の遊び
            int offset = getOffset(DrawYear, DrawMonth);

            for (int i = -offset; i < WeekCount(DrawYear, DrawMonth, (int)StartWeekday) * x_column - offset; i++)
            {
                int          row  = (offset + i) / 7;
                int          col  = (offset + i) % 7;
                Font         font = this.Font;
                Brush        brush;
                StringFormat format = new StringFormat();
                format.LineAlignment = StringAlignment.Center;
                format.Trimming      = StringTrimming.EllipsisCharacter;
                if (i >= 0 && i < DateTime.DaysInMonth(DrawYear, DrawMonth))
                {
                    DateTime dt      = new DateTime(DrawYear, DrawMonth, i + 1);
                    var      holiday = GenCalendar.HolidayChecker.Holiday(dt);
                    if (holiday.holiday == GenCalendar.HolidayChecker.HolidayInfo.HOLIDAY.SYUKUJITSU ||
                        holiday.holiday == GenCalendar.HolidayChecker.HolidayInfo.HOLIDAY.C_HOLIDAY ||
                        holiday.holiday == GenCalendar.HolidayChecker.HolidayInfo.HOLIDAY.HOLIDAY ||
                        dt.DayOfWeek == DayOfWeek.Sunday)
                    {
                        brush = new SolidBrush(HolidayColor);
                    }
                    else if (dt.DayOfWeek == DayOfWeek.Saturday)
                    {
                        brush = new SolidBrush(SaturdayColor);
                    }
                    else
                    {
                        brush = new SolidBrush(WeekDayColor);
                    }
                    g.DrawString((i + 1).ToString() + " " + holiday.name, font, brush, new RectangleF(col * column_width + xspace + rc.X, header + (row * column_height) + yspace + rc.Y, column_width, font.Height), format);

                    // スケジュール描画
                    int space;
                    if (isprint)
                    {
                        space = 20;
                    }
                    else
                    {
                        space = 6;
                    }
                    int buttongap = 0;                          // ボタンの上下の遊び
                    int stack     = (int)(header + (row * column_height) + yspace + font.Height);
                    buttons[i].ClientRectangle = Rectangle.Empty;
                    ////------
                    float schedulelabel_height = (column_height - header + yspace) / 4;
                    ////------
                    for (int j = 0; j < schedulelabels[i].Count(); j++)
                    {
                        ScheduleLabel scj = schedulelabels[i][j];
                        float         Xp  = col * column_width + xspace + rc.X;                 // schedule labelのclientのX座標
                        float         Yp;                                                       // schedule labelのclientのY座標
                        RectangleF    screct;                                                   // schedule labelのclientの四角形
                        if (isprint)
                        {
                            Yp     = ((schedulelabel_height) * j) + header + (row * column_height) + yspace + font.Height + rc.Y;
                            screct = new RectangleF(Xp, Yp, column_width - 4, schedulelabel_height);
                        }
                        else
                        {
                            Yp     = ((font.Height + space) * j) + header + (row * column_height) + yspace + font.Height + rc.Y;
                            screct = new RectangleF(Xp, Yp, column_width - 4, font.Height + space);
                        }
                        stack += (int)screct.Height;
                        if (stack > header + (row * column_height) + column_height - font.Height - buttongap && !isprint)
                        {
                            buttons[i].ClientRectangle = new Rectangle((int)screct.X + rc.X, (int)(header + (row * column_height) + column_height - font.Height - buttongap + rc.Y), (int)screct.Width, font.Height + buttongap);
                            buttons[i].Text            = "他" + (schedulelabels[i].Count - j).ToString() + "件";
                            buttons[i].Draw(g);
                            break;
                        }
                        scj.ClientRectangle = screct;
                        scj.Paint(g, isprint);
                    }
                }
                else if (i < 0)                 // 前の月の日付を描画
                {
                    DateTime prevm   = new DateTime(DrawYear, DrawMonth, 1).AddDays(i);
                    var      holiday = GenCalendar.HolidayChecker.Holiday(prevm);
                    g.DrawString((prevm.Month.ToString() + "/" + prevm.Day.ToString() + " " + holiday.name), font, Brushes.Gray, new RectangleF(col * column_width + 2 + rc.X, header + (row * column_height) + 3 + rc.Y, column_width, font.Height), format);
                }
                else                 // 次の月の日付を描画
                {
                    DateTime nextm   = new DateTime(DrawYear, DrawMonth, DateTime.DaysInMonth(DrawYear, DrawMonth)).AddDays(i - DateTime.DaysInMonth(DrawYear, DrawMonth) + 1);
                    var      holiday = GenCalendar.HolidayChecker.Holiday(nextm);
                    g.DrawString((nextm.Month.ToString() + "/" + nextm.Day.ToString() + " " + holiday.name), font, Brushes.Gray, new RectangleF(col * column_width + 2 + rc.X, header + (row * column_height) + 3 + rc.Y, column_width, font.Height), format);
                }
            }
        }