Inheritance: System.Windows.Forms.Label, IFWDisposable
示例#1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        void btn_Click(object sender, EventArgs e)
        {
            XButton btn = sender as XButton;

            if (btn != null && m_clrButtons.ContainsKey(btn) && m_clrButtons[btn] != m_currColor)
            {
                m_currentColorName = m_toolTip.GetToolTip(btn);
                CurrentColor       = m_clrButtons[btn];
                if (ColorPicked != null)
                {
                    ColorPicked(this, EventArgs.Empty);
                }
            }
        }
示例#2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public ColorPickerMatrix()
        {
            InitializeComponent();

            DoubleBuffered = true;

            m_toolTip = new ToolTip();

            int row = 0;
            int col = 0;

            for (int i = 0; i < ColorUtil.kNumberOfColors; i++)
            {
                // Get the entry from the resources that has the color name and RGB value.
                Color color = ColorUtil.ColorAtIndex(i);
                if (color == Color.Empty)
                {
                    continue;
                }

                XButton btn = new XButton();
                btn.CanBeChecked = true;
                btn.DrawEmpty    = true;
                btn.Size         = new Size(kColorSquareSize, kColorSquareSize);
                btn.BackColor    = BackColor;
                btn.Location     = new Point(col * kColorSquareSize, row * kColorSquareSize);
                btn.Paint       += new PaintEventHandler(btn_Paint);
                btn.Click       += new EventHandler(btn_Click);
                Controls.Add(btn);

                // Store the name in the tooltip and create a color from the RGB values.
                m_toolTip.SetToolTip(btn, ColorUtil.ColorNameAtIndex(i));
                m_clrButtons[btn] = color;

                col++;
                if (col == kNumberOfCols)
                {
                    col = 0;
                    row++;
                }
            }
        }
示例#3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public ColorPickerMatrix()
		{
			InitializeComponent();

			DoubleBuffered = true;

			m_toolTip = new ToolTip();

			int row = 0;
			int col = 0;

			for (int i = 0; i < ColorUtil.kNumberOfColors; i++)
			{
				// Get the entry from the resources that has the color name and RGB value.
				Color color = ColorUtil.ColorAtIndex(i);
				if (color == Color.Empty)
					continue;

				XButton btn = new XButton();
				btn.CanBeChecked = true;
				btn.DrawEmpty = true;
				btn.Size = new Size(kColorSquareSize, kColorSquareSize);
				btn.BackColor = BackColor;
				btn.Location = new Point(col * kColorSquareSize, row * kColorSquareSize);
				btn.Paint += new PaintEventHandler(btn_Paint);
				btn.Click += new EventHandler(btn_Click);
				Controls.Add(btn);

				// Store the name in the tooltip and create a color from the RGB values.
				m_toolTip.SetToolTip(btn, ColorUtil.ColorNameAtIndex(i));
				m_clrButtons[btn] = color;

				col++;
				if (col == kNumberOfCols)
				{
					col = 0;
					row++;
				}
			}
		}
示例#4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        void btn_Paint(object sender, PaintEventArgs e)
        {
            XButton btn = sender as XButton;

            if (btn == null)             // || btn.Parent == null)
            {
                return;
            }

            Rectangle rc = btn.ClientRectangle;

            using (SolidBrush br = new SolidBrush(btn.BackColor))
            {
                e.Graphics.FillRectangle(br, rc);

                br.Color = Color.Gray;
                rc.Inflate(-3, -3);
                e.Graphics.FillRectangle(br, rc);

                br.Color = m_clrButtons[btn];
                rc.Inflate(-1, -1);
                e.Graphics.FillRectangle(br, rc);
            }
        }