Пример #1
0
        /// <summary>
        /// Perform drawing of a drop down button.
        /// </summary>
        /// <param name="context">Render context.</param>
        /// <param name="displayRect">Display area available for drawing.</param>
        /// <param name="palette">Palette for sourcing display values.</param>
        /// <param name="state">State for which image size is needed.</param>
        /// <param name="orientation">How to orientate the image.</param>
        public override void DrawDropDownButton(RenderContext context,
                                                Rectangle displayRect,
                                                IPalette palette,
                                                PaletteState state,
                                                VisualOrientation orientation)
        {
            Debug.Assert(context != null);
            Debug.Assert(palette != null);

            // Validate parameter references
            if (context == null) throw new ArgumentNullException("context");
            if (palette == null) throw new ArgumentNullException("palette");

            // Grab an image appropriate to the state
            Image drawImage = palette.GetDropDownButtonImage(state);
            if (drawImage != null)
                DrawImageHelper(context, drawImage, Color.Empty,
                                displayRect, orientation, PaletteImageEffect.Normal,
                                Color.Empty, Color.Empty);
        }
Пример #2
0
        /// <summary>
        /// Calculate the requested display size for the drop down button.
        /// </summary>
        /// <param name="context">Render context.</param>
        /// <param name="palette">Palette for sourcing display values.</param>
        /// <param name="state">State for which image size is needed.</param>
        /// <param name="orientation">How to orientate the image.</param>
        public override Size GetDropDownButtonPreferredSize(ViewLayoutContext context,
                                                            IPalette palette,
                                                            PaletteState state,
                                                            VisualOrientation orientation)
        {
            // Grab an image appropriate to the state
            Image drawImage = palette.GetDropDownButtonImage(state);

            // Get the image defined size
            Size imageSize = Size.Empty;
            if (drawImage != null)
                imageSize = drawImage.Size;

            // Alter size for different orientations
            if ((orientation == VisualOrientation.Left) ||
                (orientation == VisualOrientation.Right))
            {
                // Switch dimensions to reflect rotation of 90 or 270 degrees
                imageSize = new Size(imageSize.Height, imageSize.Width);
            }

            return imageSize;
        }