/*
Copyright 2012 Justin LeCheminant
This file is part of WindowsFormsCalendar.
indowsFormsCalendar is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
indowsFormsCalendar is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with indowsFormsCalendar. If not, see .
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace WindowsFormsCalendar
{
///
/// Represents a range of time that is highlighted as work-time
///
public class CalendarHighlightRange
{
#region Events
#endregion
#region Fields
private Calendar _calendar;
private DayOfWeek _dayOfWeek;
private TimeSpan _startTime;
private TimeSpan _endTime;
#endregion
#region Properties
///
/// Gets the calendar that this range is assigned to. (If any)
///
public Calendar Calendar
{
get { return _calendar; }
}
///
/// Gets or sets the day of the week for this range
///
public DayOfWeek DayOfWeek
{
get { return _dayOfWeek; }
set { _dayOfWeek = value; Update(); }
}
///
/// Gets or sets the start time of the range
///
public TimeSpan StartTime
{
get { return _startTime; }
set { _startTime = value; Update(); }
}
///
/// Gets or sets the end time of the range
///
public TimeSpan EndTime
{
get { return _endTime; }
set { _endTime = value; Update(); }
}
#endregion
///
/// Initializes a new instance of the class.
///
public CalendarHighlightRange()
{
}
///
/// Initializes a new instance of the class.
///
/// The day.
/// The start time.
/// The end time.
public CalendarHighlightRange( DayOfWeek day, TimeSpan startTime, TimeSpan endTime )
: this()
{
_dayOfWeek = day;
_startTime = startTime;
_endTime = endTime;
}
#region Public Methods
#endregion
#region Private Methods
///
/// Tells the calendar to update the highligts
///
private void Update()
{
if (Calendar != null)
{
Calendar.UpdateHighlights();
}
}
///
/// Sets the value of the property
///
/// Calendar that this range belongs to
internal void SetCalendar(Calendar calendar)
{
_calendar = calendar;
}
#endregion
}
}