public static bool isItToolArea(LB_Tools_Interface tool, Point p) { return(tool.GetArea().Contains(p)); }
private void PictureBox_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; Rectangle rect = new Rectangle(); Rectangle rect2 = new Rectangle(); Rectangle rect3 = new Rectangle(); Brush brush; Pen pen1 = new Pen(AppAppearance.MatrixCellSelectColor, 2); Pen pen2 = new Pen(Color.Black, 1); Pen pen3 = new Pen(AppAppearance.MatrixToolSelectColor, 2); Point p1 = new Point(); Point p2 = new Point(); Color PixelColor; int BlackARGB = Color.Black.ToArgb(); rect.Height = DotSize; rect.Width = DotSize; rect2.Height = DotSize + DotSpace; rect2.Width = DotSize + DotSpace; rect3.Height = DotSize - 1; rect3.Width = DotSize - 1; for (int x = 0; x < BoardImage.Width; x++) { for (int y = 0; y < BoardImage.Height; y++) { if (x == SelectedPixel.X && y == SelectedPixel.Y) { rect2.X = x * (DotSize + DotSpace) + MatrixPosition.X - (DotSpace / 2); rect2.Y = y * (DotSize + DotSpace) + MatrixPosition.Y - (DotSpace / 2); g.DrawRectangle(pen1, rect2); } rect.X = x * (DotSize + DotSpace) + MatrixPosition.X; rect.Y = y * (DotSize + DotSpace) + MatrixPosition.Y; rect3.X = x * (DotSize + DotSpace) + MatrixPosition.X; rect3.Y = y * (DotSize + DotSpace) + MatrixPosition.Y; PixelColor = BoardImage.GetPixel(x, y); // if (PixelColor.ToArgb() != BlackARGB) { brush = new SolidBrush(PixelColor); g.FillRectangle(brush, rect); g.DrawRectangle(pen2, rect3); } /* else * { * brush = new SolidBrush(AppAppearance.DefaultMatrixColor); * g.FillRectangle(brush, rect); * g.DrawRectangle(pen2, rect3); * p1.X = rect3.X; * p1.Y = rect3.Y; * p2.X = p1.X + rect3.Width; * p2.Y = p1.Y + rect3.Height; * g.DrawLine(pen2, p1, p2); * p1.X = rect3.X + rect3.Width; * p1.Y = rect3.Y; * p2.X = rect3.X; * p2.Y = p1.Y + rect3.Height; * g.DrawLine(pen2, p1, p2); * }*/ } } if (SelectedTool != null) { Rectangle toolArea = SelectedTool.GetArea(); toolArea.Height = toolArea.Height * (DotSize + DotSpace); toolArea.Width = toolArea.Width * (DotSize + DotSpace); toolArea.X = toolArea.X * (DotSize + DotSpace) + MatrixPosition.X - (DotSpace / 2); toolArea.Y = toolArea.Y * (DotSize + DotSpace) + MatrixPosition.Y - (DotSpace / 2); g.DrawRectangle(pen3, toolArea); } Thread.Sleep(10); }