Manage a collection of button specs for placing within a collection of ViewDrawDocker instances.
상속: ButtonSpecManagerBase
예제 #1
0
 public MyKryptonBreadCrumb()
 {
     base.SetStyle(ControlStyles.Selectable, false);
     this._selectedItem              = null;
     this._dropDownNavigaton         = true;
     this._buttonStyle               = ButtonStyle.BreadCrumb;
     this._rootItem                  = new KryptonBreadCrumbItem();
     this._rootItem.PropertyChanged += new PropertyChangedEventHandler(this.OnCrumbItemChanged);
     this._allowButtonSpecToolTips   = false;
     this._buttonSpecs               = new BreadCrumbButtonSpecCollection(this);
     this._stateCommon               = new PaletteBreadCrumbRedirect(base.Redirector, base.NeedPaintDelegate);
     this._stateDisabled             = new PaletteBreadCrumbDoubleState(this._stateCommon, base.NeedPaintDelegate);
     this._stateNormal               = new PaletteBreadCrumbDoubleState(this._stateCommon, base.NeedPaintDelegate);
     this._stateTracking             = new PaletteBreadCrumbState(this._stateCommon, base.NeedPaintDelegate);
     this._statePressed              = new PaletteBreadCrumbState(this._stateCommon, base.NeedPaintDelegate);
     //this._layoutCrumbs =new ViewLayoutCrumbs( new ViewLayoutCrumbs((KryptonBreadCrumb)this, base.NeedPaintDelegate);// new ViewLayoutCrumbs(this, base.NeedPaintDelegate);
     this._drawDocker = new ViewDrawDocker(this._stateNormal.Back, this._stateNormal.Border, null);
     //this._drawDocker.Add(this._layoutCrumbs, ViewDockStyle.Fill);
     base.ViewManager = new ViewManager(this, this._drawDocker);
     PaletteMetricPadding[] viewMetricPaddings = new PaletteMetricPadding[1];
     this._buttonManager                 = new ButtonSpecManagerDraw(this, base.Redirector, this._buttonSpecs, null, new ViewDrawDocker[] { this._drawDocker }, new IPaletteMetric[] { this._stateCommon }, new PaletteMetricInt[] { PaletteMetricInt.HeaderButtonEdgeInsetPrimary }, viewMetricPaddings, new GetToolStripRenderer(this.CreateToolStripRenderer), base.NeedPaintDelegate);
     this._toolTipManager                = new ComponentFactory.Krypton.Toolkit.ToolTipManager();
     this._toolTipManager.ShowToolTip   += new EventHandler <ToolTipEventArgs>(this.OnShowToolTip);
     this._toolTipManager.CancelToolTip += new EventHandler(this.OnCancelToolTip);
     this._buttonManager.ToolTipManager  = this._toolTipManager;
 }
예제 #2
0
        /// <summary>
        /// Initialize a new instance of the KryptonBreadCrumb class.
        /// </summary>
        public KryptonBreadCrumb()
        {
            // The bread crumb cannot take the focus
            SetStyle(ControlStyles.Selectable, false);

            // Set default values
            _selectedItem                  = null;
            _dropDownNavigaton             = true;
            _buttonStyle                   = ButtonStyle.BreadCrumb;
            RootItem                       = new KryptonBreadCrumbItem("Root");
            RootItem.PropertyChanged      += OnCrumbItemChanged;
            AllowButtonSpecToolTips        = false;
            AllowButtonSpecToolTipPriority = false;

            // Create storage objects
            ButtonSpecs = new BreadCrumbButtonSpecCollection(this);

            // Create the palette storage
            StateCommon   = new PaletteBreadCrumbRedirect(Redirector, NeedPaintDelegate);
            StateDisabled = new PaletteBreadCrumbDoubleState(StateCommon, NeedPaintDelegate);
            StateNormal   = new PaletteBreadCrumbDoubleState(StateCommon, NeedPaintDelegate);
            StateTracking = new PaletteBreadCrumbState(StateCommon, NeedPaintDelegate);
            StatePressed  = new PaletteBreadCrumbState(StateCommon, NeedPaintDelegate);

            // Our view contains background and border with crumbs inside
            _layoutCrumbs = new ViewLayoutCrumbs(this, NeedPaintDelegate);
            _drawDocker   = new ViewDrawDocker(StateNormal.Back, StateNormal.Border, null)
            {
                { _layoutCrumbs, ViewDockStyle.Fill }
            };

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

            // Create button specification collection manager
            _buttonManager = new ButtonSpecManagerDraw(this, Redirector, ButtonSpecs, null,
                                                       new ViewDrawDocker[] { _drawDocker },
                                                       new IPaletteMetric[] { StateCommon },
                                                       new PaletteMetricInt[] { PaletteMetricInt.HeaderButtonEdgeInsetPrimary },
                                                       new PaletteMetricPadding[] { PaletteMetricPadding.None },
                                                       CreateToolStripRenderer,
                                                       NeedPaintDelegate);

            // Create the manager for handling tooltips
            ToolTipManager                = new ToolTipManager();
            ToolTipManager.ShowToolTip   += OnShowToolTip;
            ToolTipManager.CancelToolTip += OnCancelToolTip;
            _buttonManager.ToolTipManager = ToolTipManager;
        }
예제 #3
0
        /// <summary>
        /// Initialize a new instance of the KryptonHeader class.
        /// </summary>
        public KryptonHeader()
        {
            // The header cannot take the focus
            SetStyle(ControlStyles.Selectable, false);

            // Set default values
            _style                         = HeaderStyle.Primary;
            _orientation                   = VisualOrientation.Top;
            AllowButtonSpecToolTips        = false;
            AllowButtonSpecToolTipPriority = false;

            // Create storage objects
            Values              = new HeaderValues(NeedPaintDelegate);
            Values.TextChanged += OnHeaderTextChanged;
            ButtonSpecs         = new HeaderButtonSpecCollection(this);

            // Create the palette storage
            StateCommon   = new PaletteHeaderRedirect(Redirector, PaletteBackStyle.HeaderPrimary, PaletteBorderStyle.HeaderPrimary, PaletteContentStyle.HeaderPrimary, NeedPaintDelegate);
            StateDisabled = new PaletteTripleMetric(StateCommon, NeedPaintDelegate);
            StateNormal   = new PaletteTripleMetric(StateCommon, NeedPaintDelegate);

            // Our view contains background and border with content inside
            _drawDocker  = new ViewDrawDocker(StateNormal.Back, StateNormal.Border, null);
            _drawContent = new ViewDrawContent(StateNormal.Content, Values, Orientation);
            _drawDocker.Add(_drawContent, ViewDockStyle.Fill);

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

            // Create button specification collection manager
            _buttonManager = new ButtonSpecManagerDraw(this, Redirector, ButtonSpecs, null,
                                                       new ViewDrawDocker[] { _drawDocker },
                                                       new IPaletteMetric[] { StateCommon },
                                                       new PaletteMetricInt[] { PaletteMetricInt.HeaderButtonEdgeInsetPrimary },
                                                       new PaletteMetricPadding[] { PaletteMetricPadding.HeaderButtonPaddingPrimary },
                                                       CreateToolStripRenderer,
                                                       NeedPaintDelegate);

            // Create the manager for handling tooltips
            ToolTipManager                = new ToolTipManager();
            ToolTipManager.ShowToolTip   += OnShowToolTip;
            ToolTipManager.CancelToolTip += OnCancelToolTip;
            _buttonManager.ToolTipManager = ToolTipManager;

            // We want to be auto sized by default, but not the property default!
            AutoSize     = true;
            AutoSizeMode = AutoSizeMode.GrowAndShrink;
        }
예제 #4
0
        /// <summary>
        /// Initialize a new instance of the ViewLayoutMonths class.
        /// </summary>
        /// <param name="provider">Provider of context menu information.</param>
        /// <param name="monthCalendar">Reference to owning month calendar entry.</param>
        /// <param name="viewManager">Owning view manager instance.</param>
        /// <param name="calendar">Reference to calendar provider.</param>
        /// <param name="redirector">Redirector for getting values.</param>
        /// <param name="needPaintDelegate">Delegate for requesting paint changes.</param>
        public ViewLayoutMonths(IContextMenuProvider provider,
                                KryptonContextMenuMonthCalendar monthCalendar,
                                ViewContextMenuManager viewManager,
                                IKryptonMonthCalendar calendar,
                                PaletteRedirect redirector,
                                NeedPaintHandler needPaintDelegate)
        {
            Provider                = provider;
            Calendar                = calendar;
            _oldSelectionStart      = Calendar.SelectionStart;
            _oldSelectionEnd        = Calendar.SelectionEnd;
            _displayMonth           = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            _redirector             = redirector;
            _needPaintDelegate      = needPaintDelegate;
            _showToday              = true;
            _showTodayCircle        = true;
            CloseOnTodayClick       = false;
            _firstTimeSync          = true;
            AllowButtonSpecToolTips = false;

            // Use a controller that can work against all the displayed months
            MonthCalendarController controller = new MonthCalendarController(monthCalendar, viewManager, this, _needPaintDelegate);

            MouseController  = controller;
            SourceController = controller;
            KeyController    = controller;

            _borderForced = new PaletteBorderInheritForced(Calendar.StateNormal.Header.Border);
            _borderForced.ForceBorderEdges(PaletteDrawBorders.None);
            _drawHeader   = new ViewDrawDocker(Calendar.StateNormal.Header.Back, _borderForced, null);
            _emptyContent = new ViewDrawEmptyContent(Calendar.StateDisabled.Header.Content, Calendar.StateNormal.Header.Content);
            _drawHeader.Add(_emptyContent, ViewDockStyle.Fill);
            Add(_drawHeader);

            // Using a button spec manager to add the buttons to the header
            ButtonSpecs   = new MonthCalendarButtonSpecCollection(this);
            ButtonManager = new ButtonSpecManagerDraw(Calendar.CalendarControl, redirector, ButtonSpecs, null,
                                                      new ViewDrawDocker[] { _drawHeader },
                                                      new IPaletteMetric[] { Calendar.StateCommon },
                                                      new PaletteMetricInt[] { PaletteMetricInt.HeaderButtonEdgeInsetCalendar },
                                                      new PaletteMetricPadding[] { PaletteMetricPadding.None },
                                                      Calendar.GetToolStripDelegate, _needPaintDelegate);

            // Create the manager for handling tooltips
            _toolTipManager                = new ToolTipManager();
            _toolTipManager.ShowToolTip   += OnShowToolTip;
            _toolTipManager.CancelToolTip += OnCancelToolTip;
            ButtonManager.ToolTipManager   = _toolTipManager;

            // Create the bottom header used for showing 'today' and defined button specs
            _remapPalette            = (ButtonSpecRemapByContentView)ButtonManager.CreateButtonSpecRemap(redirector, new ButtonSpecAny());
            _remapPalette.Foreground = _emptyContent;

            // Use a redirector to get button values directly from palette
            _palette = new PaletteTripleRedirect(_remapPalette,
                                                 PaletteBackStyle.ButtonButtonSpec,
                                                 PaletteBorderStyle.ButtonButtonSpec,
                                                 PaletteContentStyle.ButtonButtonSpec,
                                                 _needPaintDelegate);

            _drawToday        = new ViewDrawToday(Calendar, _palette, _palette, _palette, _palette, _needPaintDelegate);
            _drawToday.Click += OnTodayClick;
            _drawHeader.Add(_drawToday, ViewDockStyle.Left);
        }
예제 #5
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();
        }
예제 #6
0
        /// <summary>
        /// Initialize a new instance of the ViewLayoutMonths class.
        /// </summary>
        /// <param name="provider">Provider of context menu information.</param>
        /// <param name="monthCalendar">Reference to owning month calendar entry.</param>
        /// <param name="viewManager">Owning view manager instance.</param>
        /// <param name="calendar">Reference to calendar provider.</param>
        /// <param name="redirector">Redirector for getting values.</param>
        /// <param name="needPaintDelegate">Delegate for requesting paint changes.</param>
        public ViewLayoutMonths(IContextMenuProvider provider,
                                KryptonContextMenuMonthCalendar monthCalendar,
                                ViewContextMenuManager viewManager,
                                IKryptonMonthCalendar calendar,
                                PaletteRedirect redirector,
                                NeedPaintHandler needPaintDelegate)
        {
            _provider = provider;
            _calendar = calendar;
            _oldSelectionStart = _calendar.SelectionStart;
            _oldSelectionEnd = _calendar.SelectionEnd;
            _displayMonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            _redirector = redirector;
            _needPaintDelegate = needPaintDelegate;
            _showToday = true;
            _showTodayCircle = true;
            _closeOnTodayClick = false;
            _firstTimeSync = true;
            _allowButtonSpecToolTips = false;

            // Use a controller that can work against all the displayed months
            MonthCalendarController controller = new MonthCalendarController(monthCalendar, viewManager, this, _needPaintDelegate);
            MouseController = controller;
            SourceController = controller;
            KeyController = controller;

            _borderForced = new PaletteBorderInheritForced(_calendar.StateNormal.Header.Border);
            _borderForced.ForceBorderEdges(PaletteDrawBorders.None);
            _drawHeader = new ViewDrawDocker(_calendar.StateNormal.Header.Back, _borderForced, null);
            _emptyContent = new ViewDrawEmptyContent(_calendar.StateDisabled.Header.Content, _calendar.StateNormal.Header.Content);
            _drawHeader.Add(_emptyContent, ViewDockStyle.Fill);
            Add(_drawHeader);

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

            // Create the manager for handling tooltips
            _toolTipManager = new ToolTipManager();
            _toolTipManager.ShowToolTip += new EventHandler<ToolTipEventArgs>(OnShowToolTip);
            _toolTipManager.CancelToolTip += new EventHandler(OnCancelToolTip);
            _buttonManager.ToolTipManager = _toolTipManager;

            // Create the bottom header used for showing 'today' and defined button specs
            _remapPalette = (ButtonSpecRemapByContentView)_buttonManager.CreateButtonSpecRemap(redirector, new ButtonSpecAny());
            _remapPalette.Foreground = _emptyContent;

            // Use a redirector to get button values directly from palette
            _palette = new PaletteTripleRedirect(_remapPalette,
                                                 PaletteBackStyle.ButtonButtonSpec,
                                                 PaletteBorderStyle.ButtonButtonSpec,
                                                 PaletteContentStyle.ButtonButtonSpec,
                                                 _needPaintDelegate);

            _drawToday = new ViewDrawToday(_calendar, _palette, _palette, _palette, _palette, _needPaintDelegate);
            _drawToday.Click += new EventHandler(OnTodayClick);
            _drawHeader.Add(_drawToday, ViewDockStyle.Left);
        }
        protected override void CreateButtonSpecManager()
        {
            // Create button specification collection manager
            _buttonManager = new ButtonSpecManagerDraw(Navigator, Redirector, Navigator.Button.ButtonSpecs, Navigator.FixedSpecs,
                                                       new ViewDrawDocker[] { _viewHeadingPrimary, _viewHeadingSecondary },
                                                       new IPaletteMetric[] { Navigator.StateCommon.HeaderGroup.HeaderPrimary, Navigator.StateCommon.HeaderGroup.HeaderSecondary },
                                                       new PaletteMetricInt[] { PaletteMetricInt.HeaderButtonEdgeInsetPrimary, PaletteMetricInt.HeaderButtonEdgeInsetSecondary },
                                                       new PaletteMetricPadding[] { PaletteMetricPadding.HeaderButtonPaddingPrimary, PaletteMetricPadding.HeaderButtonPaddingSecondary },
                                                       new GetToolStripRenderer(Navigator.CreateToolStripRenderer),
                                                       NeedPaintDelegate);

            // Hook up the tooltip manager so that tooltips can be generated
            _buttonManager.ToolTipManager = Navigator.ToolTipManager;
        }