/* 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; using System.Windows.Forms; namespace WindowsFormsCalendar { /// /// Contains information about something's bounds and text to draw on the calendar /// public class CalendarRendererBoxEventArgs : CalendarRendererEventArgs { #region Fields private Color _backgroundColor; private Rectangle _bounds; private Font _font; private TextFormatFlags _format; private string _text; private Color _textColor; private Size _textSize; #endregion /// /// Initializes some fields /// private CalendarRendererBoxEventArgs() { this.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; this.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; this.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; this.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; } /// /// Initializes a new instance of the class. /// /// The instance containing the event data. public CalendarRendererBoxEventArgs(CalendarRendererEventArgs original) : base(original) { Font = original.Calendar.Font; Format |= TextFormatFlags.Default | TextFormatFlags.WordBreak | TextFormatFlags.PreserveGraphicsClipping;// | TextFormatFlags.WordEllipsis; TextColor = SystemColors.ControlText; } /// /// Initializes a new instance of the class. /// /// The instance containing the event data. /// The bounds. public CalendarRendererBoxEventArgs(CalendarRendererEventArgs original, Rectangle bounds) : this(original) { Bounds = bounds; } /// /// Initializes a new instance of the class. /// /// The instance containing the event data. /// The bounds. /// The text. public CalendarRendererBoxEventArgs(CalendarRendererEventArgs original, Rectangle bounds, string text) : this(original) { Bounds = bounds; Text = text; } /// /// Initializes a new instance of the class. /// /// The instance containing the event data. /// The bounds. /// The text. /// The flags. public CalendarRendererBoxEventArgs(CalendarRendererEventArgs original, Rectangle bounds, string text, TextFormatFlags flags) : this(original) { Bounds = bounds; Text = text; Format |= flags; } /// /// Initializes a new instance of the class. /// /// The instance containing the event data. /// The bounds. /// The text. /// Color of the text. public CalendarRendererBoxEventArgs(CalendarRendererEventArgs original, Rectangle bounds, string text, Color textColor) : this(original) { Bounds = bounds; Text = text; TextColor = textColor; } /// /// Initializes a new instance of the class. /// /// The instance containing the event data. /// The bounds. /// The text. /// Color of the text. /// The flags. public CalendarRendererBoxEventArgs(CalendarRendererEventArgs original, Rectangle bounds, string text, Color textColor, TextFormatFlags flags) : this(original) { Bounds = bounds; Text = text; TextColor = TextColor; Format |= flags; } /// /// Initializes a new instance of the class. /// /// The instance containing the event data. /// The bounds. /// The text. /// Color of the text. /// Color of the background. public CalendarRendererBoxEventArgs(CalendarRendererEventArgs original, Rectangle bounds, string text, Color textColor, Color backgroundColor) : this(original) { Bounds = bounds; Text = text; TextColor = TextColor; BackgroundColor = backgroundColor; } #region Props /// /// Gets or sets the background color of the text /// public Color BackgroundColor { get { return _backgroundColor; } set { _backgroundColor = value; } } /// /// Gets or sets the bounds to draw the text /// public Rectangle Bounds { get { return _bounds; } set { _bounds = value; } } /// /// Gets or sets the font of the text to be rendered /// public Font Font { get { return _font; } set { _font = value; _textSize = Size.Empty; } } /// /// Gets or sets the format to draw the text /// public TextFormatFlags Format { get { return _format; } set { _format = value; _textSize = Size.Empty; } } /// /// Gets or sets the text to draw /// public string Text { get { return _text; } set { _text = value; _textSize = Size.Empty; } } /// /// Gets the result of measuring the text /// public Size TextSize { get { if (_textSize.IsEmpty) { _textSize = TextRenderer.MeasureText(Text, Font); } return _textSize; } } /// /// Gets or sets the color to draw the text /// public Color TextColor { get { return _textColor; } set { _textColor = value; } } #endregion #region Methods #endregion } }