Esempio n. 1
0
        /// <summary>
        /// Renders a calendar content range to the canvas.
        /// </summary>
        /// <param name="content">the content to render</param>
        /// <param name="canvas">the drawing canvas to use</param>
        /// <param name="rect">the calendar rectangle</param>
        public void Render(CalendarContentRange content, IDrawingCanvas canvas, RectangleF rect)
        {
            if (content == null)
            {
                throw new ArgumentNullException("content");
            }
            if (canvas == null)
            {
                throw new ArgumentNullException("canvas");
            }

            _calendarData     = new CalendarData((ICalendar)content.Owner);
            this._rightToLeft = ((ICalendar)content.Owner).Direction == Direction.RTL;
            try
            {
                // store the canvas to use in rendering
                _canvas = canvas;

                // TODO: consider to add gaps
                // allocate the area for calendar drawing
                _calendarArea = rect;
                // allocate the area for only one month
                _monthArea = new SizeF(content.Owner.Width.ToTwips(), content.Owner.Height.ToTwips());

                DrawMonths(CalendarData.GetMonthsRange(content.MonthFrom, content.MonthTo));
            }
            finally
            {
                if (_calendarData != null)
                {
                    _calendarData.Dispose();
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Renders a calendar content range to the canvas. It is used from the calendar designer.
        /// </summary>
        public void Render(ICalendar calendar, MonthInfo month, IDrawingCanvas canvas, RectangleF rect)
        {
            if (calendar == null)
            {
                throw new ArgumentNullException("calendar");
            }
            if (month == null)
            {
                throw new ArgumentNullException("month");
            }
            if (canvas == null)
            {
                throw new ArgumentNullException("canvas");
            }

            _calendarData     = new CalendarData(calendar);
            this._rightToLeft = calendar.Direction == Direction.RTL;
            try
            {
                // store the canvas to use in rendering
                _canvas = canvas;

                // TODO: consider to add gaps
                // allocate the area for calendar drawing
                _calendarArea = rect;
                // allocate the area for only one month
                _monthArea = new SizeF(rect.Width, rect.Height);

                DrawMonths(CalendarData.GetMonthsRange(month, month));
            }
            finally
            {
                if (_calendarData != null)
                {
                    _calendarData.Dispose();
                }
            }
        }