/// <summary> /// Initialize a new instance of the KryptonContextMenuCheckBox class. /// </summary> /// <param name="initialText">Initial text for display.</param> public KryptonContextMenuCheckBox(string initialText) { // Default fields _enabled = true; _autoClose = false; _text = initialText; _extraText = string.Empty; _image = null; _imageTransparentColor = Color.Empty; _checkState = CheckState.Unchecked; _checked = false; _threeState = false; _autoCheck = true; _style = LabelStyle.NormalPanel; Images = new CheckBoxImages(); // Create the redirectors _stateCommonRedirect = new PaletteContentInheritRedirect(PaletteContentStyle.LabelNormalPanel); StateCheckBoxImages = new PaletteRedirectCheckBox(Images); // Create the states StateCommon = new PaletteContent(_stateCommonRedirect); StateDisabled = new PaletteContent(StateCommon); StateNormal = new PaletteContent(StateCommon); OverrideFocus = new PaletteContent(_stateCommonRedirect); // Override the normal/disabled values with the focus, when the control has focus OverrideNormal = new PaletteContentInheritOverride(OverrideFocus, StateNormal, PaletteState.FocusOverride, false); OverrideDisabled = new PaletteContentInheritOverride(OverrideFocus, StateDisabled, PaletteState.FocusOverride, false); }
/// <summary> /// Initialize a new instance of the PaletteRibbonImages class. /// </summary> /// <param name="redirect">Inheritence redirection instance.</param> /// <param name="needPaint">Paint delegate.</param> public PaletteRibbonImages(PaletteRedirect redirect, NeedPaintHandler needPaint) { Debug.Assert(redirect != null); Debug.Assert(needPaint != null); CheckBox = new CheckBoxImages(needPaint); RadioButton = new RadioButtonImages(needPaint); InternalCheckBox = new PaletteRedirectCheckBox(redirect, CheckBox); InternalRadioButton = new PaletteRedirectRadioButton(redirect, RadioButton); }
/// <summary> /// Initialize a new instance of the ViewDrawRibbonGroupCheckBoxImage class. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="ribbonCheckBox">Reference to ribbon group check box definition.</param> /// <param name="large">Show the large image.</param> public ViewDrawRibbonGroupCheckBoxImage(KryptonRibbon ribbon, KryptonRibbonGroupCheckBox ribbonCheckBox, bool large) { Debug.Assert(ribbonCheckBox != null); // Remember incoming parameters _ribbonCheckBox = ribbonCheckBox; _large = large; // Use redirector to get the check box images and redirect to parent palette PaletteRedirectCheckBox redirectImages = new PaletteRedirectCheckBox(ribbon.GetRedirector(), ribbon.StateCommon.RibbonImages.CheckBox); // Create drawing element _drawCheckBox = new ViewDrawCheckBox(redirectImages); // Add as only child Add(_drawCheckBox); }
/// <summary> /// Initialize a new instance of the KryptonCheckBox class. /// </summary> public KryptonCheckBox() { // Turn off standard click and double click events, we do that manually SetStyle(ControlStyles.StandardClick | ControlStyles.StandardDoubleClick, false); // Set default properties _style = LabelStyle.NormalPanel; _orientation = VisualOrientation.Top; _checkPosition = VisualOrientation.Left; _checked = false; _threeState = false; _checkState = CheckState.Unchecked; _useMnemonic = true; AutoCheck = true; // Create content storage Values = new LabelValues(NeedPaintDelegate); Values.TextChanged += OnCheckBoxTextChanged; Images = new CheckBoxImages(NeedPaintDelegate); // Create palette redirector _paletteCommonRedirect = new PaletteContentInheritRedirect(Redirector, PaletteContentStyle.LabelNormalPanel); _paletteCheckBoxImages = new PaletteRedirectCheckBox(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, this, 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 _drawCheckBox = new ViewDrawCheckBox(_paletteCheckBoxImages) { CheckState = _checkState }; _layoutCenter = new ViewLayoutCenter { _drawCheckBox }; // 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 CheckBoxController(_drawCheckBox, _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; }
public KryptonListView() { SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor // Cannot get thi sto work (Code removed)!! | ControlStyles.EnableNotifyMessage , true); base.OwnerDraw = true; // We need to repaint entire control whenever resized SetStyle(ControlStyles.ResizeRedraw, true); // Yes, we want to be drawn double buffered by default DoubleBuffered = true; // Default fields _alwaysActive = true; _style = ButtonStyle.ListItem; Padding = new Padding(1); base.BorderStyle = System.Windows.Forms.BorderStyle.None; // We need to create and cache a device context compatible with the display _screenDC = PI.CreateCompatibleDC(IntPtr.Zero); // Set the palette and renderer to the defaults as specified by the manager Redirector = new PaletteRedirect(null); CacheNewPalette(KryptonManager.CurrentGlobalPalette); KryptonManager.GlobalPaletteChanged += OnGlobalPaletteChanged; NeedPaintDelegate = OnNeedPaint; // Create the palette storage Images = new CheckBoxImages(NeedPaintDelegate); _paletteCheckBoxImages = new PaletteRedirectCheckBox(Redirector, Images); StateCommon = new PaletteListStateRedirect(Redirector, PaletteBackStyle.InputControlStandalone, PaletteBorderStyle.InputControlStandalone, NeedPaintDelegate); OverrideFocus = new PaletteListItemTripleRedirect(Redirector, PaletteBackStyle.ButtonListItem, PaletteBorderStyle.ButtonListItem, PaletteContentStyle.ButtonListItem, NeedPaintDelegate); StateDisabled = new PaletteListState(StateCommon, NeedPaintDelegate); StateActive = new PaletteDouble(StateCommon, NeedPaintDelegate); StateNormal = new PaletteListState(StateCommon, NeedPaintDelegate); StateTracking = new PaletteListItemTriple(StateCommon.Item, NeedPaintDelegate); StatePressed = new PaletteListItemTriple(StateCommon.Item, NeedPaintDelegate); StateCheckedNormal = new PaletteListItemTriple(StateCommon.Item, NeedPaintDelegate); StateCheckedTracking = new PaletteListItemTriple(StateCommon.Item, NeedPaintDelegate); StateCheckedPressed = new PaletteListItemTriple(StateCommon.Item, NeedPaintDelegate); // Create manager and view for drawing the background ViewDrawPanel = new ViewDrawPanel(StateNormal.Back); // Create the override handling classes _overrideNormal = new PaletteTripleOverride(OverrideFocus.Item, StateNormal.Item, PaletteState.FocusOverride); _overrideTracking = new PaletteTripleOverride(OverrideFocus.Item, StateTracking.Item, PaletteState.FocusOverride); _overridePressed = new PaletteTripleOverride(OverrideFocus.Item, StatePressed.Item, PaletteState.FocusOverride); _overrideCheckedNormal = new PaletteTripleOverride(OverrideFocus.Item, StateCheckedNormal.Item, PaletteState.FocusOverride); _overrideCheckedTracking = new PaletteTripleOverride(OverrideFocus.Item, StateCheckedTracking.Item, PaletteState.FocusOverride); _overrideCheckedPressed = new PaletteTripleOverride(OverrideFocus.Item, StateCheckedPressed.Item, PaletteState.FocusOverride); // Create the check box image drawer and place inside element so it is always centered _drawCheckBox = new ViewDrawCheckBox(_paletteCheckBoxImages); _layoutCheckBox = new ViewLayoutCenter { _drawCheckBox }; _layoutCheckBoxAfter = new ViewLayoutSeparator(3, 0); _layoutCheckBoxStack = new ViewLayoutStack(true) { _layoutCheckBox, _layoutCheckBoxAfter }; // Stack used to layout the location of the node image _layoutImage = new ViewLayoutSeparator(0, 0); _layoutImageAfter = new ViewLayoutSeparator(3, 0); _layoutImageCenter = new ViewLayoutCenter(_layoutImage); _layoutImageStack = new ViewLayoutStack(true) { _layoutImageCenter, _layoutImageAfter }; _layoutImageState = new ViewLayoutSeparator(16, 16); _layoutImageCenterState = new ViewLayoutCenter(_layoutImageState); // Create the draw element for owner drawing individual items _contentValues = new ShortTextValue(); _drawButton = new ViewDrawButton(StateDisabled.Item, _overrideNormal, _overrideTracking, _overridePressed, _overrideCheckedNormal, _overrideCheckedTracking, _overrideCheckedPressed, new PaletteMetricRedirect(Redirector), _contentValues, VisualOrientation.Top, false); // Place check box on the left and the label in the remainder _layoutDockerTile = new ViewLayoutDocker { { _layoutImageStack, ViewDockStyle.Left }, { _layoutImageCenterState, ViewDockStyle.Left }, { _layoutCheckBoxStack, ViewDockStyle.Left }, { _drawButton, ViewDockStyle.Fill } }; _layoutDockerSmall = new ViewLayoutDocker { { _drawButton, ViewDockStyle.Left }, { _layoutImageStack, ViewDockStyle.Left }, { _layoutImageCenterState, ViewDockStyle.Left }, { _layoutCheckBoxStack, ViewDockStyle.Left } }; // Place check box on the left and the text to match the width _layoutDockerCheckLarge = new ViewLayoutDocker { { _layoutImageStack, ViewDockStyle.Left }, { _layoutImageCenterState, ViewDockStyle.Left }, { _layoutCheckBoxStack, ViewDockStyle.Left }, { _drawButton, ViewDockStyle.Bottom } }; // Create the element that fills the remainder space and remembers fill rectangle _layoutFill = new ViewLayoutFill(this) { DisplayPadding = new Padding(1) }; // Create inner view for placing inside the drawing docker _drawDockerInner = new ViewLayoutDocker { { _layoutFill, ViewDockStyle.Fill } }; // Create view for the control border and background _drawDockerOuter = new ViewDrawDocker(StateNormal.Back, StateNormal.Border) { { _drawDockerInner, ViewDockStyle.Fill } }; // Create the view manager instance ViewManager = new ViewManager(this, _drawDockerOuter); // We need to create and cache a device context compatible with the display _screenDC = PI.CreateCompatibleDC(IntPtr.Zero); StateCommon.Item.Content.ShortText.MultiLine = InheritBool.True; StateCommon.Item.Content.ShortText.MultiLineH = PaletteRelativeAlign.Center; StateCommon.Item.Content.ShortText.TextH = PaletteRelativeAlign.Center; }