Zooming using GoToolZooming

Hi All,

I am having a problem while zooming the view using rubberband box.The scenario is :
My view contains many GoObjects and say I have selected few of them.Now I want to zoom the view by drawing a rubberband.Requirement is such that during and after the zooming, my already selected objects collection should not change.
Now to achieve zooming this functionality, I have done:
GoView1.ReplaceMouseTool(typeof(GoToolRubberBanding), new CustomZooming(GoView1));
and I have derived CustomZooming class from GoToolZooming.I have also overriden CanStart() to start my zooming only when ctrl key is pressed.
The problem is when I start making the rectangle box using Left mouse button and Ctrl key, the already selected objects selection boundary is gone.
Thanks,
Vin

If I follow what you are saying, you have a different CanStart for zooming. You don’t want to ReplaceMouseTool the RubberBanding tool, you want to MouseMoveTools.Add(new CustomZooming(view)).

GoToolRubberBanding will still get in the way, you’ll need a simple GoToolRubberBanding that tests for “Ctrl” key in CanStart() and returns false.

Hi Jake,

I think you got me wrong here.The problem here is:
When I zoom my goview using a rubberband rectangle, then my already selected object's selection handles disappear.I need to zoom the diagram without changing my selection.
I have already achieved Ctrl key functionality.

Can you post (or email me “godiagram” at this domain) your CustomZooming class?

Hi Jake,

Here is the code:
class CustomZooming:GoToolZooming { public GDZooming(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 System.Drawing.Rectangle ComputeRubberBandBox() { /*Some code used for removing Aspect Ratio constraint. */ }

}

Also I have added this custom class using:
GoView1.ReplaceMouseTool(typeof(GoToolRubberBanding), new CustomZooming(GoView1));
Thanks,
Vin

Do you want regular drag-box selection when there is no CTRL key?

No, I don’t want drag box selection at all. I am using this code for zooming my view.

My Scenario is:
I want to zoom my view using rubberband zooming. but I have some objets selected in my view.Now when I press control key and try to make the rubberband box, my already selected objects get deselected.But I don't want this behaviour, I want my objects to remain selected when rubber band zooming is done.
The significance of Ctrl key is only that user can make the rubber band zooming rectangle only when CTRL key is pressed, in all other cases nothing will happen.

ok then. GoToolZooming is derived from GoToolRubberbanding. In the DoMouseMove, it clears the selection when the tool is activated.



so, you need to do this:



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 Jake…Issue is solved now.

Hi,

I used this 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?
Thanks

answered in other thread.