Hi, Experts.
I am dealing with 5 big images. (The resolution is about 5000 * 3000).
After loading the images and displaying them on the same canvas, I zoom-in and zoom-out the images at the same time by moving a slider.
But during this zoom-in/out actions, my program (actually my computer) is frozen.
When I used 10 small images (about 800 * 600), there was no problem.
The following code is called when I change the image size (by zoom-in/out).
Code:private static void OnImageZoomChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { ImageScrollControl control = obj as ImageScrollControl; double zoom = (double)args.NewValue; if (control == null || zoom < 0.1 || zoom > 21) return; else { // double scale = (zoom <= 20) ? (zoom / 20) : (zoom - 19); control.ImageViewBox.Height = control._pixelHeight * zoom; control.ImageViewBox.Width = control._pixelWidth * zoom; control.ImageScrollViewer.UpdateLayout(); } }
If I comment out the following two lines, then works fine.
// control.ImageViewBox.Height = control._pixelHeight * zoom;
// control.ImageViewBox.Width = control._pixelWidth * zoom;
But the size of the image in the viewbox doesn't change at all.
The following is the XAML code.
Code:<TabControl Height="Auto" Width="Auto" x:Name="LogTabControl"> <TabItem Header="Image"> <RegistrationFront_UI_Custom:ZoomNMoveScrollControl x:Name="ImageScrollViewer" Width="Auto" Height="Auto" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" PreviewMouseWheel="ImageScrollViewer_PreviewMouseWheel"> <Viewbox x:Name="ImageViewBox" OpacityMask="{x:Null}" ScrollViewer.HorizontalScrollBarVisibility="Disabled"> <Canvas x:Name="ImageCanvas" HorizontalAlignment="Center" VerticalAlignment="Center"> </Canvas> </Viewbox> </RegistrationFront_UI_Custom:ZoomNMoveScrollControl> </TabItem> <TabItem x:Name="LogTab" Header="Logs" Width="Auto" Height="Auto"> <RegistrationFront_UI_Custom:LogBrowser x:Name="LogBrowserTab" CurrentProject="{Binding Path=CurrentProject, ElementName=UserControl, Mode=Default}" /> </TabItem> </TabControl>
Do you have any idea about this problem?
Any comment will be really appreciated.
Thank you.
Kim.



Reply With Quote



Bookmarks