Inheritance: GlobalId, IMouseController, IKeyController, ISourceController, IContextMenuTarget
Esempio n. 1
0
        /// <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 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);
            }
        }