/// <summary>
        ///     Calculates appropriate colors and icons for a shape's fill color.
        /// </summary>
        private static FillColorAppearance CalculateFillColorAppearance(Color fillColor)
        {
            var hslColor = HslColor.FromRgbColor(fillColor);

            return(new FillColorAppearance
            {
                TextColor = GetTextColor(fillColor),
                OutlineColor
                    = new HslColor
                    {
                        Hue = hslColor.Hue,
                        Saturation = hslColor.Saturation * 3 / 5,
                        Luminosity = GetHighlightLuminosity(hslColor.Luminosity)
                    }.ToRgbColor(),
#if VS12ORNEWER
                EntityGlyph = ThemeUtils.GetThemedButtonImage(EntityGlyph, fillColor),
                BaseTypeIcon = ThemeUtils.GetThemedButtonImage(BaseTypeIcon, fillColor),
                ChevronExpanded = ThemeUtils.GetThemedButtonImage(ChevronExpanded, fillColor),
                ChevronCollapsed = ThemeUtils.GetThemedButtonImage(ChevronCollapsed, fillColor)
#else
                // avoid icon inversion in VS11 because it causes unclear images on light backgrounds
                EntityGlyph = EntityGlyph,
                BaseTypeIcon = BaseTypeIcon,
                ChevronExpanded = ChevronExpanded,
                ChevronCollapsed = ChevronCollapsed
#endif
            });
        private Panel CreatePanel(
            int left,
            int top,
            int width,
            int height,
            string imageResourceName,
            string accessibleName,
            string accessibleDescription,
            EventHandler mouseClickHandler     = null,
            MouseEventHandler mouseDownHandler = null)
        {
            // Create a new panel to draw the image on
            var panel = new Panel
            {
                Left   = left,
                Top    = top,
                Height = height,
                Width  = width,
                Anchor = AnchorStyles.Bottom | AnchorStyles.Right
            };

            Debug.Assert(imageResourceName != null, "imageResourceName != null");
            var bitmap     = new Bitmap(GetType(), imageResourceName);
            var pictureBox = new PictureBox
            {
                AccessibleName        = accessibleName,
                AccessibleDescription = accessibleDescription,
                AccessibleRole        = AccessibleRole.PushButton
            };

            _themeChangedActions.Add(
                ()
                => pictureBox.Image
                    = ThemeUtils.GetThemedButtonImage(
                          bitmap,
                          EnvironmentColors.ScrollBarBackgroundColorKey));

            if (mouseClickHandler != null)
            {
                pictureBox.Click += mouseClickHandler;
            }

            if (mouseDownHandler != null)
            {
                pictureBox.MouseDown += mouseDownHandler;
            }

            _toolTip.SetToolTip(pictureBox, accessibleDescription);

            panel.Controls.Add(pictureBox);
            panel.BringToFront();
            return(panel);
        }
        private Bitmap GetNotificationBitmap(RuntimeConfigState state)
        {
            Bitmap bitmap;

            switch (state)
            {
            case RuntimeConfigState.Normal:
                bitmap = Resources.Information;
                break;

            case RuntimeConfigState.Error:
                bitmap = Resources.Error;
                break;

            default:
                return(null);
            }
            return(ThemeUtils.GetThemedButtonImage(bitmap, BackColor));
        }