View element that can draw a content
Inheritance: ViewLeaf
        /// <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 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;
            _linkLabel = 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);
            _drawContent.UseMnemonic = true;
            _drawContent.Enabled = _itemEnabled;

            // Place label link in the center of the area but inside some separator to add spacing
            _innerDocker = new ViewLayoutDocker();
            _innerDocker.Add(_drawContent, 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 link label controller
            MenuLinkLabelController mllc = new MenuLinkLabelController(provider.ProviderViewManager, _drawContent, this, provider.ProviderNeedPaintDelegate);
            mllc.Click += new EventHandler(OnClick);
            _drawContent.MouseController = mllc;
            _drawContent.KeyController = mllc;

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

            // Want to know when a property changes whilst displayed
            _linkLabel.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged);

            // We need to know if a property of the command changes
            if (_linkLabel.KryptonCommand != null)
            {
                _cachedCommand = _linkLabel.KryptonCommand;
                _linkLabel.KryptonCommand.PropertyChanged += new PropertyChangedEventHandler(OnCommandPropertyChanged);
            }
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonKeyTip class.
        /// </summary>
        /// <param name="keyTipInfo">Key tip information to display.</param>
        /// <param name="paletteBack">Background palette for appearance.</param>
        /// <param name="paletteBorder">Border palette for appearance.</param>
        /// <param name="paletteContent">Content palette for appearance.</param>
        public ViewDrawRibbonKeyTip(KeyTipInfo keyTipInfo,
                                    IPaletteBack paletteBack,
                                    IPaletteBorder paletteBorder,
                                    IPaletteContent paletteContent)
            : base(paletteBack, paletteBorder)
        {
            _keyTipInfo = keyTipInfo;

            // Create view for the key tip text
            _drawContent = new ViewDrawContent(paletteContent, this, VisualOrientation.Top);

            // Add content as filler for ourself
            Add(_drawContent, ViewDockStyle.Fill);
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonAppMenuRecentDec class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon instance.</param>
        /// <param name="provider">Provider of context menu information.</param>
        /// <param name="recentDoc">Source rencent document instance.</param>
        /// <param name="maxWidth">Maximum width allowed for the item.</param>
        /// <param name="needPaintDelegate">Delegate for requesting paint updates.</param>
        /// <param name="index">Recent documet index.</param>
        public ViewDrawRibbonAppMenuRecentDec(KryptonRibbon ribbon,
                                              IContextMenuProvider provider,
                                              KryptonRibbonRecentDoc recentDoc,
                                              int maxWidth,
                                              NeedPaintHandler needPaintDelegate,
                                              int index)
            : base(provider.ProviderStateNormal.ItemHighlight.Back,
                   provider.ProviderStateNormal.ItemHighlight.Border,
                   provider.ProviderStateNormal.ItemHighlight,
                   PaletteMetricPadding.ContextMenuItemHighlight,
                   VisualOrientation.Top)
        {
            _maxWidth = maxWidth;
            _provider = provider;
            _recentDoc = recentDoc;
            _shortcutText = (index < 10 ? @"&" + index.ToString() : "A");

            // Use docker to organize horizontal items
            ViewLayoutDocker docker = new ViewLayoutDocker();

            // End of line gap
            docker.Add(new ViewLayoutSeparator(5), ViewDockStyle.Right);

            // Add the text/extraText/Image entry
            FixedContentValue entryContent = new FixedContentValue(recentDoc.Text, recentDoc.ExtraText, recentDoc.Image, recentDoc.ImageTransparentColor);
            RibbonRecentDocsEntryToContent entryPalette = new RibbonRecentDocsEntryToContent(ribbon.StateCommon.RibbonGeneral, ribbon.StateCommon.RibbonAppMenuDocsEntry);
            ViewDrawContent entryDraw = new ViewDrawContent(entryPalette, entryContent, VisualOrientation.Top);
            docker.Add(entryDraw, ViewDockStyle.Fill);

            // Shortcut to Content gap
            docker.Add(new ViewLayoutSeparator(5), ViewDockStyle.Left);

            // Add the shortcut column
            FixedContentValue shortcutContent = new FixedContentValue(_shortcutText, null, null, Color.Empty);
            RibbonRecentDocsShortcutToContent shortcutPalette = new RibbonRecentDocsShortcutToContent(ribbon.StateCommon.RibbonGeneral, ribbon.StateCommon.RibbonAppMenuDocsEntry);
            ViewDrawRibbonRecentShortcut shortcutDraw = new ViewDrawRibbonRecentShortcut(shortcutPalette, shortcutContent);
            docker.Add(shortcutDraw, ViewDockStyle.Left);

            // Start of line gap
            docker.Add(new ViewLayoutSeparator(3), ViewDockStyle.Left);

            // Attach a controller so menu item can be tracked and pressed
            RecentDocController controller = new RecentDocController(_provider.ProviderViewManager, this, needPaintDelegate);
            MouseController = controller;
            KeyController = controller;
            SourceController = controller;

            Add(docker);
        }
        /// <summary>
        /// Initialize a new instance of the MenuLinkLabelController class.
        /// </summary>
        /// <param name="viewManager">Owning view manager instance.</param>
        /// <param name="target">Target for state changes.</param>
        /// <param name="linkLabel">Drawing element that owns link label display.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public MenuLinkLabelController(ViewContextMenuManager viewManager,
                                       ViewDrawContent target,
                                       ViewDrawMenuLinkLabel linkLabel,
                                       NeedPaintHandler needPaint)
        {
            Debug.Assert(viewManager != null);
            Debug.Assert(target != null);
            Debug.Assert(linkLabel != null);
            Debug.Assert(needPaint != null);

            _viewManager = viewManager;
            _target = target;
            _menuLinkLabel = linkLabel;
            NeedPaint = needPaint;
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuHeading class.
        /// </summary>
        /// <param name="heading">Reference to owning heading entry.</param>
        /// <param name="palette">Reference to palette source.</param>
        public ViewDrawMenuHeading(KryptonContextMenuHeading heading,
                                   PaletteTripleRedirect palette)
        {
            // Create fixed storage of the content values
            _contentValues = new FixedContentValue(heading.Text,
                                                   heading.ExtraText,
                                                   heading.Image,
                                                   heading.ImageTransparentColor);

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

            // Create the content for the actual heading text/image
            _drawContent = new ViewDrawContent(heading.StateNormal.Content, _contentValues, VisualOrientation.Top);

            // Use the docker to provide the background and border
            _drawDocker = new ViewDrawDocker(heading.StateNormal.Back, heading.StateNormal.Border);
            _drawDocker.Add(_drawContent, ViewDockStyle.Fill);

            // Add docker as the composite content
            Add(_drawDocker);
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonQATButton class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="qatButton">Reference to button definition.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewDrawRibbonQATButton(KryptonRibbon ribbon,
                                       IQuickAccessToolbarButton qatButton,
                                       NeedPaintHandler needPaint)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(qatButton != null);

            // Remember incoming references
            _ribbon = ribbon;
            _qatButton = qatButton;

            // If the source interface comes from a component then allow it to
            // be selected at design time by clicking on the view instance
            Component = qatButton as System.ComponentModel.Component;

            // Attach a controller to this element for the pressing of the button
            QATButtonController controller = new QATButtonController(ribbon, this, needPaint);
            controller.Click += new MouseEventHandler(OnClick);
            SourceController = controller;
            KeyController = controller;

            // Create controller for intercepting events to determine tool tip handling
            MouseController = new ToolTipController(_ribbon.TabsArea.ButtonSpecManager.ToolTipManager,
                                                    this, controller);

            // Use a class to convert from ribbon tab to content interface
            _contentProvider = new QATButtonToContent(qatButton);

            // Create and add the draw content for display inside the button
            _drawContent = new ViewDrawContent(_contentProvider, this, VisualOrientation.Top);
            Add(_drawContent);

            // Need to notice when the ribbon enable state changes
            _ribbon.EnabledChanged += new EventHandler(OnRibbonEnableChanged);

            // Set the initial enabled state
            UpdateEnabled();
        }
示例#8
0
        /// <summary>
        /// Initialize a new instance of the KryptonLinkLabel class.
        /// </summary>
        public KryptonLinkLabel()
        {
            // The link label cannot take the focus
            SetStyle(ControlStyles.Selectable, true);

            // Turn off the target functionality present in the base class
            EnabledTarget = false;

            // Create the override states that redirect without inheriting
            _stateVisitedRedirect    = new PaletteContentInheritRedirect(Redirector, PaletteContentStyle.LabelNormalControl);
            _stateNotVisitedRedirect = new PaletteContentInheritRedirect(Redirector, PaletteContentStyle.LabelNormalControl);
            _statePressedRedirect    = new PaletteContentInheritRedirect(Redirector, PaletteContentStyle.LabelNormalControl);
            _stateFocusRedirect      = new PaletteContentInheritRedirect(Redirector, PaletteContentStyle.LabelNormalControl);
            OverrideVisited          = new PaletteContent(_stateVisitedRedirect, NeedPaintDelegate);
            OverrideNotVisited       = new PaletteContent(_stateNotVisitedRedirect, NeedPaintDelegate);
            OverrideFocus            = new PaletteContent(_stateFocusRedirect, NeedPaintDelegate);
            OverridePressed          = new PaletteContent(_statePressedRedirect, NeedPaintDelegate);

            // Override the normal state to implement the underling logic
            _inheritBehavior = new LinkLabelBehaviorInherit(StateNormal, KryptonLinkBehavior.AlwaysUnderline);

            // Create the override handling classes
            _overrideVisited         = new PaletteContentInheritOverride(OverrideVisited, _inheritBehavior, PaletteState.LinkVisitedOverride, false);
            _overrideNotVisited      = new PaletteContentInheritOverride(OverrideNotVisited, _overrideVisited, PaletteState.LinkNotVisitedOverride, true);
            _overrideFocusNotVisited = new PaletteContentInheritOverride(OverrideFocus, _overrideNotVisited, PaletteState.FocusOverride, false);
            _overridePressed         = new PaletteContentInheritOverride(OverridePressed, _inheritBehavior, PaletteState.LinkPressedOverride, false);
            _overridePressedFocus    = new PaletteContentInheritOverride(OverrideFocus, _overridePressed, PaletteState.FocusOverride, false);

            // Create controller for updating the view state/click events
            _controller        = new LinkLabelController(ViewDrawContent, StateDisabled, _overrideFocusNotVisited, _overrideFocusNotVisited, _overridePressedFocus, _overridePressed, NeedPaintDelegate);
            _controller.Click += OnControllerClick;
            ViewDrawContent.MouseController  = _controller;
            ViewDrawContent.KeyController    = _controller;
            ViewDrawContent.SourceController = _controller;

            // Set initial palette for drawing the content
            ViewDrawContent.SetPalette(_overrideFocusNotVisited);
        }
        /// <summary>
        /// Discover the preferred size of the element.
        /// </summary>
        /// <param name="context">Layout context.</param>
        public override Size GetPreferredSize(ViewLayoutContext context)
        {
            Debug.Assert(context != null);

            // Update text and image values
            _contentValues.ShortText             = ResolveText;
            _contentValues.LongText              = ResolveExtraText;
            _contentValues.Image                 = ResolveImage;
            _contentValues.ImageTransparentColor = ResolveImageTransparentColor;

            // Find new enabled state
            ItemEnabled = _provider.ProviderEnabled && ResolveEnabled;

            // Update with enabled state
            ViewDrawContent.SetPalette(ItemEnabled ? KryptonContextMenuCheckBox.OverrideNormal : KryptonContextMenuCheckBox.OverrideDisabled);
            ViewDrawContent.Enabled  = ItemEnabled;
            ViewDrawCheckBox.Enabled = ItemEnabled;

            // Update the checked state
            ViewDrawCheckBox.CheckState = ResolveCheckState;

            return(base.GetPreferredSize(context));
        }
示例#10
0
        /// <summary>
        /// Initialize a new instance of the KryptonLabel class.
        /// </summary>
        public KryptonLabel()
        {
            // The label cannot take the focus
            SetStyle(ControlStyles.Selectable, false);

            // Set default properties
            _style        = LabelStyle.NormalControl;
            _useMnemonic  = true;
            _orientation  = VisualOrientation.Top;
            _target       = null;
            EnabledTarget = true;

            // Create content storage
            Values              = new LabelValues(NeedPaintDelegate);
            Values.TextChanged += OnLabelTextChanged;

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

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

            // Our view contains background and border with content inside
            _drawContent = new ViewDrawContent(StateNormal, this, VisualOrientation.Top)
            {
                UseMnemonic = _useMnemonic
            };

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

            // 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 LinkLabelController class.
        /// </summary>
        /// <param name="target">Target for state changes.</param>
        /// <param name="paletteDisabled">Palette to use in the disabled state.</param>
        /// <param name="paletteNormal">Palette to use in the normal state.</param>
        /// <param name="paletteTracking">Palette to use in the tracking state.</param>
        /// <param name="palettePressed">Palette to use in the pressed state.</param>
        /// <param name="pressed">Override to update with the pressed state.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public LinkLabelController(ViewDrawContent target,
                                   IPaletteContent paletteDisabled,
                                   IPaletteContent paletteNormal,
                                   IPaletteContent paletteTracking,
                                   IPaletteContent palettePressed,
                                   PaletteContentInheritOverride pressed,
                                   NeedPaintHandler needPaint)
        {
            Debug.Assert(target != null);

            // Store the provided paint notification delegate
            NeedPaint = needPaint;

            // Remember target for state changes
            _target          = target;
            _paletteDisabled = paletteDisabled;
            _paletteNormal   = paletteNormal;
            _paletteTracking = paletteTracking;
            _palettePressed  = palettePressed;
            _pressed         = pressed;

            // Default other properties
            _clickTime = new DateTime();
        }
        /// <summary>
        /// Initialize a new instance of the VisualPopupTooltip class.
        /// </summary>
        /// <param name="redirector">Redirector for recovering palette values.</param>
        /// <param name="contentValues">Source of content values.</param>
        /// <param name="renderer">Drawing renderer.</param>
        /// <param name="backStyle">Style for the tooltip background.</param>
        /// <param name="borderStyle">Style for the tooltip border.</param>
        /// <param name="contentStyle">Style for the tooltip content.</param>
        public VisualPopupToolTip(PaletteRedirect redirector,
                                  IContentValues contentValues,
                                  IRenderer renderer,
                                  PaletteBackStyle backStyle,
                                  PaletteBorderStyle borderStyle,
                                  PaletteContentStyle contentStyle)
            : base(renderer, true)
        {
            Debug.Assert(contentValues != null);

            // Remember references needed later
            _contentValues = contentValues;

            // Create the triple redirector needed by view elements
            _palette = new PaletteTripleMetricRedirect(redirector, backStyle, borderStyle, contentStyle, NeedPaintDelegate);

            // Our view contains background and border with content inside
            _drawDocker  = new ViewDrawDocker(_palette.Back, _palette.Border, null);
            _drawContent = new ViewDrawContent(_palette.Content, _contentValues, VisualOrientation.Top);
            _drawDocker.Add(_drawContent, ViewDockStyle.Fill);

            // Create the view manager instance
            ViewManager = new ViewManager(this, _drawDocker);
        }
示例#13
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuHeading class.
        /// </summary>
        /// <param name="heading">Reference to owning heading entry.</param>
        /// <param name="palette">Reference to palette source.</param>
        public ViewDrawMenuHeading(KryptonContextMenuHeading heading,
                                   PaletteTripleRedirect palette)
        {
            // Create fixed storage of the content values
            _contentValues = new FixedContentValue(heading.Text,
                                                   heading.ExtraText,
                                                   heading.Image,
                                                   heading.ImageTransparentColor);

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

            // Create the content for the actual heading text/image
            _drawContent = new ViewDrawContent(heading.StateNormal.Content, _contentValues, VisualOrientation.Top);

            // Use the docker to provide the background and border
            _drawDocker = new ViewDrawDocker(heading.StateNormal.Back, heading.StateNormal.Border)
            {
                { _drawContent, ViewDockStyle.Fill }
            };

            // Add docker as the composite content
            Add(_drawDocker);
        }
示例#14
0
        /// <summary>
        /// Initialize a new instance of the LinkLabelController class.
        /// </summary>
        /// <param name="target">Target for state changes.</param>
        /// <param name="paletteDisabled">Palette to use in the disabled state.</param>
        /// <param name="paletteNormal">Palette to use in the normal state.</param>
        /// <param name="paletteTracking">Palette to use in the tracking state.</param>
        /// <param name="palettePressed">Palette to use in the pressed state.</param>
        /// <param name="pressed">Override to update with the pressed state.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public LinkLabelController(ViewDrawContent target,
                                   IPaletteContent paletteDisabled,
                                   IPaletteContent paletteNormal,
                                   IPaletteContent paletteTracking,
                                   IPaletteContent palettePressed,
                                   PaletteContentInheritOverride pressed,
                                   NeedPaintHandler needPaint)
        {
            Debug.Assert(target != null);

            // Store the provided paint notification delegate
            NeedPaint = needPaint;

            // Remember target for state changes
            _target = target;
            _paletteDisabled = paletteDisabled;
            _paletteNormal = paletteNormal;
            _paletteTracking = paletteTracking;
            _palettePressed = palettePressed;
            _pressed = pressed;

            // Default other properties
            _clickTime = new DateTime();
        }
        /// <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);
        }
        /// <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;
            }
        }
        /// <summary>
        /// Initialize a new instance of the VisualPopupTooltip class.
        /// </summary>
        /// <param name="redirector">Redirector for recovering palette values.</param>
        /// <param name="contentValues">Source of content values.</param>
        /// <param name="renderer">Drawing renderer.</param>
        /// <param name="backStyle">Style for the tooltip background.</param>
        /// <param name="borderStyle">Style for the tooltip border.</param>
        /// <param name="contentStyle">Style for the tooltip content.</param>
        public VisualPopupToolTip(PaletteRedirect redirector,
                                  IContentValues contentValues,
                                  IRenderer renderer,
                                  PaletteBackStyle backStyle,
                                  PaletteBorderStyle borderStyle,
                                  PaletteContentStyle contentStyle)
            : base(renderer, true)
        {
            Debug.Assert(contentValues != null);

            // Remember references needed later
            _contentValues = contentValues;

            // Create the triple redirector needed by view elements
            _palette = new PaletteTripleMetricRedirect(redirector, backStyle, borderStyle, contentStyle, NeedPaintDelegate);

            // Our view contains background and border with content inside
            _drawDocker = new ViewDrawDocker(_palette.Back, _palette.Border, null);
            _drawContent = new ViewDrawContent(_palette.Content, _contentValues, VisualOrientation.Top);
            _drawDocker.Add(_drawContent, ViewDockStyle.Fill);

            // Create the view manager instance
            ViewManager = new ViewManager(this, _drawDocker);
        }
示例#18
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;
            }
        }
示例#19
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;
            _paletteCurrent = _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();
            _layoutDocker.Add(_drawContent, ViewDockStyle.Fill);
            _layoutDocker.Add(_drawSplitBorder, ViewDockStyle.Right);
            _layoutDocker.Add(_drawDropDown, ViewDockStyle.Right);
            _layoutDocker.Add(_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);
        }
示例#20
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);
            _drawHeader.Add(_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 += new EventHandler(OnPrevMonth);
            _arrowNext.Click += new EventHandler(OnNextMonth);
            _buttonSpecs      = new CalendarButtonSpecCollection(this);
            _buttonSpecs.Add(_arrowPrev);
            _buttonSpecs.Add(_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();

            borderLeftDock.Add(_drawWeekNumbers, ViewDockStyle.Left);
            borderLeftDock.Add(new ViewLayoutSeparator(0, 4), ViewDockStyle.Top);
            borderLeftDock.Add(_drawBorderEdge, ViewDockStyle.Fill);
            borderLeftDock.Add(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();

            borderTopDock.Add(new ViewLayoutSeparator(4, 1), ViewDockStyle.Left);
            borderTopDock.Add(drawBorderEdge, ViewDockStyle.Fill);
            borderTopDock.Add(new ViewLayoutSeparator(4, 1), ViewDockStyle.Right);
            borderTopDock.Add(new ViewLayoutSeparator(1, 3), ViewDockStyle.Bottom);
            daysStack.Add(borderTopDock);

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

            // Adding buttons manually means we have to ask for buttons to be created
            _buttonManager.RecreateButtons();
        }
示例#21
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;
            _checkBox = 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
            _checkBox.SetPaletteRedirect(provider.ProviderRedirector);

            // Create the content for the actual heading text/image
            _drawContent = new ViewDrawContent((_itemEnabled ? (IPaletteContent)_checkBox.OverrideNormal : (IPaletteContent)_checkBox.OverrideDisabled),
                                               _contentValues, VisualOrientation.Top);
            _drawContent.UseMnemonic = true;
            _drawContent.Enabled = _itemEnabled;

            // Create the check box image drawer and place inside element so it is always centered
            _drawCheckBox = new ViewDrawCheckBox(_checkBox.StateCheckBoxImages);
            _drawCheckBox.CheckState = ResolveCheckState;
            _drawCheckBox.Enabled = _itemEnabled;
            _layoutCenter = new ViewLayoutCenter();
            _layoutCenter.Add(_drawCheckBox);

            // Place the check box 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 check box controller
            MenuCheckBoxController mcbc = new MenuCheckBoxController(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
            _checkBox.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged);

            // We need to know if a property of the command changes
            if (_checkBox.KryptonCommand != null)
            {
                _cachedCommand = _checkBox.KryptonCommand;
                _checkBox.KryptonCommand.PropertyChanged += new PropertyChangedEventHandler(OnCommandPropertyChanged);
            }
        }
示例#22
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawNavRibbonTab class.
        /// </summary>
        /// <param name="navigator">Owning navigator instance.</param>
        /// <param name="page">Page this ribbon tab represents.</param>
        public ViewDrawNavRibbonTab(KryptonNavigator navigator,
                                    KryptonPage page)
        {
            Debug.Assert(navigator != null);
            Debug.Assert(page != null);

            _navigator = navigator;
            _page = page;
            _lastClick = DateTime.Now.AddDays(-1);

            // Associate the page component with this view element
            Component = page;

            // Create a controller for managing button behavior
            _buttonController = new PageButtonController(this, new NeedPaintHandler(OnNeedPaint));
            _buttonController.ClickOnDown = true;
            _buttonController.Click += new MouseEventHandler(OnClick);
            _buttonController.RightClick += new MouseEventHandler(OnRightClick);

            // Allow the page to be dragged and hook into drag events
            _buttonController.AllowDragging = true;
            _buttonController.DragStart += new EventHandler<DragStartEventCancelArgs>(OnDragStart);
            _buttonController.DragMove += new EventHandler<PointEventArgs>(OnDragMove);
            _buttonController.DragEnd += new EventHandler<PointEventArgs>(OnDragEnd);
            _buttonController.DragQuit += new EventHandler(OnDragQuit);
            _buttonController.ButtonDragRectangle += new EventHandler<ButtonDragRectangleEventArgs>(OnButtonDragRectangle);
            _buttonController.ButtonDragOffset += new EventHandler<ButtonDragOffsetEventArgs>(OnButtonDragOffset);

            // A tab is selected on being pressed and not on the mouse up
            _buttonController.ClickOnDown = true;

            // We need to be notified of got/lost focus and keyboard events
            SourceController = _buttonController;
            KeyController = _buttonController;

            // Create a decorator to interface with the tooltip manager
            ToolTipController toolTipController = new ToolTipController(_navigator.ToolTipManager, this, _buttonController);
            ToolTipController hoverController = new ToolTipController(_navigator.HoverManager, this, toolTipController);

            // Assign controller for handing mouse input
            MouseController = hoverController;

            // Create overrides for handling a focus state
            _paletteGeneral = _navigator.StateCommon.RibbonGeneral;
            _overrideStateNormal = new PaletteRibbonTabContentInheritOverride(_page.OverrideFocus.RibbonTab.TabDraw, _page.OverrideFocus.RibbonTab.TabDraw, _page.OverrideFocus.RibbonTab.Content, _page.StateNormal.RibbonTab.TabDraw, _page.StateNormal.RibbonTab.TabDraw, _page.StateNormal.RibbonTab.Content, PaletteState.FocusOverride);
            _overrideStateTracking = new PaletteRibbonTabContentInheritOverride(_page.OverrideFocus.RibbonTab.TabDraw, _page.OverrideFocus.RibbonTab.TabDraw, _page.OverrideFocus.RibbonTab.Content, _page.StateTracking.RibbonTab.TabDraw, _page.StateTracking.RibbonTab.TabDraw, _page.StateTracking.RibbonTab.Content, PaletteState.FocusOverride);
            _overrideStatePressed = new PaletteRibbonTabContentInheritOverride(_page.OverrideFocus.RibbonTab.TabDraw, _page.OverrideFocus.RibbonTab.TabDraw, _page.OverrideFocus.RibbonTab.Content, _page.StatePressed.RibbonTab.TabDraw, _page.StatePressed.RibbonTab.TabDraw, _page.StatePressed.RibbonTab.Content, PaletteState.FocusOverride);
            _overrideStateSelected = new PaletteRibbonTabContentInheritOverride(_page.OverrideFocus.RibbonTab.TabDraw, _page.OverrideFocus.RibbonTab.TabDraw, _page.OverrideFocus.RibbonTab.Content, _page.StateSelected.RibbonTab.TabDraw, _page.StateSelected.RibbonTab.TabDraw, _page.StateSelected.RibbonTab.Content, PaletteState.FocusOverride);

            // Use a class to convert from ribbon tab to content interface
            _contentProvider = new RibbonTabToContent(_paletteGeneral, _overrideStateNormal, _overrideStateNormal);

            // Create the content view element and use the content provider as a way to
            // convert from the ribbon palette entries to the content palette entries
            _viewContent = new ViewDrawContent(_contentProvider, this, VisualOrientation.Top);

            // Add content to the view
            _layoutDocker = new ViewLayoutDocker();
            _layoutDocker.Add(_viewContent, ViewDockStyle.Fill);
            Add(_layoutDocker);

            // Create button specification collection manager
            _buttonManager = new ButtonSpecNavManagerLayoutBar(Navigator, Navigator.InternalRedirector, Page.ButtonSpecs, null,
                                                               new ViewLayoutDocker[] { _layoutDocker },
                                                               new IPaletteMetric[] { Navigator.StateCommon },
                                                               new PaletteMetricInt[] { PaletteMetricInt.PageButtonInset },
                                                               new PaletteMetricInt[] { PaletteMetricInt.PageButtonInset },
                                                               new PaletteMetricPadding[] { PaletteMetricPadding.PageButtonPadding },
                                                               new GetToolStripRenderer(Navigator.CreateToolStripRenderer),
                                                               new NeedPaintHandler(OnNeedPaint));

            // Hook up the tooltip manager so that tooltips can be generated
            _buttonManager.ToolTipManager = Navigator.ToolTipManager;
            _buttonManager.RemapTarget = ButtonSpecNavRemap.ButtonSpecRemapTarget.ButtonStandalone;

            // Ensure current button specs are created
            _buttonManager.RecreateButtons();

            // Create the state specific memento array
            _mementos = new IDisposable[Enum.GetValues(typeof(PaletteState)).Length];

            // Cache the last shape encountered
            _lastRibbonShape = PaletteRibbonShape.Office2010;
        }
        /// <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;
            }
        }
示例#24
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;
            _menuItem = menuItem;
            _imageColumn = imageColumn;
            _standardStyle = standardStyle;

            // Give the item object the redirector to use when inheriting values
            _menuItem.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 ? _menuItem.StateNormal : _menuItem.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 ? _menuItem.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);
            _imageCanvas.Add(_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 (_menuItem.ShowShortcutKeys)
            {
                string shortcutString = _menuItem.ShortcutKeyDisplayString;
                if (string.IsNullOrEmpty(shortcutString))
                    shortcutString = (_menuItem.ShortcutKeys != Keys.None) ? new KeysConverter().ConvertToString(_menuItem.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 = (_menuItem.Items.Count > 0) && _menuItem.SplitSubMenu;

            // SubMenu Indicator
            _hasSubMenu = (_menuItem.Items.Count > 0);
            _subMenuContent = new ViewDrawMenuItemContent(menuItemState.ItemImage.Content, new FixedContentValue(null, null, (!_hasSubMenu ? _empty16x16 : provider.ProviderImages.GetContextMenuSubMenuImage()), (_menuItem.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
            _menuItem.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged);

            // We need to know if a property of the command changes
            if (_menuItem.KryptonCommand != null)
            {
                _cachedCommand = _menuItem.KryptonCommand;
                _menuItem.KryptonCommand.PropertyChanged += new PropertyChangedEventHandler(OnCommandPropertyChanged);
            }
        }
示例#25
0
        /// <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.NormalControl;
            _orientation = VisualOrientation.Top;
            _checkPosition = VisualOrientation.Left;
            _checked = false;
            _threeState = false;
            _checkState = CheckState.Unchecked;
            _useMnemonic = true;
            _autoCheck = true;

            // Create content storage
            _labelValues = new LabelValues(NeedPaintDelegate);
            _labelValues.TextChanged += new EventHandler(OnCheckBoxTextChanged);
            _images = new CheckBoxImages(NeedPaintDelegate);

            // Create palette redirector
            _paletteCommonRedirect = new PaletteContentInheritRedirect(Redirector, PaletteContentStyle.LabelNormalControl);
            _paletteCheckBoxImages = new PaletteRedirectCheckBox(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, this, 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
            _drawCheckBox = new ViewDrawCheckBox(_paletteCheckBoxImages);
            _drawCheckBox.CheckState = _checkState;
            _layoutCenter = new ViewLayoutCenter();
            _layoutCenter.Add(_drawCheckBox);

            // 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 CheckBoxController(_drawCheckBox, _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;
        }
        /// <summary>
        /// Create the view hierarchy for this view mode.
        /// </summary>
        protected override void CreateCheckItemView()
        {
            // Create the two headers and header content
            _viewContentPrimary = new ViewDrawContent(Navigator.StateNormal.HeaderGroup.HeaderPrimary.Content,
                                                      Navigator.Header.HeaderValuesPrimary,
                                                      VisualOrientation.Top);

            _viewHeadingPrimary = new ViewDrawDocker(Navigator.StateNormal.HeaderGroup.HeaderPrimary.Back,
                                                     Navigator.StateNormal.HeaderGroup.HeaderPrimary.Border,
                                                     Navigator.StateNormal.HeaderGroup.HeaderPrimary,
                                                     PaletteMetricBool.None,
                                                     PaletteMetricPadding.HeaderGroupPaddingPrimary,
                                                     VisualOrientation.Top);

            _viewContentSecondary = new ViewDrawContent(Navigator.StateNormal.HeaderGroup.HeaderSecondary.Content,
                                                        Navigator.Header.HeaderValuesSecondary,
                                                        VisualOrientation.Top);

            _viewHeadingSecondary = new ViewDrawDocker(Navigator.StateNormal.HeaderGroup.HeaderSecondary.Back,
                                                       Navigator.StateNormal.HeaderGroup.HeaderSecondary.Border,
                                                       Navigator.StateNormal.HeaderGroup.HeaderSecondary,
                                                       PaletteMetricBool.None,
                                                       PaletteMetricPadding.HeaderGroupPaddingSecondary,
                                                       VisualOrientation.Top);

            // Place the the content as fillers in the headers
            _viewHeadingPrimary.Add(_viewContentPrimary, ViewDockStyle.Fill);
            _viewHeadingSecondary.Add(_viewContentSecondary, ViewDockStyle.Fill);

            // Create a canvas for containing the selected page and put old root inside it
            _drawGroup = new ViewDrawCanvas(Navigator.StateNormal.HeaderGroup.Back,
                                            Navigator.StateNormal.HeaderGroup.Border,
                                            VisualOrientation.Top);

            _drawGroup.ApplyIncludeBorderEdge = true;
            _drawGroup.Add(_oldRoot);

            // Create the view element that lays out the check/tab buttons
            ViewLayoutBarForTabs layoutBar = new ViewLayoutBarForTabs(Navigator.Bar.ItemSizing,
                                                                      Navigator.Bar.ItemAlignment,
                                                                      Navigator.Bar.BarMultiline,
                                                                      Navigator.Bar.ItemMinimumSize,
                                                                      Navigator.Bar.ItemMaximumSize,
                                                                      Navigator.Bar.BarMinimumHeight,
                                                                      Navigator.Bar.TabBorderStyle,
                                                                      true);
            _layoutBar = layoutBar;

            // Create the scroll spacer that restricts display
            _layoutBarViewport = new ViewLayoutViewport(Navigator.StateCommon.Bar,
                                                        PaletteMetricPadding.BarPaddingTabs,
                                                        PaletteMetricInt.CheckButtonGap,
                                                        Navigator.Bar.BarOrientation,
                                                        Navigator.Bar.ItemAlignment,
                                                        Navigator.Bar.BarAnimation);
            _layoutBarViewport.Add(_layoutBar);

            // Create the button bar area docker
            _layoutBarDocker = new ViewLayoutDocker();
            _layoutBarDocker.Add(_layoutBarViewport, ViewDockStyle.Fill);

            // Add a separators for insetting items
            _layoutBarSeparatorFirst = new ViewLayoutSeparator(0);
            _layoutBarSeparatorLast = new ViewLayoutSeparator(0);
            _layoutBarDocker.Add(_layoutBarSeparatorFirst, ViewDockStyle.Left);
            _layoutBarDocker.Add(_layoutBarSeparatorLast, ViewDockStyle.Right);

            // Create the layout that insets the contents to allow for rounding of the group border
            _layoutOverlap = new ViewLayoutInsetOverlap(_drawGroup);
            _layoutOverlap.Add(_layoutBarDocker);

            // Create the docker used to layout contents of main panel and fill with group
            _layoutPanelDocker = new ViewLayoutDockerOverlap(_drawGroup, _layoutOverlap, layoutBar);
            _layoutPanelDocker.Add(_layoutOverlap, ViewDockStyle.Top);
            _layoutPanelDocker.Add(_drawGroup, ViewDockStyle.Fill);

            // Place the headers and page holding area into the group
            _topGroup = new ViewLayoutDocker();
            _topGroup.Add(_viewHeadingSecondary, ViewDockStyle.Bottom);
            _topGroup.Add(_viewHeadingPrimary, ViewDockStyle.Top);
            _topGroup.Add(_layoutPanelDocker, ViewDockStyle.Fill);

            // Prevent adjacent headers from having two borders
            _topGroup.RemoveChildBorders = true;

            // Create the top level panel and put a layout docker inside it
            _drawPanel = new ViewDrawPanel(Navigator.StateNormal.Back);
            _drawPanel.Add(_topGroup);
            _newRoot = _drawPanel;

            // Set initial visible state of headers
            _viewHeadingPrimary.Visible = Navigator.Header.HeaderVisiblePrimary;
            _viewHeadingSecondary.Visible = Navigator.Header.HeaderVisibleSecondary;

            // Set the correct tab style
            UpdateTabStyle();

            // Must call the base class to perform common actions
            base.CreateCheckItemView();
        }
示例#27
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;
            _paletteCurrent         = _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();
            _layoutDocker.Add(_drawContent, ViewDockStyle.Fill);
            _layoutDocker.Add(_drawSplitBorder, ViewDockStyle.Right);
            _layoutDocker.Add(_drawDropDown, ViewDockStyle.Right);
            _layoutDocker.Add(_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);
        }
        /// <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;
        }
        private void CreateHeaderGroupView(ViewBase filler)
        {
            // Create the top level group view
            _viewGroup = new ViewDrawDocker(Navigator.StateNormal.HeaderGroup.Back,
                                            Navigator.StateNormal.HeaderGroup.Border,
                                            Navigator.StateNormal.HeaderGroup,
                                            PaletteMetricBool.HeaderGroupOverlay);

            // Create the two headers and header content
            _viewContentPrimary = new ViewDrawContent(Navigator.StateNormal.HeaderGroup.HeaderPrimary.Content,
                                                      GetPrimaryValues(),
                                                      VisualOrientation.Top);

            _viewHeadingPrimary = new ViewDrawDocker(Navigator.StateNormal.HeaderGroup.HeaderPrimary.Back,
                                                     Navigator.StateNormal.HeaderGroup.HeaderPrimary.Border,
                                                     Navigator.StateNormal.HeaderGroup.HeaderPrimary,
                                                     PaletteMetricBool.None,
                                                     PaletteMetricPadding.HeaderGroupPaddingPrimary,
                                                     VisualOrientation.Top);

            _viewContentSecondary = new ViewDrawContent(Navigator.StateNormal.HeaderGroup.HeaderSecondary.Content,
                                                        GetSecondaryValues(),
                                                        VisualOrientation.Top);

            _viewHeadingSecondary = new ViewDrawDocker(Navigator.StateNormal.HeaderGroup.HeaderSecondary.Back,
                                                       Navigator.StateNormal.HeaderGroup.HeaderSecondary.Border,
                                                       Navigator.StateNormal.HeaderGroup.HeaderSecondary,
                                                       PaletteMetricBool.None,
                                                       PaletteMetricPadding.HeaderGroupPaddingSecondary,
                                                       VisualOrientation.Top);

            // Place the the content as fillers in the headers
            _viewHeadingPrimary.Add(_viewContentPrimary, ViewDockStyle.Fill);
            _viewHeadingSecondary.Add(_viewContentSecondary, ViewDockStyle.Fill);

            // Place the headers and page holding area into the group
            _viewGroup.Add(_viewHeadingSecondary, ViewDockStyle.Bottom);
            _viewGroup.Add(_viewHeadingPrimary, ViewDockStyle.Top);
            _viewGroup.Add(filler, ViewDockStyle.Fill);

            // Prevent adjacent headers from having two borders
            _viewGroup.RemoveChildBorders = true;

            // Set initial visible state of headers
            _viewHeadingPrimary.Visible = Navigator.Header.HeaderVisiblePrimary;
            _viewHeadingSecondary.Visible = GetHeaderSecondaryVisible();
        }
 private void SetHeaderPosition(ViewDrawCanvas canvas,
                                ViewDrawContent content,
                                VisualOrientation position)
 {
     switch (position)
     {
         case VisualOrientation.Top:
             _topGroup.SetDock(canvas, ViewDockStyle.Top);
             canvas.Orientation = VisualOrientation.Top;
             content.Orientation = VisualOrientation.Top;
             break;
         case VisualOrientation.Bottom:
             _topGroup.SetDock(canvas, ViewDockStyle.Bottom);
             canvas.Orientation = VisualOrientation.Top;
             content.Orientation = VisualOrientation.Top;
             break;
         case VisualOrientation.Left:
             _topGroup.SetDock(canvas, ViewDockStyle.Left);
             canvas.Orientation = VisualOrientation.Left;
             content.Orientation = VisualOrientation.Left;
             break;
         case VisualOrientation.Right:
             _topGroup.SetDock(canvas, ViewDockStyle.Right);
             canvas.Orientation = VisualOrientation.Right;
             content.Orientation = VisualOrientation.Right;
             break;
     }
 }
        /// <summary>
        /// Returns a view appropriate for this item based on the object it is inside.
        /// </summary>
        /// <param name="provider">Provider of context menu information.</param>
        /// <param name="parent">Owning object reference.</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>
        /// <returns>ViewBase that is the root of the view hierachy being added.</returns>
        public override ViewBase GenerateView(IContextMenuProvider provider,
                                              object parent,
                                              ViewLayoutStack columns,
                                              bool standardStyle,
                                              bool imageColumn)
        {
            if (Horizontal && (parent is KryptonContextMenuItemCollection))
            {
                // Create a stack of horizontal items inside the item
                ViewLayoutDocker docker = new ViewLayoutDocker();

                // Take up same space as the image column, so separator starts close to actual text
                ViewDrawContent imageContent = new ViewDrawContent(provider.ProviderStateCommon.ItemImage.Content, new FixedContentValue(null, null, null, Color.Empty), VisualOrientation.Top);
                ViewDrawMenuImageCanvas imageCanvas = new ViewDrawMenuImageCanvas(provider.ProviderStateCommon.ItemImage.Back, provider.ProviderStateCommon.ItemImage.Border, 0, true);
                imageCanvas.Add(imageContent);
                docker.Add(new ViewLayoutCenter(imageCanvas), ViewDockStyle.Left);
                docker.Add(new ViewLayoutSeparator(1, 0), ViewDockStyle.Left);

                // Gap that matches left padding of text/extra text
                docker.Add(new ViewLayoutMenuSepGap(provider.ProviderStateCommon, standardStyle), ViewDockStyle.Left);

                // Separator Display
                ViewLayoutStack separatorStack = new ViewLayoutStack(false);
                separatorStack.Add(new ViewLayoutSeparator(1, 1));
                separatorStack.Add(new ViewDrawMenuSeparator(this, provider.ProviderStateCommon.Separator));
                separatorStack.Add(new ViewLayoutSeparator(1, 1));
                docker.Add(separatorStack, ViewDockStyle.Fill);

                return docker;
            }
            else
                return new ViewDrawMenuSeparator(this, provider.ProviderStateCommon.Separator);
        }
示例#32
0
        /// <summary>
        /// Initialize a new instance of the KryptonLabel class.
        /// </summary>
        public KryptonLabel()
        {
            // The label cannot take the focus
            SetStyle(ControlStyles.Selectable, false);

            // Set default properties
            _style = LabelStyle.NormalControl;
            _useMnemonic = true;
            _orientation = VisualOrientation.Top;
            _target = null;
            _enabledTarget = true;

            // Create content storage
            _labelValues = new LabelValues(NeedPaintDelegate);
            _labelValues.TextChanged += new EventHandler(OnLabelTextChanged);

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

            // Create the palette provider
            _stateCommon = new PaletteContent(_paletteCommonRedirect, NeedPaintDelegate);
            _stateDisabled = new PaletteContent(_stateCommon, NeedPaintDelegate);
            _stateNormal = new PaletteContent(_stateCommon, NeedPaintDelegate);

            // Our view contains background and border with content inside
            _drawContent = new ViewDrawContent(_stateNormal, this, VisualOrientation.Top);
            _drawContent.UseMnemonic = _useMnemonic;

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

            // We want to be auto sized by default, but not the property default!
            AutoSize = true;
            AutoSizeMode = AutoSizeMode.GrowAndShrink;
        }