David
1
Hi
When I add a new object in GoView, I want it shape square
When Mouse moving with Shift Key, it should be changed square shape (both height and width are same)
I use my New class
and then, made methods
public override void DoMouseMove()
public override void DoMouseUp()
public class myToolCreating : GoToolCreating
{
public override void DoMouseMove()
{
if (this.LastInput.Shift)
{
###### code 1 ########
}
}
public override void DoMouseUp()
{
###### code 2 ######
}
.....
}
I need code1, code2…
Would you give me sample code in the method…
or Another solution.
please reply
thank you
Jake
2
Here is the code for ComputeBox in GoCreateTool. I think the simplest thing to do is override this and add your square constraint.
You can use this.LastInput.Modifiers to test for shift (the low bit set).
public virtual RectangleF ComputeBox() {
PointF start = this.FirstInput.DocPoint;
PointF latest = this.LastInput.DocPoint;
if (this.SnapsToGrid) {
start = this.View.SnapPoint(start, this.NewObject);
latest = this.View.SnapPoint(latest, this.NewObject);
}
RectangleF r = new RectangleF(Math.Min(latest.X, start.X),
Math.Min(latest.Y, start.Y),
Math.Abs(latest.X - start.X),
Math.Abs(latest.Y - start.Y));
SizeF min = this.MinimumSize;
SizeF max = this.MaximumSize;
if (r.Width < min.Width)
r.Width = min.Width;
else if (r.Width > max.Width)
r.Width = max.Width;
if (r.Height < min.Height)
r.Height = min.Height;
else if (r.Height > max.Height)
r.Height = max.Height;
return r;
}