Tulasi Viswanath C
Tulasi Viswanath C

Reputation: 11

Resize the canvas after zooming

I'm performing Zooming too canvas using Matrix. The code is below:

void Zoom_MouseWheel(object sender, MouseWheelEventArgs e)
{
        Point p = e.MouseDevice.GetPosition(clipBorder);

        Matrix m = CanvasPanel.RenderTransform.Value;
        if (e.Delta > 0)
            m.ScaleAtPrepend(1.1, 1.1, p.X, p.Y);
        else
            m.ScaleAtPrepend(1 / 1.1, 1 / 1.1, p.X, p.Y);

        CanvasPanel.RenderTransform = new MatrixTransform(m);
       // CanvasPanel.RenderTransformOrigin = new Point(0.5, 0.5);
}

I want to resize the canvas when I click button in Main Window. Can any one plz, help me out.

Regards,

Viswa

Upvotes: 0

Views: 173

Answers (1)

Tulasi Viswanath C
Tulasi Viswanath C

Reputation: 11

private void btn_Original_Click(object sender, RoutedEventArgs e)//---------------------------------------> Event for getting Original size of canvas
    {
        Matrix m = CanvasPanel.RenderTransform.Value;
        m.SetIdentity();                 
        CanvasPanel.RenderTransform = new MatrixTransform(m);
    }

This makes the canvas to set original size of it and comes back to it's original position

Upvotes: 1

Related Questions