Zooming the view horizontally using rubberbanding

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));
Thanks

No, you can’t have a separate horizontal and vertical scale. We actually tried that, but you quickly run into issues like how wide a Pen draws on horizontal and vertical… it starts looking weird pretty quickly.

Hi,
I agree to you. But still is it possible that in a specific derive class for rubberbanding zooming, can we ignore y zoom factor?

thanks

I think the discussion here is the sort of information you’re looking for. ComputeRubberBandBox and DoRubberBand overrides give you the ability to customize the zooming.