using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Panel panel1;
Button button1;
PictureBox pictureBox1;
Timer timer1;
const int startpointX = 50;
const int startpointY = 50;
const int endpointX = 500;
const int endpointY = 50;
const int movesizeX = 2;
const int movesizeY = 0;
private void Form1_Load(object sender, EventArgs e)
{
this.ClientSize = new Size(800, 600);
panel1 = new Panel();
panel1.Dock = DockStyle.Bottom;
this.Controls.Add(panel1);
button1 = new Button();
button1.Text = "実行";
button1.Click += new EventHandler(button1_Click);
panel1.Controls.Add(button1);
Bitmap bmp = new Bitmap(100, 100, PixelFormat.Format32bppArgb);
using (Graphics g = Graphics.FromImage(bmp))
{
//g.FillRectangle(Brushes.White, 0, 0, bmp.Width, bmp.Height);
g.FillRectangle(Brushes.Transparent, 0, 0, bmp.Width, bmp.Height);
//g.SmoothingMode = SmoothingMode.AntiAlias;
Pen pen1 = new Pen(Brushes.Red,1);
g.DrawEllipse(pen1, 0, 0, 99, 99);
pen1.Dispose();
}
pictureBox1 = new PictureBox();
pictureBox1.Image = bmp;
pictureBox1.Location = new Point(startpointX, startpointY);
pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
this.Controls.Add(pictureBox1);
timer1 = new Timer();
timer1.Interval = 1000 / 60;
timer1.Enabled = false;
timer1.Tick += new EventHandler(timer1_Tick);
}
void timer1_Tick(object sender, EventArgs e)
{
if (pictureBox1.Location.X >= endpointX)
{
timer1.Enabled = false;
button1.Enabled = true;
}
else
{
pictureBox1.Location = new Point(pictureBox1.Location.X + movesizeX, pictureBox1.Location.Y + movesizeY);
}
}
void button1_Click(object sender, EventArgs e)
{
button1.Enabled = false;
pictureBox1.Location = new Point(startpointX, startpointY);
timer1.Enabled = true;
}
}
}
dXNpbmcgU3lzdGVtOwp1c2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AgICAgICAgICAgIHBpY3R1cmVCb3gxLkltYWdlID0gYm1wOwogICAgICAgICAgICBwaWN0dXJlQm94MS5Mb2NhdGlvbiA9IG5ldyBQb2ludChzdGFydHBvaW50WCwgc3RhcnRwb2ludFkpOwogICAgICAgICAgICBwaWN0dXJlQm94MS5TaXplTW9kZSA9IFBpY3R1cmVCb3hTaXplTW9kZS5BdXRvU2l6ZTsKCiAgICAgICAgICAgIHRoaXMuQ29udHJvbHMuQWRkKHBpY3R1cmVCb3gxKTsKCiAgICAgICAgICAgIHRpbWVyMSA9IG5ldyBUaW1lcigpOwogICAgICAgICAgICB0aW1lcjEuSW50ZXJ2YWwgPSAxMDAwIC8gNjA7CiAgICAgICAgICAgIHRpbWVyMS5FbmFibGVkID0gZmFsc2U7CiAgICAgICAgICAgIHRpbWVyMS5UaWNrICs9IG5ldyBFdmVudEhhbmRsZXIodGltZXIxX1RpY2spOwogICAgICAgIH0KCiAgICAgICAgdm9pZCB0aW1lcjFfVGljayhvYmplY3Qgc2VuZGVyLCBFdmVudEFyZ3MgZSkKICAgICAgICB7CiAgICAgICAgICAgIGlmIChwaWN0dXJlQm94MS5Mb2NhdGlvbi5YID49IGVuZHBvaW50WCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgdGltZXIxLkVuYWJsZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgIGJ1dHRvbjEuRW5hYmxlZCA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBwaWN0dXJlQm94MS5Mb2NhdGlvbiA9IG5ldyBQb2ludChwaWN0dXJlQm94MS5Mb2NhdGlvbi5YICsgbW92ZXNpemVYLCBwaWN0dXJlQm94MS5Mb2NhdGlvbi5ZICsgbW92ZXNpemVZKTsKICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgdm9pZCBidXR0b24xX0NsaWNrKG9iamVjdCBzZW5kZXIsIEV2ZW50QXJncyBlKQogICAgICAgIHsKICAgICAgICAgICAgYnV0dG9uMS5FbmFibGVkID0gZmFsc2U7CiAgICAgICAgICAgIHBpY3R1cmVCb3gxLkxvY2F0aW9uID0gbmV3IFBvaW50KHN0YXJ0cG9pbnRYLCBzdGFydHBvaW50WSk7CiAgICAgICAgICAgIHRpbWVyMS5FbmFibGVkID0gdHJ1ZTsKICAgICAgICB9CiAgICB9Cn0K