This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

zoom on load and undo

Vestan Pance#1869
Hi

I want to add undo to my application but I'm running up against a small problem. You've already kindly helped with the zooming in this post

As you can see from my previous post when I load the image to the bitmapviewer I set the zoom at the same time in the code behind. However when I add an undo button using the following code it doesn't respect the zoom.

aspx snippet:
    function undo(){
        bitmapViewer1.invokeRemoteMethod("undo");
    }


vb.net snippet
    <Aurigma.GraphicsMill.WebControls.RemoteScriptingMethod()> _
    Public Sub undo()
        If Not BitmapViewer1.Bitmap.IsEmpty Then
            If BitmapViewer1.Bitmap.CanUndo Then
                BitmapViewer1.Bitmap.Undo()
            End If
        End If
    End Sub


What do I need to do to get the zoom set on load and on undo?
Vestan Pance#7530
To clarfiy, what I am trying to acheive is that the image is always displayed "best fit" and the scroll bars never need to show regardless of how large or what shape the image is.
Sergey Peshekhonov#7531
Hello, Vestan

As I understand your problem, you should just replace your undo() function with this code:
    function undo(){
        bitmapViewer1.invokeRemoteMethod("undo");
        updateRectangle=true;
    }

and replace your bitmapViewer1_StatusChanged() function with this code:
    function bitmapViewer1_StatusChanged(){
	var s = bitmapViewer1.getStatus();

	if (updateRectangle && s != "Busy"){
		updateRectangle = false;
		bitmapViewer1.setZoom(bitmapViewer1.offsetWidth/bitmapViewer1.bitmap.getWidth());
		rectangleRubberband1.setRectangle(new Rectangle(0, 0, bitmapViewer1.bitmap.getWidth(), bitmapViewer1.bitmap.getHeight()))
	}
    }


Also, during zoom calculation, you should take into account Height of the BitmapViewer.