/// <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; } }
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; _checkButton = 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 _checkButton.SetPaletteRedirect(provider.ProviderRedirector); // Create the view button instance _drawButton = 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 _drawButton.SetCheckedPalettes(checkButton.OverrideCheckedNormal, checkButton.OverrideCheckedTracking, checkButton.OverrideCheckedPressed); _drawButton.Enabled = _itemEnabled; _drawButton.Checked = ResolveChecked; // Place the check box on the left of the available space but inside separators _innerDocker = new ViewLayoutDocker(); _innerDocker.Add(_drawButton, ViewDockStyle.Fill); _innerDocker.Add(new ViewLayoutSeparator(1), ViewDockStyle.Right); _innerDocker.Add(new ViewLayoutSeparator(1), 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 check box controller MenuCheckButtonController mcbc = new MenuCheckButtonController(provider.ProviderViewManager, _innerDocker, this, provider.ProviderNeedPaintDelegate); mcbc.Click += new EventHandler(OnClick); _innerDocker.MouseController = mcbc; _innerDocker.KeyController = mcbc; // Add docker as the composite content Add(_outerDocker); // Want to know when a property changes whilst displayed _checkButton.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); // We need to know if a property of the command changes if (_checkButton.KryptonCommand != null) { _cachedCommand = _checkButton.KryptonCommand; _checkButton.KryptonCommand.PropertyChanged += new PropertyChangedEventHandler(OnCommandPropertyChanged); } }