示例#1
0
        /// <summary>
        /// Controls the actual drawing for this gradient slider control.
        /// </summary>
        /// <param name="g">The graphics object used for drawing.</param>
        /// <param name="clipRectangle">The clip rectangle.</param>
        protected virtual void OnDraw(Graphics g, Rectangle clipRectangle)
        {
            GraphicsPath gp        = new GraphicsPath();
            Rectangle    innerRect = new Rectangle(LeftHandle.Width, 3, Width - 1 - RightHandle.Width - LeftHandle.Width, Height - 1 - 6);

            gp.AddRoundedRectangle(innerRect, 2);

            if (Width == 0 || Height == 0)
            {
                return;
            }

            // Create a rounded gradient effect as the backdrop that other colors will be drawn to
            LinearGradientBrush silver = new LinearGradientBrush(ClientRectangle, BackColor.Lighter(.2F), BackColor.Darker(.6F), LinearGradientMode.Vertical);

            g.FillPath(silver, gp);
            silver.Dispose();

            LinearGradientBrush lgb = new LinearGradientBrush(innerRect, MinimumColor, MaximumColor, LinearGradientMode.Horizontal);

            g.FillPath(lgb, gp);
            lgb.Dispose();

            g.DrawPath(Pens.Gray, gp);
            gp.Dispose();

            if (Enabled)
            {
                LeftHandle.Draw(g);
                RightHandle.Draw(g);
            }
        }
示例#2
0
        /// <summary>
        /// Draws the bounding box and its edit handles into the given canvas
        /// </summary>
        /// <param name="canvas">Canvas.</param>
        public virtual void Draw(SKCanvas canvas)
        {
            // Anything to process?
            if (State != KimonoShapeState.Selected &&
                State != KimonoShapeState.Constructing &&
                State != KimonoShapeState.Grouping)
            {
                return;
            }

            // Define the paint style
            var paint = new SKPaint()
            {
                Style       = SKPaintStyle.Stroke,
                StrokeWidth = 1
            };

            // Set stroke based on the state
            switch (State)
            {
            case KimonoShapeState.Grouping:
                paint.Color = KimonoColor.Ice;
                break;

            case KimonoShapeState.Selected:
                paint.Color = KimonoColor.Tungsten;
                break;

            case KimonoShapeState.Constructing:
                paint.Color = KimonoColor.Aqua;
                break;
            }

            // Draw bounding frame
            canvas.DrawRect(Rect, paint);

            // Draw the four corner handles
            TopLeftHandle?.Draw(canvas);
            TopRightHandle?.Draw(canvas);
            BottomRightHandle?.Draw(canvas);
            BottomLeftHandle?.Draw(canvas);

            // Draw optional handles
            TopHandle?.Draw(canvas);
            RightHandle?.Draw(canvas);
            BottomHandle?.Draw(canvas);
            LeftHandle?.Draw(canvas);
        }
示例#3
0
        /// <summary>
        /// Controls the actual drawing for this gradient slider control.
        /// </summary>
        /// <param name="g">The graphics object used for drawing.</param>
        /// <param name="clipRectangle">The clip rectangle.</param>
        protected virtual void OnDraw(Graphics g, Rectangle clipRectangle)
        {
            using (GraphicsPath gp = new())
            {
                Rectangle innerRect = new(LeftHandle.Width, 3, Width - 1 - RightHandle.Width - LeftHandle.Width, Height - 1 - 6);
                gp.AddRoundedRectangle(innerRect, 2);

                if (Width == 0 || Height == 0)
                {
                    return;
                }

                // Create a rounded gradient effect as the backdrop that other colors will be drawn to
                LinearGradientBrush silver = new(ClientRectangle, BackColor.Lighter(.2F), BackColor.Darker(.6F), LinearGradientMode.Vertical);
                g.FillPath(silver, gp);
                silver.Dispose();

                using (LinearGradientBrush lgb = new(innerRect, Color.White, Color.White, LinearGradientMode.Horizontal))
                {
                    Color[] colors    = new Color[37];
                    float[] positions = new float[37];

                    for (int i = 0; i <= 36; i++)
                    {
                        int j = _inverted ? 36 - i : i;
                        colors[j]    = SymbologyGlobal.ColorFromHsl(((i * 10) + _hueShift) % 360, 1, .7).ToTransparent(.7f);
                        positions[i] = i / 36f;
                    }

                    ColorBlend cb = new()
                    {
                        Colors    = colors,
                        Positions = positions
                    };
                    lgb.InterpolationColors = cb;
                    g.FillPath(lgb, gp);
                }

                g.DrawPath(Pens.Gray, gp);
            }

            if (Enabled)
            {
                LeftHandle.Draw(g);
                RightHandle.Draw(g);
            }
        }