public Tube(TubeCoords tubeCoords) { this.tubeCoords = tubeCoords; rectanglePosition = tubeRowColToXY(tubeCoords); this.rectangle = new Rectangle(this.rectanglePosition.x, this.rectanglePosition.y, this.tubeSize, this.tubeSize); }
private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { Tube currentTube = tubes.Find(tube => tube.isClicked(e.Location)); if (currentTube is Tube) { TubeCoords coords = currentTube.getCoords(); tbPX.Text = coords.row.ToString(); tbPY.Text = coords.col.ToString(); } }
private RectangleCoords tubeRowColToXY(TubeCoords tubeCoords) { RectangleCoords rectangleCoords = new RectangleCoords() { x = ((int)(tubeCoords.col - 200) * tubeShift), //Ряд y = ((int)tubeCoords.row * tubeSize) //Колонна }; //сместили если четный ряд if (rectangleCoords.y % 2 != 0) { rectangleCoords.x = rectangleCoords.x + tubeShift; } return(rectangleCoords); }
private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { Tube currentTube = tubes.Find(tube => tube.isClicked(e.Location)); if (currentTube is Tube) { TubeCoords coords = currentTube.getCoords(); string toolTipText = "Row: " + coords.row.ToString() + " Col: " + coords.col.ToString(); if (this.toolTipText != toolTipText) { this.tubeTip.Show(toolTipText, this, currentTube.rectanglePosition.x, currentTube.rectanglePosition.y + 35); this.toolTipText = toolTipText; } } else { this.tubeTip.Hide(this); } }
private void pictureBox1_Paint(object sender, PaintEventArgs e) { Graphics graphics = e.Graphics; SQLiteDataReader data = this.db.query("select * from planClear"); if (data.HasRows) { while (data.Read()) { TubeCoords currentTubeCoords = new TubeCoords { row = data.GetInt32(1), col = data.GetInt32(2) }; int type = data.GetInt32(3); Tube tube = new Tube(currentTubeCoords); tubes.Add(tube); graphics.DrawImage(icons.getIcon(type), tube.getRectangle()); } } }