private void DrawPalette() { paletteBitmap = new Bitmap(256, 256, System.Drawing.Imaging.PixelFormat.Format32bppArgb); Graphics g = Graphics.FromImage(paletteBitmap); short x = 0; short y = 0; if (Colors == null) { throw new Exception("No palette to draw!"); } foreach (NSE_Framework.Data.GBAcolor p in Colors) { g.FillRectangle(new SolidBrush(p.Color), x, y, 16, 16); if (x < 240) { x += 16; } else { x = 0; y += 16; } } ColorsBox.Image = paletteBitmap; ColorsBox.Refresh(); }
private void ComboBoxMode_SelectedIndexChanged(object sender, EventArgs e) { ColorsBox.Refresh(); if (ComboBoxMode.SelectedIndex == 0) { index = 0; Graphics gx = this.ColorsBox.CreateGraphics(); gx.DrawRectangle(new Pen(Color.Black, 1), 0, index * 16, 256, 15); gx.DrawRectangle(new Pen(Color.Red, 1), 1, index * 16 + 1, 254, 13); } }
private void ColorsBox_MouseDown(object sender, MouseEventArgs e) { if (ComboBoxMode.SelectedIndex == 0) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { int y = ColorsBox.PointToClient(Cursor.Position).Y; if (y > 0 && y < 256) { int i = (y - y % 16) / 16; if (i * 16 < Colors.Length) { index = i; ColorsBox.Refresh(); Graphics gx = this.ColorsBox.CreateGraphics(); gx.DrawRectangle(new Pen(Color.Red, 1), 0, index * 16, 256, 15); gx.DrawRectangle(new Pen(Color.Black, 1), 1, index * 16 + 1, 254, 13); } } } } }