Here's the script:
I have a canvas with different diagrams drawn on it. Now you need to zoom in using the code located either with C # or with VB. Moreover, I need to put the scaling code in some dll so that I can reuse the same set of code outside my application.
Now my question is: how to do this ....
I tried using the following code, which is.
public MainWindow()
{
InitializeComponent();
canvas.MouseEnter += new MouseEventHandler(canvas_MouseEnter);
canvas.MouseWheel += new MouseWheelEventHandler(canvas_MouseWheel);
}
void canvas_MouseWheel(object sender, MouseWheelEventArgs e)
{
double height = canvas.ActualHeight;
double width = canvas.ActualWidth;
double zoom = e.Delta;
height += 2;
width += 2;
ScaleTransform sc = new ScaleTransform(width, height);
canvas.LayoutTransform = sc;
canvas.UpdateLayout();
}
source
share