Source/ColorPickerItem/CustomColorBlender.cs

(开头部分) 8KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.ComponentModel;

namespace DevComponents.DotNetBar.ColorPickerItem
{
    [ToolboxItem(false)]
    internal class CustomColorBlender : System.Windows.Forms.UserControl
    {
        #region Events
        /// <summary>
        /// Occurs after selected color has changed.
        /// </summary>
        public event EventHandler SelectedColorChanged;
        #endregion
    	
        #region Private Variables
        private Bitmap m_ColorBlendBitmap = null;
        private Point m_SelectedPoint = new Point(-1, -1);
        #endregion

        #region Constructor, Dispose
        public CustomColorBlender()
		{
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.Opaque, true);
            this.SetStyle(DisplayHelp.DoubleBufferFlag, true);
            this.SetStyle(ControlStyles.ResizeRedraw, true);
		}

        private void CreateBlendBitmap()
        {
            int stripeCount = 6;
            Rectangle clientRect = this.ClientRectangle;

            int stripeWidth = clientRect.Width / stripeCount;
            int ySteps=127;
            int xStart = clientRect.X;
            Bitmap bmp = new Bitmap(clientRect.Width, clientRect.Height, PixelFormat.Format24bppRgb);
            using (Graphics graph = Graphics.FromImage(bmp))
            {
                graph.FillRectangle(SystemBrushes.Control, clientRect);

                for (int stripe = 0; stripe < stripeCount; stripe++)
                {
                    // Calculate X steps and point Width
                    int pointWidth = 4;
                    int colorStepX = 255 / (stripeWidth / pointWidth);

                    if (colorStepX<1)
                    {
                        pointWidth = stripeWidth / 255;
                        colorStepX = 1;
                    }

后面还有 201 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。