private void pixels_Click(object sender, EventArgs e) { if((sender is PixelButton)){ selectpix = (PixelButton)sender; RedCount.Text = (map.GetPixel(selectpix.getX(), selectpix.getY()).R).ToString(); GreenCount.Text = (map.GetPixel(selectpix.getX(), selectpix.getY()).G).ToString(); BlueCount.Text = (map.GetPixel(selectpix.getX(), selectpix.getY()).B).ToString(); AlphaCount.Text = (map.GetPixel(selectpix.getX(), selectpix.getY()).A).ToString(); pixelInfo.Text = "像素資訊" + selectpix.getX() + "," + selectpix.getY(); butColor.BackColor = map.GetPixel(selectpix.getX(), selectpix.getY()); butClear.Enabled = true; } }
/* private void initPixels(){ this.designPanel.Controls.Clear(); for (int x = 0; x < pixels.GetLength(0);x++ ) { for (int y = 0; y < pixels.GetLength(1); y++) { pixels[x, y] = new PixelButton(); pixels[x, y].BackColor = System.Drawing.Color.Transparent; pixels[x, y].FlatStyle = System.Windows.Forms.FlatStyle.Flat; pixels[x, y].FlatAppearance.BorderSize = 0; pixels[x, y].Location = new System.Drawing.Point(0, 0); pixels[x, y].Margin = new System.Windows.Forms.Padding(0); pixels[x, y].Name = "pixel"; if (pixels.GetLength(0) == 32 && pixels.GetLength(1) == 32) { pixels[x, y].Size = new System.Drawing.Size(8, 8); } else { pixels[x, y].Size = new System.Drawing.Size(16, 16); } pixels[x, y].UseVisualStyleBackColor = false; pixels[x, y].setXY(x, y); pixels[x, y].Click += new System.EventHandler(this.pixels_Click); pixels[x, y].BackColorChanged += new System.EventHandler(this.pixels_Changed); this.designPanel.Controls.Add(pixels[x, y]); } } if (pixels.GetLength(0) == 32 && pixels.GetLength(1) == 32) { lblSizex.Text = "32x32"; } else { lblSizex.Text = "16x16"; } redrawPixels(); }*/ private void initCrossPixels() { this.designPanel.Controls.Clear(); pixels.Initialize(); for (int x = 0; x < pixels.GetLength(0); x++) { for (int y = 0; y < pixels.GetLength(1); y++) { if (pixels[y, x] == null) { pixels[y, x] = new PixelButton(); } pixels[y, x].BackColor = System.Drawing.Color.Transparent; pixels[y, x].FlatStyle = System.Windows.Forms.FlatStyle.Flat; pixels[y, x].FlatAppearance.BorderSize = 0; pixels[y, x].Location = new System.Drawing.Point(0, 0); pixels[y, x].Margin = new System.Windows.Forms.Padding(0); pixels[y, x].Name = "pixel"; if (pixels.GetLength(0) == 64 && pixels.GetLength(1) == 64) { pixels[y, x].Size = new System.Drawing.Size(4, 4); } else if (pixels.GetLength(0) == 32 && pixels.GetLength(1) == 32) { pixels[y, x].Size = new System.Drawing.Size(8, 8); } else { pixels[y, x].Size = new System.Drawing.Size(16, 16); } pixels[y, x].UseVisualStyleBackColor = false; pixels[y, x].setXY(y, x); pixels[y, x].Click += new System.EventHandler(this.pixels_Click); pixels[y, x].BackColorChanged += new System.EventHandler(this.pixels_Changed); this.designPanel.Controls.Add(pixels[y, x]); } } if (pixels.GetLength(0) == 64 && pixels.GetLength(1) == 64) { lblSizex.Text = "64x64"; } else if (pixels.GetLength(0) == 32 && pixels.GetLength(1) == 32) { lblSizex.Text = "32x32"; } else { lblSizex.Text = "16x16"; } redrawPixels(); }