Extends the ViewComposite by creating/destroying month instances in a grid.
Inheritance: ViewComposite, IContentValues
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuMonthCalendar class.
        /// </summary>
        /// <param name="provider">Reference to provider.</param>
        /// <param name="monthCalendar">Reference to owning month calendar entry.</param>
        public ViewDrawMenuMonthCalendar(IContextMenuProvider provider,
                                         KryptonContextMenuMonthCalendar monthCalendar)
        {
            _provider = provider;
            _monthCalendar = monthCalendar;
            _firstDayOfWeek = _monthCalendar.FirstDayOfWeek;
            _minDate = _monthCalendar.MinDate;
            _maxDate = _monthCalendar.MaxDate;
            _todayDate = _monthCalendar.TodayDate;
            _maxSelectionCount = _monthCalendar.MaxSelectionCount;
            _scrollChange = _monthCalendar.ScrollChange;
            _todayText = _monthCalendar.TodayText;
            _todayFormat = _monthCalendar.TodayFormat;
            _dimensions = _monthCalendar.CalendarDimensions;

            // Decide on the enabled state of the display
            _itemEnabled = provider.ProviderEnabled && _monthCalendar.Enabled;

            // Give the item object the redirector to use when inheriting values
            _monthCalendar.SetPaletteRedirect(provider.ProviderRedirector);

            // Create view that is used by standalone control as well as this context menu element
            _layoutMonths = new ViewLayoutMonths(provider, monthCalendar, provider.ProviderViewManager, this, provider.ProviderRedirector, provider.ProviderNeedPaintDelegate);
            _layoutMonths.CloseOnTodayClick = _monthCalendar.CloseOnTodayClick;
            _layoutMonths.ShowWeekNumbers = _monthCalendar.ShowWeekNumbers;
            _layoutMonths.ShowTodayCircle = _monthCalendar.ShowTodayCircle;
            _layoutMonths.ShowToday = _monthCalendar.ShowToday;
            _layoutMonths.Enabled = _itemEnabled;

            Add(_layoutMonths);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initialize a new instance of the ViewDrawMonthDays class.
 /// </summary>
 /// <param name="calendar">Reference to calendar provider.</param>
 /// <param name="months">Reference to months instance.</param>
 public ViewDrawMonthDays(IKryptonMonthCalendar calendar, ViewLayoutMonths months)
 {
     _calendar = calendar;
     _months = months;
     _dayMementos = new IDisposable[DAYS];
     _dayRects = new Rectangle[DAYS];
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initialize a new instance of the ViewDrawWeekNumbers class.
 /// </summary>
 /// <param name="calendar">Reference to calendar provider.</param>
 /// <param name="months">Reference to months instance.</param>
 public ViewDrawWeekNumbers(IKryptonMonthCalendar calendar, ViewLayoutMonths months)
 {
     _drawText = string.Empty;
     _calendar = calendar;
     _months = months;
     _dayMementos = new IDisposable[WEEKS];
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initialize a new instance of the ViewLayoutWeekCorner class.
 /// </summary>
 /// <param name="calendar">Reference to calendar provider.</param>
 /// <param name="months">Reference to months instance.</param>
 /// <param name="palette">Reference to border palette.</param>
 public ViewLayoutWeekCorner(IKryptonMonthCalendar calendar, 
                             ViewLayoutMonths months,
                             PaletteBorder palette)
 {
     _calendar = calendar;
     _months = months;
     _palette = palette;
 }
        /// <summary>
        /// Initialize a new instance of the ViewDrawMonthDayNames class.
        /// </summary>
        /// <param name="calendar">Reference to calendar provider.</param>
        /// <param name="months">Reference to months instance.</param>
        public ViewDrawMonthDayNames(IKryptonMonthCalendar calendar, ViewLayoutMonths months)
        {
            _calendar = calendar;
            _months = months;

            // 7 day mementos
            _dayMementos = new IDisposable[7];
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawMonthDayNames class.
        /// </summary>
        /// <param name="calendar">Reference to calendar provider.</param>
        /// <param name="months">Reference to months instance.</param>
        public ViewDrawMonthDayNames(IKryptonMonthCalendar calendar, ViewLayoutMonths months)
        {
            _calendar = calendar;
            _months   = months;

            // 7 day mementos
            _dayMementos = new IDisposable[7];
        }
 /// <summary>
 /// Initialize a new instance of the MonthCalendarController class.
 /// </summary>
 /// <param name="monthCalendar">Reference to owning month calendar entry.</param>
 /// <param name="viewManager">Owning view manager instance.</param>
 /// <param name="months">Reference to view that manages the display of months.</param>
 /// <param name="needPaint">Delegate for handling repainting requests.</param>
 public MonthCalendarController(KryptonContextMenuMonthCalendar monthCalendar,
                                ViewContextMenuManager viewManager,
                                ViewLayoutMonths months, 
                                NeedPaintHandler needPaint)
 {
     _monthCalendar = monthCalendar;
     _viewManager = viewManager;
     _months = months;
     _needPaint = needPaint;
     _mouseOver = false;
     _captured = false;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Initialize a new instance of the MonthCalendarController class.
 /// </summary>
 /// <param name="monthCalendar">Reference to owning month calendar entry.</param>
 /// <param name="viewManager">Owning view manager instance.</param>
 /// <param name="months">Reference to view that manages the display of months.</param>
 /// <param name="needPaint">Delegate for handling repainting requests.</param>
 public MonthCalendarController(KryptonContextMenuMonthCalendar monthCalendar,
                                ViewContextMenuManager viewManager,
                                ViewLayoutMonths months,
                                NeedPaintHandler needPaint)
 {
     _monthCalendar = monthCalendar;
     ViewManager    = viewManager;
     _months        = months;
     _needPaint     = needPaint;
     _mouseOver     = false;
     _captured      = false;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawMonth class.
        /// </summary>
        /// <param name="calendar">Reference to calendar provider.</param>
        /// <param name="months">Reference to months instance.</param>
        /// <param name="redirector">Redirector for getting values.</param>
        /// <param name="needPaintDelegate">Delegate for requesting paint changes.</param>
        public ViewDrawMonth(IKryptonMonthCalendar calendar,
                             ViewLayoutMonths months,
                             PaletteRedirect redirector,
                             NeedPaintHandler needPaintDelegate)
            : base(false)
        {
            _calendar = calendar;
            _months   = months;

            // Add a header for showing the month/year value
            _drawContent  = new ViewDrawContent(_calendar.StateNormal.Header.Content, this, VisualOrientation.Top);
            _borderForced = new PaletteBorderInheritForced(_calendar.StateNormal.Header.Border);
            _borderForced.ForceBorderEdges(PaletteDrawBorders.None);
            _drawHeader = new ViewDrawDocker(_calendar.StateNormal.Header.Back, _borderForced, null);
            _drawHeader.Add(_drawContent, ViewDockStyle.Fill);
            Add(_drawHeader);

            // Create the left/right arrows for moving the months
            _arrowPrev        = new ButtonSpecCalendar(this, PaletteButtonSpecStyle.Previous, RelativeEdgeAlign.Near);
            _arrowNext        = new ButtonSpecCalendar(this, PaletteButtonSpecStyle.Next, RelativeEdgeAlign.Far);
            _arrowPrev.Click += new EventHandler(OnPrevMonth);
            _arrowNext.Click += new EventHandler(OnNextMonth);
            _buttonSpecs      = new CalendarButtonSpecCollection(this);
            _buttonSpecs.Add(_arrowPrev);
            _buttonSpecs.Add(_arrowNext);

            // Using a button spec manager to add the buttons to the header
            _buttonManager = new ButtonSpecManagerDraw(_calendar.CalendarControl, redirector, null, _buttonSpecs,
                                                       new ViewDrawDocker[] { _drawHeader },
                                                       new IPaletteMetric[] { _calendar.StateCommon },
                                                       new PaletteMetricInt[] { PaletteMetricInt.HeaderButtonEdgeInsetCalendar },
                                                       new PaletteMetricPadding[] { PaletteMetricPadding.None },
                                                       _calendar.GetToolStripDelegate, needPaintDelegate);

            // Create stacks for holding display items
            ViewLayoutStack namesStack = new ViewLayoutStack(true);
            ViewLayoutStack weeksStack = new ViewLayoutStack(true);
            ViewLayoutStack daysStack  = new ViewLayoutStack(false);

            _numberStack = new ViewLayoutStack(false);
            weeksStack.Add(_numberStack);
            weeksStack.Add(daysStack);

            // Add day names
            _drawMonthDayNames = new ViewDrawMonthDayNames(_calendar, _months);
            _drawWeekCorner    = new ViewLayoutWeekCorner(_calendar, _months, _calendar.StateNormal.Header.Border);
            namesStack.Add(_drawWeekCorner);
            namesStack.Add(_drawMonthDayNames);
            Add(namesStack);
            Add(weeksStack);

            // Add border between week numbers and days area
            _borderEdgeRedirect = new PaletteBorderEdgeRedirect(_calendar.StateNormal.Header.Border, null);
            _borderEdge         = new PaletteBorderEdge(_borderEdgeRedirect, null);
            _drawBorderEdge     = new ViewDrawBorderEdge(_borderEdge, Orientation.Vertical);
            _drawWeekNumbers    = new ViewDrawWeekNumbers(_calendar, _months);
            ViewLayoutDocker borderLeftDock = new ViewLayoutDocker();

            borderLeftDock.Add(_drawWeekNumbers, ViewDockStyle.Left);
            borderLeftDock.Add(new ViewLayoutSeparator(0, 4), ViewDockStyle.Top);
            borderLeftDock.Add(_drawBorderEdge, ViewDockStyle.Fill);
            borderLeftDock.Add(new ViewLayoutSeparator(0, 4), ViewDockStyle.Bottom);
            _numberStack.Add(borderLeftDock);

            // Add border between day names and individual days
            PaletteBorderEdgeRedirect borderEdgeRedirect = new PaletteBorderEdgeRedirect(_calendar.StateNormal.Header.Border, null);
            PaletteBorderEdge         borderEdge         = new PaletteBorderEdge(borderEdgeRedirect, null);
            ViewDrawBorderEdge        drawBorderEdge     = new ViewDrawBorderEdge(borderEdge, Orientation.Horizontal);
            ViewLayoutDocker          borderTopDock      = new ViewLayoutDocker();

            borderTopDock.Add(new ViewLayoutSeparator(4, 1), ViewDockStyle.Left);
            borderTopDock.Add(drawBorderEdge, ViewDockStyle.Fill);
            borderTopDock.Add(new ViewLayoutSeparator(4, 1), ViewDockStyle.Right);
            borderTopDock.Add(new ViewLayoutSeparator(1, 3), ViewDockStyle.Bottom);
            daysStack.Add(borderTopDock);

            // Add the actual individual days
            _drawMonthDays = new ViewDrawMonthDays(_calendar, _months);
            daysStack.Add(_drawMonthDays);

            // Adding buttons manually means we have to ask for buttons to be created
            _buttonManager.RecreateButtons();
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Initialize a new instance of the KryptonMonthCalendar class.
        /// </summary>
        public KryptonMonthCalendar()
        {
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);

            // Create the palette storage
            _stateCommon = new PaletteMonthCalendarRedirect(Redirector, NeedPaintDelegate);
            _stateFocus = new PaletteMonthCalendarStateRedirect(Redirector, NeedPaintDelegate);
            _stateBolded = new PaletteMonthCalendarStateRedirect(Redirector, NeedPaintDelegate);
            _stateToday = new PaletteMonthCalendarStateRedirect(Redirector, NeedPaintDelegate);

            // Basic state storage
            _stateDisabled = new PaletteMonthCalendarDoubleState(_stateCommon, NeedPaintDelegate);
            _stateNormal = new PaletteMonthCalendarDoubleState(_stateCommon, NeedPaintDelegate);
            _stateTracking = new PaletteMonthCalendarState(_stateCommon, NeedPaintDelegate);
            _statePressed = new PaletteMonthCalendarState(_stateCommon, NeedPaintDelegate);
            _stateCheckedNormal = new PaletteMonthCalendarState(_stateCommon, NeedPaintDelegate);
            _stateCheckedTracking = new PaletteMonthCalendarState(_stateCommon, NeedPaintDelegate);
            _stateCheckedPressed = new PaletteMonthCalendarState(_stateCommon, NeedPaintDelegate);

            // Bold overrides
            _boldedDisabled = new PaletteTripleOverride(_stateBolded.Day, _stateDisabled.Day, PaletteState.BoldedOverride);
            _boldedNormal = new PaletteTripleOverride(_stateBolded.Day, _stateNormal.Day, PaletteState.BoldedOverride);
            _boldedTracking = new PaletteTripleOverride(_stateBolded.Day, _stateTracking.Day, PaletteState.BoldedOverride);
            _boldedPressed = new PaletteTripleOverride(_stateBolded.Day, _statePressed.Day, PaletteState.BoldedOverride);
            _boldedCheckedNormal = new PaletteTripleOverride(_stateBolded.Day, _stateCheckedNormal.Day, PaletteState.BoldedOverride);
            _boldedCheckedTracking = new PaletteTripleOverride(_stateBolded.Day, _stateCheckedTracking.Day, PaletteState.BoldedOverride);
            _boldedCheckedPressed = new PaletteTripleOverride(_stateBolded.Day, _stateCheckedPressed.Day, PaletteState.BoldedOverride);

            // Today overrides
            _todayDisabled = new PaletteTripleOverride(_stateToday.Day, _boldedDisabled, PaletteState.TodayOverride);
            _todayNormal = new PaletteTripleOverride(_stateToday.Day, _boldedNormal, PaletteState.TodayOverride);
            _todayTracking = new PaletteTripleOverride(_stateToday.Day, _boldedTracking, PaletteState.TodayOverride);
            _todayPressed = new PaletteTripleOverride(_stateToday.Day, _boldedPressed, PaletteState.TodayOverride);
            _todayCheckedNormal = new PaletteTripleOverride(_stateToday.Day, _boldedCheckedNormal, PaletteState.TodayOverride);
            _todayCheckedTracking = new PaletteTripleOverride(_stateToday.Day, _boldedCheckedTracking, PaletteState.TodayOverride);
            _todayCheckedPressed = new PaletteTripleOverride(_stateToday.Day, _boldedCheckedPressed, PaletteState.TodayOverride);

            // Focus overrides added to bold overrides
            _overrideDisabled = new PaletteTripleOverride(_stateFocus.Day, _todayDisabled, PaletteState.FocusOverride);
            _overrideNormal = new PaletteTripleOverride(_stateFocus.Day, _todayNormal, PaletteState.FocusOverride);
            _overrideTracking = new PaletteTripleOverride(_stateFocus.Day, _todayTracking, PaletteState.FocusOverride);
            _overridePressed = new PaletteTripleOverride(_stateFocus.Day, _todayPressed, PaletteState.FocusOverride);
            _overrideCheckedNormal = new PaletteTripleOverride(_stateFocus.Day, _todayCheckedNormal, PaletteState.FocusOverride);
            _overrideCheckedTracking = new PaletteTripleOverride(_stateFocus.Day, _todayCheckedTracking, PaletteState.FocusOverride);
            _overrideCheckedPressed = new PaletteTripleOverride(_stateFocus.Day, _todayCheckedPressed, PaletteState.FocusOverride);

            // Create view that is used by standalone control as well as this context menu element
            _drawMonths = new ViewLayoutMonths(null, null, null, this, Redirector, NeedPaintDelegate);

            // Place the months layout view inside a standard docker which provides the control border
            _drawDocker = new ViewDrawDocker(_stateNormal.Back, _stateNormal.Border, null);
            _drawDocker.Add(_drawMonths, ViewDockStyle.Fill);

            // Create the view manager instance
            ViewManager = new ViewManager(this, _drawDocker);

            // Set default property values
            _dimensions = new Size(1, 1);
            _firstDayOfWeek = Day.Default;
            _headerStyle = HeaderStyle.Calendar;
            _dayStyle = ButtonStyle.CalendarDay;
            _dayOfWeekStyle = ButtonStyle.CalendarDay;
            _selectionStart = DateTime.Now.Date;
            _selectionEnd = _selectionStart;
            _todayDate = _selectionStart;
            _minDate = DateTimePicker.MinimumDateTime;
            _maxDate = DateTimePicker.MaximumDateTime;
            _maxSelectionCount = 7;
            _annualDays = new int[12];
            _annualDates = new DateTimeList();
            _monthlyDates = new DateTimeList();
            _dates = new DateTimeList();
            _scrollChange = 0;
            _todayFormat = "d";
        }