コード例 #1
0
        /// <summary>
        /// Initialize a new instance of the RadioButton class.
        /// </summary>
        public KryptonRadioButton()
        {
            // Turn off standard click and double click events, we do that manually
            SetStyle(ControlStyles.StandardClick |
                     ControlStyles.StandardDoubleClick, false);

            // Set default properties
            _style         = LabelStyle.NormalControl;
            _orientation   = VisualOrientation.Top;
            _checkPosition = VisualOrientation.Left;
            _checked       = false;
            _useMnemonic   = true;
            _autoCheck     = true;

            // Create content storage
            Values              = new LabelValues(NeedPaintDelegate);
            Values.TextChanged += OnRadioButtonTextChanged;
            Images              = new RadioButtonImages(NeedPaintDelegate);

            // Create palette redirector
            _paletteCommonRedirect    = new PaletteContentInheritRedirect(Redirector, PaletteContentStyle.LabelNormalControl);
            _paletteRadioButtonImages = new PaletteRedirectRadioButton(Redirector, Images);

            // Create the palette provider
            StateCommon   = new PaletteContent(_paletteCommonRedirect, NeedPaintDelegate);
            StateDisabled = new PaletteContent(StateCommon, NeedPaintDelegate);
            StateNormal   = new PaletteContent(StateCommon, NeedPaintDelegate);
            OverrideFocus = new PaletteContent(_paletteCommonRedirect, NeedPaintDelegate);

            // Override the normal values with the focus, when the control has focus
            _overrideNormal = new PaletteContentInheritOverride(OverrideFocus, StateNormal, PaletteState.FocusOverride, false);

            // Our view contains background and border with content inside
            _drawContent = new ViewDrawContent(_overrideNormal, Values, VisualOrientation.Top)
            {
                UseMnemonic = _useMnemonic,

                // Only draw a focus rectangle when focus cues are needed in the top level form
                TestForFocusCues = true
            };

            // Create the check box image drawer and place inside element so it is always centered
            _drawRadioButton = new ViewDrawRadioButton(_paletteRadioButtonImages)
            {
                CheckState = _checked
            };
            _layoutCenter = new ViewLayoutCenter
            {
                _drawRadioButton
            };

            // Place check box on the left and the label in the remainder
            _layoutDocker = new ViewLayoutDocker
            {
                { _layoutCenter, ViewDockStyle.Left },
                { _drawContent, ViewDockStyle.Fill }
            };

            // Need a controller for handling mouse input
            _controller                   = new RadioButtonController(_drawRadioButton, _layoutDocker, NeedPaintDelegate);
            _controller.Click            += OnControllerClick;
            _controller.Enabled           = true;
            _layoutDocker.MouseController = _controller;
            _layoutDocker.KeyController   = _controller;

            // Change the layout to match the inital right to left setting and orientation
            UpdateForOrientation();

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

            // We want to be auto sized by default, but not the property default!
            AutoSize     = true;
            AutoSizeMode = AutoSizeMode.GrowAndShrink;
        }
コード例 #2
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawButton class.
        /// </summary>
        /// <param name="paletteDisabled">Palette source for the disabled state.</param>
        /// <param name="paletteNormal">Palette source for the normal state.</param>
        /// <param name="paletteTracking">Palette source for the tracking state.</param>
        /// <param name="palettePressed">Palette source for the pressed state.</param>
        /// <param name="paletteCheckedNormal">Palette source for the normal checked state.</param>
        /// <param name="paletteCheckedTracking">Palette source for the tracking checked state.</param>
        /// <param name="paletteCheckedPressed">Palette source for the pressed checked state.</param>
        /// <param name="paletteMetric">Palette source for metric values.</param>
        /// <param name="buttonValues">Source for content values.</param>
        /// <param name="orientation">Visual orientation of the content.</param>
        /// <param name="useMnemonic">Use mnemonics.</param>
        public ViewDrawButton(IPaletteTriple paletteDisabled,
                              IPaletteTriple paletteNormal,
                              IPaletteTriple paletteTracking,
                              IPaletteTriple palettePressed,
                              IPaletteTriple paletteCheckedNormal,
                              IPaletteTriple paletteCheckedTracking,
                              IPaletteTriple paletteCheckedPressed,
                              IPaletteMetric paletteMetric,
                              IContentValues buttonValues,
                              VisualOrientation orientation,
                              bool useMnemonic)
        {
            // Remember the source information
            _paletteDisabled        = paletteDisabled;
            _paletteNormal          = paletteNormal;
            _paletteTracking        = paletteTracking;
            _palettePressed         = palettePressed;
            _paletteCheckedNormal   = paletteCheckedNormal;
            _paletteCheckedTracking = paletteCheckedTracking;
            _paletteCheckedPressed  = paletteCheckedPressed;
            CurrentPalette          = _paletteNormal;

            // Default to not being checked
            Checked           = false;
            AllowUncheck      = true;
            _dropDown         = false;
            _splitter         = false;
            _dropDownPosition = VisualOrientation.Right;

            // Create the drop down view
            _drawDropDown       = new ViewLayoutCenter(1);
            _drawDropDownButton = new ViewDrawDropDownButton();
            _drawDropDown.Add(_drawDropDownButton);
            _drawOuterSeparator = new ViewLayoutSeparator(1);

            // Create the view used to draw the split edge
            _edgeRedirect    = new PaletteBorderEdgeRedirect(_paletteNormal.PaletteBorder, null);
            _drawSplitBorder = new ViewDrawBorderEdge(new PaletteBorderEdge(_edgeRedirect, null), CommonHelper.VisualToOrientation(orientation));

            // Our view contains background and border with content inside
            _drawContent = new ViewDrawContent(_paletteNormal.PaletteContent, buttonValues, orientation);
            _drawCanvas  = new ViewDrawSplitCanvas(_paletteNormal.PaletteBack, _paletteNormal.PaletteBorder, paletteMetric, PaletteMetricPadding.None, orientation);

            // Use a docker layout to organize the contents of the canvas
            LayoutDocker = new ViewLayoutDocker
            {
                { _drawContent, ViewDockStyle.Fill },
                { _drawSplitBorder, ViewDockStyle.Right },
                { _drawDropDown, ViewDockStyle.Right },
                { _drawOuterSeparator, ViewDockStyle.Right }
            };
            LayoutDocker.Tag = this;

            // Pass the mnemonic default to the content view
            _drawContent.UseMnemonic = useMnemonic;

            // Place the content inside the canvas
            _drawCanvas.Add(LayoutDocker);

            // Set initial view element visible states
            UpdateDropDown();

            // Place the canvas inside ourself
            Add(_drawCanvas);
        }
コード例 #3
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)
            {
                { _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 += OnPrevMonth;
            _arrowNext.Click += OnNextMonth;
            _buttonSpecs      = new CalendarButtonSpecCollection(this)
            {
                _arrowPrev,
                _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
            {
                { _drawWeekNumbers, ViewDockStyle.Left },
                { new ViewLayoutSeparator(0, 4), ViewDockStyle.Top },
                { _drawBorderEdge, ViewDockStyle.Fill },
                { 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
            {
                { new ViewLayoutSeparator(4, 1), ViewDockStyle.Left },
                { drawBorderEdge, ViewDockStyle.Fill },
                { new ViewLayoutSeparator(4, 1), ViewDockStyle.Right },
                { new ViewLayoutSeparator(1, 3), ViewDockStyle.Bottom }
            };

            daysStack.Add(borderTopDock);

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

            // Adding buttons manually means we have to ask for buttons to be created
            _buttonManager.RecreateButtons();
        }
コード例 #4
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuLinkLabel class.
        /// </summary>
        /// <param name="provider">Reference to provider.</param>
        /// <param name="linkLabel">Reference to owning link label entry.</param>
        public ViewDrawMenuLinkLabel(IContextMenuProvider provider,
                                     KryptonContextMenuLinkLabel linkLabel)
        {
            _provider = provider;
            KryptonContextMenuLinkLabel = linkLabel;

            // Create fixed storage of the content values
            _contentValues = new FixedContentValue(linkLabel.Text,
                                                   linkLabel.ExtraText,
                                                   linkLabel.Image,
                                                   linkLabel.ImageTransparentColor);

            // Decide on the enabled state of the display
            ItemEnabled = provider.ProviderEnabled;

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

            // Create the content for the actual heading text/image
            _drawContent = new ViewDrawContent(linkLabel.OverrideFocusNotVisited, _contentValues, VisualOrientation.Top)
            {
                UseMnemonic = true,
                Enabled     = ItemEnabled
            };

            // Place label link in the center of the area but inside some separator to add spacing
            _innerDocker = new ViewLayoutDocker
            {
                { _drawContent, ViewDockStyle.Fill },
                { new ViewLayoutSeparator(1), ViewDockStyle.Right },
                { new ViewLayoutSeparator(1), ViewDockStyle.Left },
                { new ViewLayoutSeparator(1), ViewDockStyle.Top },
                { new ViewLayoutSeparator(1), ViewDockStyle.Bottom }
            };

            // Use outer docker so that any extra space not needed is used by the null
            _outerDocker = new ViewLayoutDocker
            {
                { _innerDocker, ViewDockStyle.Top },
                { new ViewLayoutNull(), ViewDockStyle.Fill }
            };

            // Use context menu specific version of the link label controller
            MenuLinkLabelController mllc = new MenuLinkLabelController(provider.ProviderViewManager, _drawContent, this, provider.ProviderNeedPaintDelegate);

            mllc.Click += OnClick;
            _drawContent.MouseController = mllc;
            _drawContent.KeyController   = mllc;

            // Add docker as the composite content
            Add(_outerDocker);

            // Want to know when a property changes whilst displayed
            KryptonContextMenuLinkLabel.PropertyChanged += OnPropertyChanged;

            // We need to know if a property of the command changes
            if (KryptonContextMenuLinkLabel.KryptonCommand != null)
            {
                _cachedCommand = KryptonContextMenuLinkLabel.KryptonCommand;
                KryptonContextMenuLinkLabel.KryptonCommand.PropertyChanged += OnCommandPropertyChanged;
            }
        }
コード例 #5
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuCheckButton class.
        /// </summary>
        /// <param name="provider">Reference to provider.</param>
        /// <param name="checkButton">Reference to owning check button entry.</param>
        public ViewDrawMenuCheckButton(IContextMenuProvider provider,
                                       KryptonContextMenuCheckButton checkButton)
        {
            _provider = provider;
            KryptonContextMenuCheckButton = checkButton;

            // Create fixed storage of the content values
            _contentValues = new FixedContentValue(ResolveText,
                                                   ResolveExtraText,
                                                   ResolveImage,
                                                   ResolveImageTransparentColor);

            // Decide on the enabled state of the display
            ItemEnabled = provider.ProviderEnabled && ResolveEnabled;

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

            // Create the view button instance
            ViewDrawButton = new ViewDrawButton(checkButton.OverrideDisabled,
                                                checkButton.OverrideNormal,
                                                checkButton.OverrideTracking,
                                                checkButton.OverridePressed,
                                                new PaletteMetricRedirect(provider.ProviderRedirector),
                                                _contentValues,
                                                VisualOrientation.Top,
                                                true);

            // Add the checked specific palettes to the existing view button
            ViewDrawButton.SetCheckedPalettes(checkButton.OverrideCheckedNormal,
                                              checkButton.OverrideCheckedTracking,
                                              checkButton.OverrideCheckedPressed);

            ViewDrawButton.Enabled = ItemEnabled;
            ViewDrawButton.Checked = ResolveChecked;

            // Place the check box on the left of the available space but inside separators
            _innerDocker = new ViewLayoutDocker
            {
                { ViewDrawButton, ViewDockStyle.Fill },
                { new ViewLayoutSeparator(1), ViewDockStyle.Right },
                { new ViewLayoutSeparator(1), ViewDockStyle.Left },
                { new ViewLayoutSeparator(1), ViewDockStyle.Top },
                { new ViewLayoutSeparator(1), ViewDockStyle.Bottom }
            };

            // Use outer docker so that any extra space not needed is used by the null
            _outerDocker = new ViewLayoutDocker
            {
                { _innerDocker, ViewDockStyle.Top },
                { new ViewLayoutNull(), ViewDockStyle.Fill }
            };

            // Use context menu specific version of the check box controller
            MenuCheckButtonController mcbc = new MenuCheckButtonController(provider.ProviderViewManager, _innerDocker, this, provider.ProviderNeedPaintDelegate);

            mcbc.Click += OnClick;
            _innerDocker.MouseController = mcbc;
            _innerDocker.KeyController   = mcbc;

            // Add docker as the composite content
            Add(_outerDocker);

            // Want to know when a property changes whilst displayed
            KryptonContextMenuCheckButton.PropertyChanged += OnPropertyChanged;

            // We need to know if a property of the command changes
            if (KryptonContextMenuCheckButton.KryptonCommand != null)
            {
                _cachedCommand = KryptonContextMenuCheckButton.KryptonCommand;
                KryptonContextMenuCheckButton.KryptonCommand.PropertyChanged += OnCommandPropertyChanged;
            }
        }
コード例 #6
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuItem class.
        /// </summary>
        /// <param name="provider">Provider of context menu information.</param>
        /// <param name="menuItem">Menu item definition.</param>
        /// <param name="columns">Containing columns.</param>
        /// <param name="standardStyle">Draw items with standard or alternate style.</param>
        /// <param name="imageColumn">Draw an image background for the item images.</param>
        public ViewDrawMenuItem(IContextMenuProvider provider,
                                KryptonContextMenuItem menuItem,
                                ViewLayoutStack columns,
                                bool standardStyle,
                                bool imageColumn)
            : base(menuItem.StateNormal.ItemHighlight.Back,
                   menuItem.StateNormal.ItemHighlight.Border,
                   menuItem.StateNormal.ItemHighlight,
                   PaletteMetricPadding.ContextMenuItemHighlight,
                   VisualOrientation.Top)
        {
            // Remember values
            _provider = provider;
            KryptonContextMenuItem = menuItem;
            _imageColumn           = imageColumn;
            _standardStyle         = standardStyle;

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

            // Create a stack of horizontal items inside the item
            ViewLayoutDocker docker = new ViewLayoutDocker();

            // Decide on the enabled state of the display
            ItemEnabled = provider.ProviderEnabled && ResolveEnabled;
            PaletteContextMenuItemState menuItemState = (ItemEnabled ? KryptonContextMenuItem.StateNormal : KryptonContextMenuItem.StateDisabled);

            // Calculate the image to show inside in the image column
            Image itemColumnImage      = ResolveImage;
            Color itemImageTransparent = ResolveImageTransparentColor;

            // If no image found then...
            if (itemColumnImage != null)
            {
                // Ensure we have a fixed size if we are showing an image column
                if (_imageColumn)
                {
                    itemColumnImage      = _empty16x16;
                    itemImageTransparent = Color.Magenta;
                }

                switch (ResolveCheckState)
                {
                case CheckState.Checked:
                    itemColumnImage      = provider.ProviderImages.GetContextMenuCheckedImage();
                    itemImageTransparent = Color.Empty;
                    break;

                case CheckState.Indeterminate:
                    itemColumnImage      = provider.ProviderImages.GetContextMenuIndeterminateImage();
                    itemImageTransparent = Color.Empty;
                    break;
                }
            }

            // Column Image
            PaletteTripleJustImage justImage = (ResolveChecked ? KryptonContextMenuItem.StateChecked.ItemImage : menuItemState.ItemImage);

            _fixedImage   = new FixedContentValue(null, null, itemColumnImage, itemImageTransparent);
            _imageContent = new ViewDrawContent(justImage.Content, _fixedImage, VisualOrientation.Top);
            _imageCanvas  = new ViewDrawMenuImageCanvas(justImage.Back, justImage.Border, 0, false)
            {
                _imageContent
            };
            docker.Add(new ViewLayoutCenter(_imageCanvas), ViewDockStyle.Left);
            _imageContent.Enabled = ItemEnabled;

            // Text/Extra Text
            PaletteContentJustText menuItemStyle = (standardStyle ? menuItemState.ItemTextStandard : menuItemState.ItemTextAlternate);

            _fixedTextExtraText = new FixedContentValue(ResolveText, ResolveExtraText, null, Color.Empty);
            _textContent        = new ViewDrawMenuItemContent(menuItemStyle, _fixedTextExtraText, 1);
            docker.Add(_textContent, ViewDockStyle.Fill);
            _textContent.Enabled = ItemEnabled;

            // Shortcut
            if (KryptonContextMenuItem.ShowShortcutKeys)
            {
                string shortcutString = KryptonContextMenuItem.ShortcutKeyDisplayString;
                if (string.IsNullOrEmpty(shortcutString))
                {
                    shortcutString = (KryptonContextMenuItem.ShortcutKeys != Keys.None) ? new KeysConverter().ConvertToString(KryptonContextMenuItem.ShortcutKeys) : string.Empty;
                }

                if (shortcutString.Length > 0)
                {
                    _shortcutContent = new ViewDrawMenuItemContent(menuItemState.ItemShortcutText, new FixedContentValue(shortcutString, null, null, Color.Empty), 2);
                    docker.Add(_shortcutContent, ViewDockStyle.Right);
                    _shortcutContent.Enabled = ItemEnabled;
                }
            }

            // Add split item separator
            SplitSeparator = new ViewDrawMenuSeparator(menuItemState.ItemSplit);
            docker.Add(SplitSeparator, ViewDockStyle.Right);
            SplitSeparator.Enabled = ItemEnabled;
            SplitSeparator.Draw    = (KryptonContextMenuItem.Items.Count > 0) && KryptonContextMenuItem.SplitSubMenu;

            // SubMenu Indicator
            HasSubMenu      = (KryptonContextMenuItem.Items.Count > 0);
            _subMenuContent = new ViewDrawMenuItemContent(menuItemState.ItemImage.Content, new FixedContentValue(null, null, (!HasSubMenu ? _empty16x16 : provider.ProviderImages.GetContextMenuSubMenuImage()), (KryptonContextMenuItem.Items.Count == 0 ? Color.Magenta : Color.Empty)), 3);
            docker.Add(new ViewLayoutCenter(_subMenuContent), ViewDockStyle.Right);
            _subMenuContent.Enabled = ItemEnabled;

            Add(docker);

            // Add a controller for handing mouse and keyboard events
            MenuItemController mic = new MenuItemController(provider.ProviderViewManager, this, provider.ProviderNeedPaintDelegate);

            MouseController = mic;
            KeyController   = mic;

            // Want to know when a property changes whilst displayed
            KryptonContextMenuItem.PropertyChanged += OnPropertyChanged;

            // We need to know if a property of the command changes
            if (KryptonContextMenuItem.KryptonCommand != null)
            {
                _cachedCommand = KryptonContextMenuItem.KryptonCommand;
                KryptonContextMenuItem.KryptonCommand.PropertyChanged += OnCommandPropertyChanged;
            }
        }
コード例 #7
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuRadioButton class.
        /// </summary>
        /// <param name="provider">Reference to provider.</param>
        /// <param name="radioButton">Reference to owning radio button entry.</param>
        public ViewDrawMenuRadioButton(IContextMenuProvider provider,
                                       KryptonContextMenuRadioButton radioButton)
        {
            _provider = provider;
            KryptonContextMenuRadioButton = radioButton;

            // Create fixed storage of the content values
            _contentValues = new FixedContentValue(radioButton.Text,
                                                   radioButton.ExtraText,
                                                   radioButton.Image,
                                                   radioButton.ImageTransparentColor);

            // Decide on the enabled state of the display
            ItemEnabled = provider.ProviderEnabled && KryptonContextMenuRadioButton.Enabled;

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

            // Create the content for the actual heading text/image
            ViewDrawContent = new ViewDrawContent((ItemEnabled ? KryptonContextMenuRadioButton.OverrideNormal : KryptonContextMenuRadioButton.OverrideDisabled),
                                                  _contentValues, VisualOrientation.Top)
            {
                UseMnemonic = true,
                Enabled     = ItemEnabled
            };

            // Create the radio button image drawer and place inside element so it is always centered
            ViewDrawRadioButton = new ViewDrawRadioButton(KryptonContextMenuRadioButton.StateRadioButtonImages)
            {
                CheckState = KryptonContextMenuRadioButton.Checked,
                Enabled    = ItemEnabled
            };
            _layoutCenter = new ViewLayoutCenter
            {
                ViewDrawRadioButton
            };

            // Place the radio button on the left of the available space but inside separators
            _innerDocker = new ViewLayoutDocker
            {
                { ViewDrawContent, ViewDockStyle.Fill },
                { _layoutCenter, ViewDockStyle.Left },
                { new ViewLayoutSeparator(1), ViewDockStyle.Right },
                { new ViewLayoutSeparator(3), ViewDockStyle.Left },
                { new ViewLayoutSeparator(1), ViewDockStyle.Top },
                { new ViewLayoutSeparator(1), ViewDockStyle.Bottom }
            };

            // Use outer docker so that any extra space not needed is used by the null
            _outerDocker = new ViewLayoutDocker
            {
                { _innerDocker, ViewDockStyle.Top },
                { new ViewLayoutNull(), ViewDockStyle.Fill }
            };

            // Use context menu specific version of the radio button controller
            MenuRadioButtonController mrbc = new MenuRadioButtonController(provider.ProviderViewManager, _innerDocker, this, provider.ProviderNeedPaintDelegate);

            mrbc.Click += OnClick;
            _innerDocker.MouseController = mrbc;
            _innerDocker.KeyController   = mrbc;

            // We need to be notified whenever the checked state changes
            KryptonContextMenuRadioButton.CheckedChanged += OnCheckedChanged;

            // Add docker as the composite content
            Add(_outerDocker);
        }
コード例 #8
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuCheckBox class.
        /// </summary>
        /// <param name="provider">Reference to provider.</param>
        /// <param name="checkBox">Reference to owning check box entry.</param>
        public ViewDrawMenuCheckBox(IContextMenuProvider provider,
                                    KryptonContextMenuCheckBox checkBox)
        {
            _provider = provider;
            KryptonContextMenuCheckBox = checkBox;

            // Create fixed storage of the content values
            _contentValues = new FixedContentValue(ResolveText,
                                                   ResolveExtraText,
                                                   ResolveImage,
                                                   ResolveImageTransparentColor);

            // Decide on the enabled state of the display
            ItemEnabled = provider.ProviderEnabled && ResolveEnabled;

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

            // Create the content for the actual heading text/image
            ViewDrawContent = new ViewDrawContent((ItemEnabled ? KryptonContextMenuCheckBox.OverrideNormal : KryptonContextMenuCheckBox.OverrideDisabled),
                                                  _contentValues, VisualOrientation.Top)
            {
                UseMnemonic = true,
                Enabled     = ItemEnabled
            };

            // Create the check box image drawer and place inside element so it is always centered
            ViewDrawCheckBox = new ViewDrawCheckBox(KryptonContextMenuCheckBox.StateCheckBoxImages)
            {
                CheckState = ResolveCheckState,
                Enabled    = ItemEnabled
            };
            _layoutCenter = new ViewLayoutCenter
            {
                ViewDrawCheckBox
            };

            // Place the check box on the left of the available space but inside separators
            _innerDocker = new ViewLayoutDocker
            {
                { ViewDrawContent, ViewDockStyle.Fill },
                { _layoutCenter, ViewDockStyle.Left },
                { new ViewLayoutSeparator(1), ViewDockStyle.Right },
                { new ViewLayoutSeparator(3), ViewDockStyle.Left },
                { new ViewLayoutSeparator(1), ViewDockStyle.Top },
                { new ViewLayoutSeparator(1), ViewDockStyle.Bottom }
            };

            // Use outer docker so that any extra space not needed is used by the null
            _outerDocker = new ViewLayoutDocker
            {
                { _innerDocker, ViewDockStyle.Top },
                { new ViewLayoutNull(), ViewDockStyle.Fill }
            };

            // Use context menu specific version of the check box controller
            MenuCheckBoxController mcbc = new MenuCheckBoxController(provider.ProviderViewManager, _innerDocker, this, provider.ProviderNeedPaintDelegate);

            mcbc.Click += OnClick;
            _innerDocker.MouseController = mcbc;
            _innerDocker.KeyController   = mcbc;

            // Add docker as the composite content
            Add(_outerDocker);

            // Want to know when a property changes whilst displayed
            KryptonContextMenuCheckBox.PropertyChanged += OnPropertyChanged;

            // We need to know if a property of the command changes
            if (KryptonContextMenuCheckBox.KryptonCommand != null)
            {
                _cachedCommand = KryptonContextMenuCheckBox.KryptonCommand;
                KryptonContextMenuCheckBox.KryptonCommand.PropertyChanged += OnCommandPropertyChanged;
            }
        }