示例#1
0
        public Tube(TubeCoords tubeCoords)
        {
            this.tubeCoords = tubeCoords;

            rectanglePosition = tubeRowColToXY(tubeCoords);
            this.rectangle    = new Rectangle(this.rectanglePosition.x, this.rectanglePosition.y, this.tubeSize, this.tubeSize);
        }
示例#2
0
        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();
            }
        }
示例#3
0
        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);
        }
示例#4
0
        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);
            }
        }
示例#5
0
        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());
                }
            }
        }