/// <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; _radioButton = 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 && _radioButton.Enabled; // Give the heading object the redirector to use when inheriting values _radioButton.SetPaletteRedirect(provider.ProviderRedirector); // Create the content for the actual heading text/image _drawContent = new ViewDrawContent((_itemEnabled ? (IPaletteContent)_radioButton.OverrideNormal : (IPaletteContent)_radioButton.OverrideDisabled), _contentValues, VisualOrientation.Top); _drawContent.UseMnemonic = true; _drawContent.Enabled = _itemEnabled; // Create the radio button image drawer and place inside element so it is always centered _drawRadioButton = new ViewDrawRadioButton(_radioButton.StateRadioButtonImages); _drawRadioButton.CheckState = _radioButton.Checked; _drawRadioButton.Enabled = _itemEnabled; _layoutCenter = new ViewLayoutCenter(); _layoutCenter.Add(_drawRadioButton); // Place the radio button on the left of the available space but inside separators _innerDocker = new ViewLayoutDocker(); _innerDocker.Add(_drawContent, ViewDockStyle.Fill); _innerDocker.Add(_layoutCenter, ViewDockStyle.Left); _innerDocker.Add(new ViewLayoutSeparator(1), ViewDockStyle.Right); _innerDocker.Add(new ViewLayoutSeparator(3), ViewDockStyle.Left); _innerDocker.Add(new ViewLayoutSeparator(1), ViewDockStyle.Top); _innerDocker.Add(new ViewLayoutSeparator(1), ViewDockStyle.Bottom); // Use outer docker so that any extra space not needed is used by the null _outerDocker = new ViewLayoutDocker(); _outerDocker.Add(_innerDocker, ViewDockStyle.Top); _outerDocker.Add(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 += new EventHandler(OnClick); _innerDocker.MouseController = mrbc; _innerDocker.KeyController = mrbc; // We need to be notified whenever the checked state changes _radioButton.CheckedChanged += new EventHandler(OnCheckedChanged); // Add docker as the composite content Add(_outerDocker); }
/// <summary> /// Initialize a new instance of the RadioButtonController class. /// </summary> /// <param name="target">Target for state changes.</param> /// <param name="top">Top element for the radio button control.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public RadioButtonController(ViewDrawRadioButton target, ViewBase top, NeedPaintHandler needPaint) { Debug.Assert(target != null); Debug.Assert(top != null); // Store the provided paint notification delegate NeedPaint = needPaint; // Remember target for state changes _target = target; _top = top; }
/// <summary> /// Initialize a new instance of the ViewDrawRibbonGroupRadioButtonImage class. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="ribbonRadioButton">Reference to ribbon group radio button definition.</param> /// <param name="large">Show the large image.</param> public ViewDrawRibbonGroupRadioButtonImage(KryptonRibbon ribbon, KryptonRibbonGroupRadioButton ribbonRadioButton, bool large) { Debug.Assert(ribbonRadioButton != null); // Remember incoming parameters _ribbonRadioButton = ribbonRadioButton; _large = large; // Use redirector to get the radio button images and redirect to parent palette PaletteRedirectRadioButton redirectImages = new PaletteRedirectRadioButton(ribbon.GetRedirector(), ribbon.StateCommon.RibbonImages.RadioButton); // Create drawing element _drawRadioButton = new ViewDrawRadioButton(redirectImages); // Add as only child Add(_drawRadioButton); }
/// <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; }
/// <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 _labelValues = new LabelValues(NeedPaintDelegate); _labelValues.TextChanged += new EventHandler(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); _stateFocus = new PaletteContent(_paletteCommonRedirect, NeedPaintDelegate); // Override the normal values with the focus, when the control has focus _overrideNormal = new PaletteContentInheritOverride(_stateFocus, _stateNormal, PaletteState.FocusOverride, false); // Our view contains background and border with content inside _drawContent = new ViewDrawContent(_overrideNormal, _labelValues, VisualOrientation.Top); _drawContent.UseMnemonic = _useMnemonic; // Only draw a focus rectangle when focus cues are needed in the top level form _drawContent.TestForFocusCues = true; // Create the check box image drawer and place inside element so it is always centered _drawRadioButton = new ViewDrawRadioButton(_paletteRadioButtonImages); _drawRadioButton.CheckState = _checked; _layoutCenter = new ViewLayoutCenter(); _layoutCenter.Add(_drawRadioButton); // Place check box on the left and the label in the remainder _layoutDocker = new ViewLayoutDocker(); _layoutDocker.Add(_layoutCenter, ViewDockStyle.Left); _layoutDocker.Add(_drawContent, ViewDockStyle.Fill); // Need a controller for handling mouse input _controller = new RadioButtonController(_drawRadioButton, _layoutDocker, NeedPaintDelegate); _controller.Click += new EventHandler(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; }