コード例 #1
0
ファイル: Cache.cs プロジェクト: robolix11/CalendarProject
        public void AddAppointment(string year, string month, string day, Appointment a)
        {
            if (day == "-")
            {
                a.repeating = true;
                DaylyAppointments.Add(a);
                return;
            }

            int intDay = int.Parse(day);

            if (month == "-")
            {
                a.repeating = true;
                MonthlyAppointments.Add(new Tuple <Appointment, int>(a, intDay));
                return;
            }

            int intMonth = int.Parse(month);

            if (year == "-")
            {
                a.repeating = true;
                YearlyAppointments.Add(new Tuple <Appointment, int, int>(a, intDay, intMonth));
                return;
            }

            int intYear = int.Parse(year);

            MonthData md = GetMonthData(intYear, intMonth);

            md.AddAppointment(intDay, a);
        }
コード例 #2
0
ファイル: Cache.cs プロジェクト: robolix11/CalendarProject
 private void DeleteRepeatingAppointmentsFromMonthData(MonthData md)
 {
     foreach (CalendarDay cd in md.CalendarDays)
     {
         cd.Appointments.RemoveAll(a => a.repeating);
     }
 }
コード例 #3
0
        public void DrawMonthView(MonthData md, PaintEventArgs e)
        {
            g = e.Graphics;

            Font   font           = new Font("Arial", (f.ScreenHeight / 25), FontStyle.Bold);
            string MonthViewTitle = ((Months)(md.Month - 1)).ToString() + " " + md.Year;

            g.DrawString(MonthViewTitle, font, new SolidBrush(Color.White), (int)(f.ScreenWidth * 0.5 - MonthViewTitle.Length * font.Size / 3), 50);


            int startIndex = ((int)md.GetWeekdayOfFirstDay() - 1 + 7) % 7; //offset that monday is front
            int dayCount   = md.GetDayCount();


            int dayCountBeforeMonth = md.GetDayCountBeforeMonth();

            for (int index = startIndex - 1; index >= 0; index--)
            {
                f.dbf.DayButtons[index].Text      = "" + (dayCountBeforeMonth - (startIndex - index - 1));
                f.dbf.DayButtons[index].TextColor = Color.Gray;
                //f.dbf.DayButtons[index].IsScoolHoliday = false;
                f.dbf.DayButtons[index].IsNationalHoliday = false;
                f.dbf.DayButtons[index].IsMainMonth       = false;
                //DrawDayAtIndex(index, dayCountBeforeMonth - (startIndex - index-1), Color.FromArgb(150, 150, 150), Color.Black, Color.FromArgb(100,100,100));
            }

            for (int index = startIndex; index < startIndex + dayCount; index++)
            {
                f.dbf.DayButtons[index].Text        = "" + (index - startIndex + 1);
                f.dbf.DayButtons[index].TextColor   = Color.Cyan;
                f.dbf.DayButtons[index].IsMainMonth = true;

                CalendarDay        calendarDay  = md.CalendarDays[(index - startIndex + 1) - 1];
                List <Appointment> appointments = calendarDay.Appointments.FindAll(a => a.Type == AppointmentType.SchoolHoliday || a.Type == AppointmentType.SpecialDay);

                //f.dbf.DayButtons[index].IsScoolHoliday = appointments.FindAll(a => a.Type == AppointmentType.SchoolHoliday).Count <= 0 ? false : true;
                f.dbf.DayButtons[index].IsNationalHoliday = appointments.FindAll(a => a.Type == AppointmentType.SpecialDay).Count <= 0 ? false : true;
            }

            int dayAfterMonth = 1;

            for (int index = startIndex + dayCount; index < 42; index++)
            {
                f.dbf.DayButtons[index].Text      = "" + (dayAfterMonth);
                f.dbf.DayButtons[index].TextColor = Color.Gray;
                //f.dbf.DayButtons[index].IsScoolHoliday = false;
                f.dbf.DayButtons[index].IsNationalHoliday = false;
                f.dbf.DayButtons[index].IsMainMonth       = false;
                dayAfterMonth++;
            }

            g.Dispose();
        }
コード例 #4
0
ファイル: Cache.cs プロジェクト: robolix11/CalendarProject
        private void AddRepeatingAppointmentsToMonthData(MonthData md, int month)
        {
            foreach (Appointment a in DaylyAppointments)
            {
                foreach (CalendarDay cd in md.CalendarDays)
                {
                    cd.AddAppointment(a);
                }
            }

            foreach (Tuple <Appointment, int> tuple in MonthlyAppointments)
            {
                for (int i = 0; i < md.CalendarDays.Count; i++)
                {
                    if (tuple.Item2 != i + 1)
                    {
                        continue;
                    }
                    md.CalendarDays[i].AddAppointment(tuple.Item1);
                }
            }

            foreach (Tuple <Appointment, int, int> tuple2 in YearlyAppointments)
            {
                if (tuple2.Item3 != month)
                {
                    continue;
                }
                for (int i = 0; i < md.CalendarDays.Count; i++)
                {
                    if (tuple2.Item2 != i + 1)
                    {
                        continue;
                    }
                    md.CalendarDays[i].AddAppointment(tuple2.Item1);
                }
            }
        }
コード例 #5
0
ファイル: Cache.cs プロジェクト: robolix11/CalendarProject
        public MonthData GetMonthData(int year, int month)
        {
            List <MonthData> yearOccurences = monthData.FindAll(md => md.Year == year);

            if (yearOccurences.Count == 0)
            {
                AddScoolHolidays(year);
                AddNationalHolidays(year);
            }

            MonthData next = yearOccurences.Find(md => md.Month == month);

            if (next == null)
            {
                next = new MonthData(year, month);
                monthData.Add(next);
            }
            else
            {
                DeleteRepeatingAppointmentsFromMonthData(next);
            }
            AddRepeatingAppointmentsToMonthData(next, month);
            return(next);
        }