アニメ『神撃のバハムート VIRGIN SOUL』
絵がきれい。まるで映画のようです。一期は全部見ていないので、一期を見てから見ようと思います。
ドミノエディタの続きです。
今回はButtonをマトリクス状に配置して、ボタンダウンの座標を覚えて、ドラッグしたボタンに座標を表示してみます。
サンプルです。
using System;
using System.Drawing;
using System.Windows.Forms;
class Test : Form{
int xlen=20;
int ylen=16;
int bsize=44;
class Matrix : Button{
public int state = 0;
public int x;
public int y;
}
Test(){
this.Size = new Size((bsize+1)*xlen,(bsize+1)*ylen);
Matrix[,] mat = new Matrix[xlen,ylen];
for(int x=0;x<xlen;x++){
for(int y=0;y<ylen;y++){
mat[x,y] = new Matrix();
mat[x,y].x = x;
mat[x,y].y = y;
mat[x,y].Parent = this;
mat[x,y].Location = new Point(bsize*x,bsize*y);
mat[x,y].Size = new Size(bsize,bsize);
mat[x,y].AllowDrop = true;
mat[x,y].MouseDown += MouseDown;
mat[x,y].DragEnter += DragEnter;
}
}
}
new private void MouseDown(object sender, MouseEventArgs e){
Matrix b = (Matrix)sender;
string data = "" + b.x + "," + b.y;
b.DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Move);
}
new private void DragEnter(object sender, DragEventArgs e){
Matrix b = (Matrix)sender;
b.Text=(string)e.Data.GetData(typeof(String));
}
[STAThread]
public static void Main(){
Application.Run(new Test());
}
}
実行して、このようにドラッグすろと、
ボタンダウンの座標(ペンタブでペンで描き始めた座標)が、各ボタン上に表示されます。


コメント