Hi,
I used the following code for while zooming the view using rubberband box & this works perfect as per functionality. But In my application, I have a constraint, that zooming should be done only horizontally not vertically.Because I have a fixed hight of Y axis, which is always current visible area of the screen. But X axis grows, as per data according to y axis.
So how can I use this code in my application without zooming vertically?
public class AmeravinZooming:GoToolZooming
{
public AmeravinZooming(GoView v)
: base(v) { }
public override bool CanStart()
{
bool pRetVal = false;
GoInputEventArgs e = this.LastInput;
pRetVal = (e.Buttons == MouseButtons.Left) && e.Control;
return pRetVal;
}
public override void DoMouseMove() {
if (!this.Active) {
if (this.Modal)
return;
else {
//Activate();
this.Active = true;
this.Box = new Rectangle(this.FirstInput.ViewPoint.X, this.FirstInput.ViewPoint.Y, 0, 0);
this.View.Refresh();
}
}
else {
base.DoMouseMove();
}
}
Activate() is a private utility routine within Go (and is where the selection is cleared), I've copied the needed bits into DoMouseMove.
OK, for other readers here: If you wanted to continue drag box selection and add zoom with CTRL-drag, then you would do this:
public class AmeravinRubberBanding : GoToolRubberBanding {
public AmeravinRubberBanding(GoView v)
: base(v) { }
public override bool CanStart() {
if (!base.CanStart()) return false;
bool pRetVal = false;
GoInputEventArgs e = this.LastInput;
pRetVal = (e.Buttons == MouseButtons.Left) && e.Control;
return !pRetVal;
}
}
This class duplicates GoToolRubberBanding but doesn't activate if CTRL is down.
and, to add these two tools to the view, you would:
view.ReplaceMouseTool(typeof(GoToolRubberBanding), new AmeravinRubberBanding(view));
view.MouseMoveTools.Add(new AmeravinZooming(view));
{
public AmeravinZooming(GoView v)
: base(v) { }
public override bool CanStart()
{
bool pRetVal = false;
GoInputEventArgs e = this.LastInput;
pRetVal = (e.Buttons == MouseButtons.Left) && e.Control;
return pRetVal;
}
public override void DoMouseMove() {
if (!this.Active) {
if (this.Modal)
return;
else {
//Activate();
this.Active = true;
this.Box = new Rectangle(this.FirstInput.ViewPoint.X, this.FirstInput.ViewPoint.Y, 0, 0);
this.View.Refresh();
}
}
else {
base.DoMouseMove();
}
}
Activate() is a private utility routine within Go (and is where the selection is cleared), I've copied the needed bits into DoMouseMove.
OK, for other readers here: If you wanted to continue drag box selection and add zoom with CTRL-drag, then you would do this:
public class AmeravinRubberBanding : GoToolRubberBanding {
public AmeravinRubberBanding(GoView v)
: base(v) { }
public override bool CanStart() {
if (!base.CanStart()) return false;
bool pRetVal = false;
GoInputEventArgs e = this.LastInput;
pRetVal = (e.Buttons == MouseButtons.Left) && e.Control;
return !pRetVal;
}
}
This class duplicates GoToolRubberBanding but doesn't activate if CTRL is down.
and, to add these two tools to the view, you would:
view.ReplaceMouseTool(typeof(GoToolRubberBanding), new AmeravinRubberBanding(view));
view.MouseMoveTools.Add(new AmeravinZooming(view));
Thanks