⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 customcolordlg.cs

📁 c#编写的仿OUTLOOK工具条的Winform菜单
💻 CS
📖 第 1 页 / 共 2 页
字号:
				updateMousePos = true;
				crossPos.Y = rc.Top;
			}
			if ( e.Y >= rc.Bottom ) 
			{
				updateMousePos = true;
				crossPos.Y = rc.Bottom;
			}  
          
			if ( updateMousePos )
				Cursor.Position = paletteBox.PointToScreen(new Point(crossPos.X, crossPos.Y));

			HueSatChanged();
			
		}

		void paletteBox_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			paletteBox.Capture = false;
			drawCrossHair = true;
			crossPos.X = e.X;
			crossPos.Y = e.Y;
			paletteBox.Invalidate();
			HueSatChanged();
		}

		void paletteBox_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			paletteBox.Capture = true;
			drawCrossHair = false;
			crossPos.X = e.X;
			crossPos.Y = e.Y;
			paletteBox.Invalidate();
		}

		void paletteBox_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
		{
			
			// Draw the cross-hair
			if ( drawCrossHair )
			{
				Pen p = new Pen(Brushes.Black, 3);
				int x = crossPos.X;
				int y = crossPos.Y;
				e.Graphics.DrawLine(p,x - 10, y , x - 5, y );
				e.Graphics.DrawLine(p,x + 10, y , x + 5, y );
				e.Graphics.DrawLine(p,x , y + 11, x , y +5);
				e.Graphics.DrawLine(p,x , y - 10, x , y -4);
			}
		
		}

		void hueEdit_TextChanged(object sender, System.EventArgs e)
		{
			if ( !updatingUI )
				HueSatTextBoxChanged();
		}

		void satEdit_TextChanged(object sender, System.EventArgs e)
		{
			if ( !updatingUI )
				HueSatTextBoxChanged();
		}

		void lumEdit_TextChanged(object sender, System.EventArgs e)
		{
			if ( !updatingUI )
				LuminosityChanged();
		}

		void redEdit_TextChanged(object sender, System.EventArgs e)
		{
			if ( !updatingUI )
				RGBTextChanged();
		}

		void greenEdit_TextChanged(object sender, System.EventArgs e)
		{
			if ( !updatingUI )
				RGBTextChanged();
		}

		void blueEdit_TextChanged(object sender, System.EventArgs e)
		{
			if ( !updatingUI )
				RGBTextChanged();
		}

		#endregion

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(CustomColorDlg));
			this.paletteBox = new System.Windows.Forms.PictureBox();
			this.lumBox = new System.Windows.Forms.PictureBox();
			this.currentColorPanel = new System.Windows.Forms.Panel();
			this.button1 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.hueEdit = new NumericTextBox();
			this.satEdit = new NumericTextBox();
			this.lumEdit = new NumericTextBox();
			this.redEdit = new NumericTextBox();
			this.greenEdit = new NumericTextBox();
			this.blueEdit = new NumericTextBox();
			this.Label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.label5 = new System.Windows.Forms.Label();
			this.label6 = new System.Windows.Forms.Label();
			this.label7 = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// paletteBox
			// 
			this.paletteBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.paletteBox.Location = new System.Drawing.Point(10, 12);
			this.paletteBox.Name = "paletteBox";
			this.paletteBox.Size = new System.Drawing.Size(202, 188);
			this.paletteBox.TabIndex = 0;
			this.paletteBox.TabStop = false;
			this.paletteBox.Paint += new System.Windows.Forms.PaintEventHandler(this.paletteBox_Paint);
			this.paletteBox.MouseUp += new System.Windows.Forms.MouseEventHandler(this.paletteBox_MouseUp);
			this.paletteBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.paletteBox_MouseMove);
			this.paletteBox.MouseDown += new System.Windows.Forms.MouseEventHandler(this.paletteBox_MouseDown);
			// 
			// lumBox
			// 
			this.lumBox.Location = new System.Drawing.Point(220, 7);
			this.lumBox.Name = "lumBox";
			this.lumBox.Size = new System.Drawing.Size(24, 198);
			this.lumBox.TabIndex = 1;
			this.lumBox.TabStop = false;
			this.lumBox.Paint += new System.Windows.Forms.PaintEventHandler(this.LumBox_Paint);
			this.lumBox.MouseUp += new System.Windows.Forms.MouseEventHandler(this.lumBox_MouseUp);
			this.lumBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.lumBox_MouseMove);
			this.lumBox.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lumBox_MouseDown);
			// 
			// currentColorPanel
			// 
			this.currentColorPanel.BackColor = System.Drawing.SystemColors.Control;
			this.currentColorPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.currentColorPanel.Location = new System.Drawing.Point(12, 212);
			this.currentColorPanel.Name = "currentColorPanel";
			this.currentColorPanel.Size = new System.Drawing.Size(66, 48);
			this.currentColorPanel.TabIndex = 2;
			// 
			// button1
			// 
			this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
			this.button1.Location = new System.Drawing.Point(52, 298);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(64, 22);
			this.button1.TabIndex = 3;
			this.button1.Text = "Add Color";
			// 
			// button2
			// 
			this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.button2.Location = new System.Drawing.Point(138, 298);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(64, 22);
			this.button2.TabIndex = 4;
			this.button2.Text = "Cancel";
			// 
			// hueEdit
			// 
			this.hueEdit.Location = new System.Drawing.Point(124, 218);
			this.hueEdit.MaxLength = 3;
			this.hueEdit.Name = "hueEdit";
			this.hueEdit.SetRange = new System.Drawing.Size(0, 240);
			this.hueEdit.Size = new System.Drawing.Size(30, 20);
			this.hueEdit.TabIndex = 5;
			this.hueEdit.Text = "160";
			this.hueEdit.TextChanged += new System.EventHandler(this.hueEdit_TextChanged);
			// 
			// satEdit
			// 
			this.satEdit.Location = new System.Drawing.Point(124, 241);
			this.satEdit.MaxLength = 3;
			this.satEdit.Name = "satEdit";
			this.satEdit.SetRange = new System.Drawing.Size(0, 240);
			this.satEdit.Size = new System.Drawing.Size(30, 20);
			this.satEdit.TabIndex = 6;
			this.satEdit.Text = "0";
			this.satEdit.TextChanged += new System.EventHandler(this.satEdit_TextChanged);
			// 
			// lumEdit
			// 
			this.lumEdit.Location = new System.Drawing.Point(124, 264);
			this.lumEdit.MaxLength = 3;
			this.lumEdit.Name = "lumEdit";
			this.lumEdit.SetRange = new System.Drawing.Size(0, 240);
			this.lumEdit.Size = new System.Drawing.Size(30, 20);
			this.lumEdit.TabIndex = 7;
			this.lumEdit.Text = "0";
			this.lumEdit.TextChanged += new System.EventHandler(this.lumEdit_TextChanged);
			// 
			// redEdit
			// 
			this.redEdit.Location = new System.Drawing.Point(200, 218);
			this.redEdit.MaxLength = 3;
			this.redEdit.Name = "redEdit";
			this.redEdit.SetRange = new System.Drawing.Size(0, 255);
			this.redEdit.Size = new System.Drawing.Size(30, 20);
			this.redEdit.TabIndex = 8;
			this.redEdit.Text = "0";
			this.redEdit.TextChanged += new System.EventHandler(this.redEdit_TextChanged);
			// 
			// greenEdit
			// 
			this.greenEdit.Location = new System.Drawing.Point(200, 241);
			this.greenEdit.MaxLength = 3;
			this.greenEdit.Name = "greenEdit";
			this.greenEdit.SetRange = new System.Drawing.Size(0, 255);
			this.greenEdit.Size = new System.Drawing.Size(30, 20);
			this.greenEdit.TabIndex = 9;
			this.greenEdit.Text = "0";
			this.greenEdit.TextChanged += new System.EventHandler(this.greenEdit_TextChanged);
			// 
			// blueEdit
			// 
			this.blueEdit.Location = new System.Drawing.Point(200, 264);
			this.blueEdit.MaxLength = 3;
			this.blueEdit.Name = "blueEdit";
			this.blueEdit.SetRange = new System.Drawing.Size(0, 255);
			this.blueEdit.Size = new System.Drawing.Size(30, 20);
			this.blueEdit.TabIndex = 10;
			this.blueEdit.Text = "0";
			this.blueEdit.TextChanged += new System.EventHandler(this.blueEdit_TextChanged);
			// 
			// Label1
			// 
			this.Label1.Location = new System.Drawing.Point(96, 220);
			this.Label1.Name = "Label1";
			this.Label1.Size = new System.Drawing.Size(26, 18);
			this.Label1.TabIndex = 11;
			this.Label1.Text = "Hue";
			this.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(96, 243);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(26, 18);
			this.label2.TabIndex = 12;
			this.label2.Text = "Sat";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(96, 266);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(26, 18);
			this.label3.TabIndex = 13;
			this.label3.Text = "Lum";
			this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(166, 220);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(34, 18);
			this.label4.TabIndex = 14;
			this.label4.Text = "Red:";
			this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(158, 242);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(42, 18);
			this.label5.TabIndex = 15;
			this.label5.Text = "Green:";
			this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(158, 266);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(42, 18);
			this.label6.TabIndex = 16;
			this.label6.Text = "Blue:";
			this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label7
			// 
			this.label7.Location = new System.Drawing.Point(18, 266);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(60, 14);
			this.label7.TabIndex = 17;
			this.label7.Text = "Color|Solid";
			// 
			// CustomColorDlg
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(246, 330);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.label7,
																		  this.label6,
																		  this.label5,
																		  this.label4,
																		  this.label3,
																		  this.label2,
																		  this.Label1,
																		  this.blueEdit,
																		  this.greenEdit,
																		  this.redEdit,
																		  this.lumEdit,
																		  this.satEdit,
																		  this.hueEdit,
																		  this.button2,
																		  this.button1,
																		  this.currentColorPanel,
																		  this.lumBox,
																		  this.paletteBox});
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "CustomColorDlg";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.Text = "Define Color";
			this.Load += new System.EventHandler(this.CustomColorDlg_Load);
			this.ResumeLayout(false);

		}
		#endregion
		
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -