Source/ColorPickerItem/ColorSelectionPreviewControl.cs

(开头部分) 1KB

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

using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace DevComponents.DotNetBar.ColorPickerItem
{
    [ToolboxItem(false)]
	internal class ColorSelectionPreviewControl : System.Windows.Forms.UserControl
	{
		#region Private Variables
		private Color m_CurrentColor = Color.Black;
		private Color m_NewColor = Color.Empty;
		#endregion
		
		#region Constructor
		public ColorSelectionPreviewControl()
		{
			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);
		}
		#endregion
		
		#region Internal Implementation
		protected override void OnPaint(PaintEventArgs e)
		{
			if(this.BackColor == Color.Transparent)
			{
				base.OnPaintBackground(e);
			}

			Graphics g = e.Graphics;
			
			Rectangle r = this.ClientRectangle;
			
			g.FillRectangle(SystemBrushes.Control, r);
			
			if(!m_NewColor.IsEmpty)
			{
				using(SolidBrush brush = new SolidBrush(m_NewColor))
					g.FillRectangle(brush, r.X, r.Y, r.Width, r.Height / 2);
			}
			
			if(!m_CurrentColor.IsEmpty)
			{
				using(SolidBrush brush = new SolidBrush(m_CurrentColor))
					g.FillRectangle(brush, r.X, r.Y + r.Height / 2, r.Width, r.Height / 2);
			}
			
			using(Pen pen=new Pen(Color.Black))
			{
				r.Width--;
				r.Height--;
				g.DrawRectangle(pen, r);
				
后面还有 26 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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