コード例 #1
0
        /// <summary>
        /// Calculates the start indexes for both row and column position on the calendar
        /// based on this event's start time.
        /// </summary>
        /// <param name="columnIndex">
        /// Passed-by-reference column index. Initialised in the method.
        /// </param>
        /// <param name="startRowIndex">
        /// Passed-by-reference row index. Initialised in the method.
        /// </param>
        public void CalculateStartPosition(out int columnIndex, out int startRowIndex)
        {
            columnIndex = CalendarController.DayIndexForMondayWeekStart(_startTime.DayOfWeek);

            //Table row index matches the hour (in 24 hr time) integer
            startRowIndex = _startTime.Hour;
        }
コード例 #2
0
 /// <summary>
 /// Highlights the label for the current day of the week, if in the current week
 /// </summary>
 private void HighlightCurrentDay()
 {
     if (CalendarController.IsAtThisWeek())
     {
         int labelIndex = CalendarController.CurrentDayIndex();
         dateNumbersPanel.Controls[labelIndex].BackColor = System.Drawing.Color.Plum;
     }
 }
コード例 #3
0
 /// <summary>
 /// Refreshes the calendar TableLayoutPanel with new date, month, and year labels
 /// and events are drawn for the current calendar week.
 /// </summary>
 public override void Refresh()
 {
     ClearHighlight();
     UpdateDateLabels();
     UpdateMonthYearLabel();
     HighlightCurrentDay();
     calendarTable.Visible = false;
     CalendarController.DrawWeeksEvents(calendarTable);
     calendarTable.Visible = true;
 }
コード例 #4
0
        /// <summary>
        /// Updates all date labels of the calendar for the current calendar week
        /// </summary>
        private void UpdateDateLabels()
        {
            DayOfWeek dayOfWeek = DayOfWeek.Monday;

            foreach (Label label in dateNumbersPanel.Controls)
            {
                label.Text = CalendarController.DayDateString(dayOfWeek).ToString();
                dayOfWeek++;
            }
        }
コード例 #5
0
        /// <summary>
        /// When table is clicked new event can be added.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CalendarTable_MouseClick(object sender, MouseEventArgs e)
        {
            if ((calendarTable.ColumnCount < 1) || (calendarTable.RowCount < 1))
            {
                throw new Exception("Error: Should not be able to click if no cells in table.");
            }

            int colIndex = calendarTable.CellClickedColumnIndex(e.X);
            int rowIndex = calendarTable.CellClickedRowIndex(e.Y);

            //If there is not already an event in the current cell
            if (calendarTable.GetControlFromPosition(colIndex, rowIndex) == null)
            {
                CalendarController.NewEventRequest(colIndex, rowIndex);
                Refresh();
            }
            else
            {
                //Event editing is done only when the label itself is clicked, not the empty
                //space around the label.
                MessageBox.Show("Spot taken");
            }
        }
コード例 #6
0
 /// <summary>
 /// AddController adds its event to the CalendarController's event list
 /// </summary>
 public override void Action()
 {
     CalendarController.AddEvent(_event);
 }
コード例 #7
0
        /// <summary>
        /// Clears the highlight by changing the label color back to the default
        /// </summary>
        private void ClearHighlight()
        {
            int labelIndex = CalendarController.CurrentDayIndex();

            dateNumbersPanel.Controls[labelIndex].BackColor = Color.WhiteSmoke;
        }
コード例 #8
0
 private void PreviousWeekButton_Click(object sender, EventArgs e)
 {
     CalendarController.PreviousWeek();
     Refresh();
 }
コード例 #9
0
 /// <summary>
 /// EventHandler for mouse click on the label of this CalendarEvent
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Label_Click(object sender, EventArgs e)
 {
     CalendarController.EditEventRequest(this);
 }