private void OnClick(object sender, EventArgs e) => KryptonContextMenuCheckButton.PerformClick();
/// <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(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; } }