|
■No9528 (mあ@反省中 さん) に返信 > C# も載せます。 > > using System; > using System.Collections.Generic; > using System.ComponentModel; > using System.Data; > using System.Drawing; > using System.Text; > using System.Windows.Forms; > > namespace GameCs > { > public partial class Form1 : Form > { > private PictureBox pic = new PictureBox(); > public Form1() > { > InitializeComponent(); > } > > private void Form1_Load(object sender, EventArgs e) > { > Controls.Add(pic); > > pic.Paint += pic_Paint; > this.KeyUp += me_Keyup; > } > > private void pic_Paint(Object s, PaintEventArgs e) > { > e.Graphics.DrawRectangle(Pens.AliceBlue,new Rectangle(10,10,40,40)); > e.Graphics.FillRectangle(Brushes.Aqua, new Rectangle(10, 10, 40, 40)); > } > > private void me_Keyup(object s, KeyEventArgs e) > { > switch (e.KeyCode) > { > case Keys.Up: > pic.Top = pic.Top - 10; > break; > case Keys.Down: > pic.Top = pic.Top + 10; > break; > case Keys.Left: > pic.Left = pic.Left - 10; > break; > case Keys.Right: > pic.Left = pic.Left + 10; > break; > default: > break; > }; > } > > } > } > ありがとうございます。上記のコードを記述してみましたが、ビルドして何も描画されていないウインドウが表示されるだけです。
|