コード例 #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
ファイル: Calendar.cs プロジェクト: krkkng/Taikihyou
 /// <summary>
 /// 月の予定を抽出します。
 /// </summary>
 /// <param name="DrawYear"></param>
 /// <param name="DrawMonth"></param>
 private void ExtractMonthSchedules(int DrawYear, int DrawMonth)
 {
     if (schedulelabels != null)
     {
         schedulelabels.ToList().ForEach(t => t.ForEach(l => deleteEvents(l)));
     }
     if (buttons != null)
     {
         buttons.ToList().ForEach(t => t.Click -= Button_Click);
     }
     schedulelabels = new List <ScheduleLabel> [DateTime.DaysInMonth(DrawYear, DrawMonth)];
     buttons        = new Button[DateTime.DaysInMonth(DrawYear, DrawMonth)];
     for (int i = 0; i < schedulelabels.Count(); i++)
     {
         schedulelabels[i] = new List <ScheduleLabel>();
         buttons[i]        = new Button(this);
         buttons[i].Click += Button_Click;
     }
     schedules.ForEach(t =>
     {
         if (t.Start.Year == DrawYear &&
             t.Start.Month == DrawMonth)
         {
             ScheduleLabel sl = new ScheduleLabel(this, t);
             setEvents(sl);
             schedulelabels[t.Start.Day - 1].Add(sl);
         }
     });
 }
コード例 #3
0
ファイル: Calendar.cs プロジェクト: krkkng/Taikihyou
 private void deleteEvents(ScheduleLabel sl)
 {
     sl.MouseUp          -= sl_MouseUp;
     sl.MouseDoubleClick -= sl_MouseDoubleClick;
     sl.SelectionChanged -= sl_SelectionChanged;
     sl.Leave            -= sl_Leave;
     sl.KeyDown          -= sl_KeyDown;
 }
コード例 #4
0
ファイル: Calendar.cs プロジェクト: krkkng/Taikihyou
 private void setEvents(ScheduleLabel sl)
 {
     sl.MouseUp          += sl_MouseUp;
     sl.MouseDoubleClick += sl_MouseDoubleClick;
     sl.SelectionChanged += sl_SelectionChanged;
     sl.Leave            += sl_Leave;
     sl.KeyDown          += sl_KeyDown;
     this.EnabledChanged += Calendar_EnabledChanged;
 }
コード例 #5
0
ファイル: Calendar.cs プロジェクト: krkkng/Taikihyou
 public void AddSchedule(Schedule sd)
 {
     schedules.Add(sd);
     if (schedulelabels != null && DrawYear == sd.Start.Year && DrawMonth == sd.Start.Month)
     {
         ScheduleLabel sl = new ScheduleLabel(this, sd);
         setEvents(sl);
         schedulelabels[sd.Start.Day - 1].Add(sl);
         //sl.ClientRectangle = GetDateRect(sd.Start);
         Invalidate(Rectangle.Round(GetDateRect(sd.Start, this.ClientRectangle)));
     }
 }
コード例 #6
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            ScheduleLabel other = obj as ScheduleLabel;

            if (other == null)
            {
                return(false);
            }
            return(this.Schedule == other.Schedule && this.ClientRectangle == other.ClientRectangle);
        }
コード例 #7
0
ファイル: Calendar.cs プロジェクト: krkkng/Taikihyou
        void sl_SelectionChanged(object sender, EventArgs e)
        {
            ScheduleLabel target = sender as ScheduleLabel;

            if (!target.IsSelected)
            {
                return;
            }
            schedulelabels.ToList().ForEach(sl =>
            {
                sl.ForEach(sl2 =>
                {
                    if (sl2 != target && sl2.IsSelected)
                    {
                        sl2.SetSelected(false);
                    }
                });
            });
        }
コード例 #8
0
ファイル: Calendar.cs プロジェクト: krkkng/Taikihyou
        private void printDate(Graphics g, Rectangle rc)
        {
            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 stack = (int)(header + (row * column_height) + yspace + font.Height);
                    buttons[i].ClientRectangle = Rectangle.Empty;
                    ////------
                    float schedulelabel_height = (column_height - font.Height - yspace - 4) / 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の四角形
                        Yp     = ((schedulelabel_height) * j) + header + (row * column_height) + yspace + font.Height + rc.Y;
                        screct = new RectangleF(Xp, Yp, column_width - 4, schedulelabel_height);
                        scj.ClientRectangle = screct;
                        scj.Print(g);
                    }
                }
                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);
                }
            }
        }
コード例 #9
0
ファイル: Calendar.cs プロジェクト: krkkng/Taikihyou
 public ScheduleLabelKeyEventArgs(ScheduleLabel label, Keys keydata) : base(keydata)
 {
     Label = label;
 }
コード例 #10
0
ファイル: Calendar.cs プロジェクト: krkkng/Taikihyou
 public ScheduleLabelMouseEventArgs(ScheduleLabel label, MouseButtons buttons, int clicks, int x, int y, int delta)
     : base(buttons, clicks, x, y, delta)
 {
     Label = label;
 }