コード例 #1
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++;
                }
            }
        }