예제 #1
0
            public void Paint(Graphics _graphics, ref Rectangle _rectangle, PlayerSmallDisplayParams _params = null)
            {
                if (_rectangle.Width < IconSize || _rectangle.Height < IconSize)
                {
                    return;
                }
                if (!_Visible)
                {
                    return;
                }
                _params = _params ?? PlayerSmallDisplayParams.Default;

                Rect        = _rectangle;
                Rect.Width  = IconSize;
                Rect.Y     += (Rect.Height - IconSize) / 2;
                Rect.Height = IconSize;

                _rectangle.X     += IconSize;
                _rectangle.Width -= IconSize;

                float color = Enabled ? (MouseHover ? _params.ColorHovered : _params.ColorEnabled) : _params.ColorDisabled;

                float[][] colorMatrixElements =
                {
                    new float[] { color,     0,     0, 0, 0 },
                    new float[] {     0, color,     0, 0, 0 },
                    new float[] {     0,     0, color, 0, 0 },
                    new float[] {     0,     0,     0, 1, 0 }, // alpha scaling factor of 1
                    new float[] {     0,     0,     0, 0, 1 }
                };

                ColorMatrix     colorMatrix     = new ColorMatrix(colorMatrixElements);
                ImageAttributes imageAttributes = new ImageAttributes();

                imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
                _graphics.DrawImage(Image, Rect, 0, 0, Image.Width, Image.Height, GraphicsUnit.Pixel, imageAttributes);
            }
예제 #2
0
        //---------------------------------------------------------------------------------------
        public static void StaticPaint(Graphics _graphics, Rectangle R, Point _mousePos, PlayerSmallData _data, PlayerSmallDisplayParams _params = null)
        {
            if (_data == null)
            {
                return;
            }
            SmoothingMode saveMode = _graphics.SmoothingMode;

            _graphics.SmoothingMode = SmoothingMode.HighQuality;

            if (_data.ButtonPlayPause != null)
            {
                if (_data.ButtonPlayPause.MouseHover && !_data.ButtonPlayPause.Rect.Contains(_mousePos))
                {
                    _data.ButtonPlayPause.MouseHover = false;
                }
                _data.ButtonPlayPause.Paint(_graphics, ref R, _params);
            }
            if (_data.ButtonStop != null)
            {
                if (_data.ButtonStop.MouseHover && !_data.ButtonStop.Rect.Contains(_mousePos))
                {
                    _data.ButtonStop.MouseHover = false;
                }
                _data.ButtonStop.Paint(_graphics, ref R, _params);
            }
            _graphics.SmoothingMode = saveMode;
        }