Zooming issue

Hey,

I have set my application up to allow the user to select a portion of a diagram and then prompt them to either 1) copy the elements within the selection, 2) delete all items within the selection, or 3) zoom the view to the selection bounds. I do this by first first replacing the default mouse tool with my custom one:

m_modelerView.ReplaceMouseTool(typeof(GoToolRubberBanding), m_selectionTool);

The new mouse tool looks like this:

public class LRProcessModellerSelectionTool : GoToolRubberBanding
{

  public override void DoRubberBand(Rectangle box)
  {
     RectangleF docRect = this.View.ConvertViewToDoc(box);
     ZoomToRect(docRect);
  }

}

I have the rectangle I want but when I try to zoom the view to that rectangle it does not work… can you let me know what I am doing wrong with how I am attempting to zoom?

private void ZoomToRect(RectangleF rect)
{
DiagramView.Document.Bounds = rect;
DiagramView.RescaleToFit();
}

Thanks!

You can’t set the Document.Bounds like that… that property wants to be at least big enough to
contain all the objects in the document.

We do have a GoToolZomming that you can use. Have you tried the zooming functionality in WebWalker? There’s a toolbar button to invoke:

GoToolZooming zoomer = new GoToolZooming(myView);
zoomer.Modal = true;
myView.Tool = zoomer;

This also does the work of making the selection box the correct ratio for the view.