Rev 1459 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BurutaruEditor.file;
namespace BurutaruEditor.interaction
{
public class SelectMove : Interaction
{
private bool mLeftDown = false;
private int mLastX = 0;
private int mLastY = 0;
private LevelObject mSelectedObject = null;
public SelectMove(MainForm owner)
: base(owner)
{
}
public override void MouseDown(MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
mLeftDown = true;
mSelectedObject = Owner.View.FindObjectAt(e.X, e.Y);
}
mLastX = e.X;
mLastY = e.Y;
}
public override void MouseMove(MouseEventArgs e)
{
if (mLeftDown && (mSelectedObject != null))
{
float dx = e.X - mLastX;
float dy = e.Y - mLastY;
if (mSelectedObject != null)
{
mSelectedObject.MoveBy(dx, dy);
}
}
else
{
LevelObject obj = Owner.View.FindObjectAt(e.X, e.Y);
if (obj == null)
Owner.GlView.Cursor = Cursors.Arrow;
else
Owner.GlView.Cursor = Cursors.SizeAll;
}
mLastX = e.X;
mLastY = e.Y;
}
public override void MouseUp(MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
mLeftDown = false;
mSelectedObject = null;
}
}
}
}