private void ViewImg_MouseLeave(object sender, EventArgs e) { XposText.Text = ""; YposText.Text = ""; ShowTile(LastTile.X, LastTile.Y); LastTile.X = -1; LastTile.Y = -1; MouseLeft = false; MouseRight = false; ViewImg.Refresh(); }
//вывод экрана void ShowScreen() { Graphics g = Graphics.FromImage(Img); for (int y = 0; y < 16; y++) { for (int x = 0; x < 16; x++) { ShowTile(x, y); } } ViewImg.Refresh(); }
//работа с Img private void ViewImg_MouseMove(object sender, MouseEventArgs e) { XCord = e.X / PixSize; if (XCord < 0) { XCord = 0; } if (XCord > 255) { XCord = 255; } YCord = e.Y / PixSize; if (YCord < 0) { YCord = 0; } if (YCord > 255) { YCord = 255; } XposText.Text = XCord.ToString(); YposText.Text = YCord.ToString(); if (MouseLeft || MouseRight) { SetPixel(); } if (LastTile.X != -1 && LastTile.Y != -1) { ShowTile(LastTile.X, LastTile.Y); } int xtile = XCord / 16; int ytile = YCord / 16; Graphics g = Graphics.FromImage(Img); Pen p = new Pen(Color.Red); p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; g.DrawRectangle(p, xtile * PixSize * 16, ytile * PixSize * 16, PixSize * 16 - 1, PixSize * 16 - 1); ViewImg.Refresh(); LastTile.X = xtile; LastTile.Y = ytile; }
private void ViewImg_MouseDown(object sender, MouseEventArgs e) { //захват значений аттрибута if (CaptureColor.Checked) { CaptureColors(); return; } else { if (e.Button == MouseButtons.Left) { MouseLeft = true; } else { MouseRight = true; } SetPixel(); ViewImg.Refresh(); } }