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

📄 colorpanel.cs

📁 100个非常有趣的C语言UNIX程序实例。可以在乐趣中练习C语言编程。
💻 CS
字号:
using System;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace MasterMind
{
	/// <summary>
	/// Summary description for ColorPanel.
	/// </summary>
	public class ColorPanel
	{
		Point Position;
		const int PanelWidth = 50;
		const int PanelHeight = 8* 20;
		Rectangle Frame;

		public ColorPanel(int x, int y)
		{
			//
			// TODO: Add constructor logic here
			//
			Position = new Point(x,y);
			Frame = new Rectangle(Position, new Size(PanelWidth, PanelHeight));
		}

		public void Draw(Graphics g)
		{
			g.DrawRectangle(Pens.Black, Position.X, Position.Y, PanelWidth, PanelHeight);
			for (int i = 0; i< 8; i++)
			{
				g.FillRectangle(Board.GetBrush(i+1), Position.X, Position.Y+ (i*20), PanelWidth, 20);
			}
		}

		public int GetColorAt(int x, int y)
		{
          int result = -1;
		  if (Frame.Contains(new Point(x,y)) == false)
			  return result;  // precondition
		  
		  return  (y - Position.Y)/20 + 1;
		
		}


	}
}

⌨️ 快捷键说明

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