コード例 #1
0
        private void Form2_Load_1(object sender, EventArgs e)
        {
            _g = Graphics.FromImage(_bmp); //Binding the graphics to the Bitmap
            pictureBox1.Image = _bmp;

            RotatingTimer.Start();
        }
コード例 #2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            _g = Graphics.FromImage(_bmp);
            _g.Clear(Color.White);

            // Points SQUARE
            var point1 = new Point(LineCoord(_angle, _radiusSq, _center)[0], LineCoord(_angle, _radiusSq, _center)[1]);
            var point2 = new Point(LineCoord(_angle + 90, _radiusSq, _center)[0], LineCoord(_angle + 90, _radiusSq, _center)[1]);
            var point3 = new Point(LineCoord(_angle + 180, _radiusSq, _center)[0], LineCoord(_angle + 180, _radiusSq, _center)[1]);
            var point4 = new Point(LineCoord(_angle + 270, _radiusSq, _center)[0], LineCoord(_angle + 270, _radiusSq, _center)[1]);

            // Points TR
            var point7 = new Point(LineCoord(_angle + 45, _radiusTr, _center)[0], LineCoord(_angle + 45, _radiusTr, _center)[1]);
            var point6 = new Point(LineCoord(_angle + 180, _radiusTr, _center)[0], LineCoord(_angle + 180, _radiusTr, _center)[1]);
            var point5 = new Point(LineCoord(_angle + 270, _radiusTr, _center)[0], LineCoord(_angle + 270, _radiusTr, _center)[1]);

            Point[] pointsTr = { point5, point6, point7, point5 };

            Point[] pointsSq = { point1, point2, point3, point4, point1 }; // Get all points in one array
            pictureBox1.Image = _bmp;

            _g.DrawLines(new Pen(Color.Black), pointsSq);
            _g.DrawLines(new Pen(Color.Red), pointsTr);

            _g.Dispose();

            _angle = _angle + 15;

            if (_radiusSq < 2)
            {
                timer1.Stop();
                RotatingTimer.Start();
            }
            _radiusSq = _radiusSq - _resize;
            _radiusTr = _radiusTr + _resize;
        }