ComponentFactory.Krypton.Toolkit.ViewDrawWeekNumbers.Layout C# (CSharp) Method

Layout() public method

Perform a layout of the elements.
public Layout ( ViewLayoutContext context ) : void
context ViewLayoutContext Layout context.
return void
        public override void Layout(ViewLayoutContext context)
        {
            Debug.Assert(context != null);

            // We take on all the available display area
            ClientRectangle = context.DisplayRectangle;

            // Do not draw week numbers in bold or focused
            _calendar.SetFocusOverride(false);
            _calendar.SetBoldedOverride(false);

            // Layout each week number
            Rectangle layoutRectWeek = new Rectangle(ClientLocation.X, ClientLocation.Y, _months.SizeDay.Width, _months.SizeDays.Height);
            DateTime weekDate = _weekDay;
            DateTime displayDate = _firstDay;
            for (int j = 0; j < WEEKS; j++)
            {
                // Should we draw a week number for a week starting on this date
                DateTime weekNumberDate = weekDate;
                if (DisplayWeekNumber(displayDate, ref weekNumberDate))
                {
                    // Define text to be drawn
                    _drawText = GetWeekNumber(weekNumberDate).ToString();

                    if (_dayMementos[j] != null)
                    {
                        _dayMementos[j].Dispose();
                        _dayMementos[j] = null;
                    }

                    PaletteState paletteState = (Enabled ? PaletteState.Normal : PaletteState.Disabled);
                    IPaletteTriple paletteTriple = (Enabled ? _calendar.StateNormal.Day : _calendar.StateDisabled.Day);

                    _dayMementos[j] = context.Renderer.RenderStandardContent.LayoutContent(context, layoutRectWeek, paletteTriple.PaletteContent,
                                                                                           this, VisualOrientation.Top, paletteState, false, false);
                }

                // Move to next week
                weekDate += TIMESPAN_1WEEK;
                displayDate += TIMESPAN_1WEEK;
                layoutRectWeek.Y += _months.SizeDays.Height;
            }

            // Put back the original display value now we have finished
            context.DisplayRectangle = ClientRectangle;
        }