/* 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; using System.Drawing; namespace WindowsFormsCalendar { /// /// Implements a basic /// public abstract class CalendarSelectableElement : ICalendarSelectableElement { #region Fields private Calendar _calendar; private Rectangle _bounds; private DateTime _date; private bool _selected; #endregion /// /// Initializes a new instance of the class. /// /// The calendar. public CalendarSelectableElement(Calendar calendar) { if (calendar == null) throw new ArgumentNullException("calendar"); _calendar = calendar; } #region ICalendarSelectableElement Members /// /// Gets the calendar /// public virtual DateTime Date { get { return _date; } } /// /// Gets the Calendar this element belongs to /// public virtual Calendar Calendar { get { return _calendar; } } /// /// Gets the Bounds of the element on the window /// public virtual Rectangle Bounds { get { return _bounds; } } /// /// Gets a value indicating if the element is currently selected /// public virtual bool Selected { get { return _selected; } } /// /// Compares this element with other using date as comparer /// /// /// public virtual int CompareTo(ICalendarSelectableElement element) { return this.Date.CompareTo(element.Date); } #endregion #region Internal Methods /// /// Sets the value of the property /// /// Bounds of the element internal virtual void SetBounds(Rectangle bounds) { _bounds = bounds; } /// /// Sets the value of the property /// /// Value indicating if the element is currently selected internal virtual void SetSelected(bool selected) { _selected = selected; //Calendar.Invalidate(Bounds); } #endregion } }