Exemplo n.º 1
0
        /// <summary>
        /// Completely redraws the calendar
        /// </summary>
        public void RefreshCal(DateTime?date)
        {
            if (date == null)
            {
                date = viewDate;
            }

            DateTime newDate   = (DateTime)date;
            DateTime startDate = new DateTime(newDate.Year, newDate.Month, 1);

            viewDate = startDate;

            SetDaysNumbering(startDate);
            SetWeekdayNames(startDate);
            SetWeekNumbers(startDate);
            FormatHeaderText(startDate);

            SetTodayIndicator();
            AddEvents();
            HolidayHelper.UpdateHolidays(startDate, Header_Cal, headerToolTips);
        }
Exemplo n.º 2
0
        public CalendarForm()
        {
            InitializeComponent();

            //SaveLoad.CreateEmptyUserFile();       //for testing
            //SaveLoad.CreateEmptyEventsFile();

            try { SaveLoad.RenewUsersData(); }
            catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.ToString()); }

            try { SaveLoad.RenewEventsData(); }
            catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.ToString()); }

            Size screenSize = Screen.PrimaryScreen.Bounds.Size;

            this.Size = new Size((int)(screenSize.Width * 0.8f), (int)(screenSize.Height * 0.8f));

            ResizeEnd             += new EventHandler(CalendarForm_ResizeEnd);
            Resize                += new EventHandler(CalendarForm_Resize);
            CalGrid_Cal.CellEnter += new DataGridViewCellEventHandler(CalGrid_Cal_CellEnter);
            Header_Cal.CellEnter  += new DataGridViewCellEventHandler(Header_Cal_CellEnter);

            DateTime startDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);

            viewDate = startDate;

            InitHeader(startDate);

            SetTodayIndicator();
            AddUsers();
            AddEvents();
            HolidayHelper.UpdateHolidays(viewDate, Header_Cal, headerToolTips);

            ResizeDaysHeader();
            ResizeUsersList();
        }