/* 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 { /// /// Holds data about a box of text to be rendered on the month view /// public class MonthViewBoxEventArgs { #region Fields private Graphics _graphics; private Color _textColor; private Color _backgroundColor; private string _text; private Color _borderColor; private Rectangle _bounds; private Font _font; private TextFormatFlags _TextFlags; #endregion #region Properties /// /// Gets or sets the bounds of the box /// public Rectangle Bounds { get { return _bounds; } } /// /// Gets or sets the font of the text. If null, default will be used. /// public Font Font { get { return _font; } set { _font = value; } } /// /// Gets or sets the Graphics object where to draw /// public Graphics Graphics { get { return _graphics; } } /// /// Gets or sets the border color of the box /// public Color BorderColor { get { return _borderColor; } set { _borderColor = value; } } /// /// Gets or sets the text of the box /// public string Text { get { return _text; } set { _text = value; } } /// /// Gets or sets the background color of the box /// public Color BackgroundColor { get { return _backgroundColor; } set { _backgroundColor = value; } } /// /// Gets or sets the text color of the box /// public Color TextColor { get { return _textColor; } set { _textColor = value; } } /// /// Gets or sets the flags of the text /// public TextFormatFlags TextFlags { get { return _TextFlags; } set { _TextFlags = value; } } #endregion /// /// Initializes a new instance of the class. /// /// The graphics. /// The bounds. /// The text. /// The text align. /// Color of the text. /// Color of the back. /// Color of the border. internal MonthViewBoxEventArgs( Graphics graphics, Rectangle bounds, string text, StringAlignment textAlign, Color textColor, Color backColor, Color borderColor ) { _graphics = graphics; _graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; _graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; _graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; _graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; _bounds = bounds; Text = text; TextColor = textColor; BackgroundColor = backColor; BorderColor = borderColor; switch( textAlign ) { case StringAlignment.Center: TextFlags |= TextFormatFlags.HorizontalCenter; break; case StringAlignment.Far: TextFlags |= TextFormatFlags.Right; break; case StringAlignment.Near: TextFlags |= TextFormatFlags.Left; break; default: break; } TextFlags |= TextFormatFlags.VerticalCenter; } /// /// Initializes a new instance of the class. /// /// The graphics. /// The bounds. /// The text. /// Color of the text. internal MonthViewBoxEventArgs( Graphics graphics, Rectangle bounds, string text, Color textColor ) : this( graphics, bounds, text, StringAlignment.Center, textColor, Color.Empty, Color.Empty ) { } /// /// Initializes a new instance of the class. /// /// The graphics. /// The bounds. /// The text. /// Color of the text. /// Color of the back. internal MonthViewBoxEventArgs( Graphics graphics, Rectangle bounds, string text, Color textColor, Color backColor ) : this( graphics, bounds, text, StringAlignment.Center, textColor, backColor, Color.Empty ) { } /// /// Initializes a new instance of the class. /// /// The graphics. /// The bounds. /// The text. /// The text align. /// Color of the text. /// Color of the back. internal MonthViewBoxEventArgs( Graphics graphics, Rectangle bounds, string text, StringAlignment textAlign, Color textColor, Color backColor ) : this( graphics, bounds, text, textAlign, textColor, backColor, Color.Empty ) { } /// /// Initializes a new instance of the class. /// /// The graphics. /// The bounds. /// The text. /// The text align. /// Color of the text. internal MonthViewBoxEventArgs( Graphics graphics, Rectangle bounds, string text, StringAlignment textAlign, Color textColor ) : this( graphics, bounds, text, textAlign, textColor, Color.Empty, Color.Empty ) { } } }