private void Part8Button_Click(object sender, RoutedEventArgs e) { if (!_part8Complete) { //var layersList = _segmentLayers.Select(p => p.Value).ToList(); //_image.Layers = layersList; //_svgImage = ToSvgString(_image, _segmentLayers, _options.SvgRendering); _svgImage = new TracedImage(_segmentLayers, _loadedImage.Width, _loadedImage.Height).ToSvgString(_options.SvgRendering); File.WriteAllText(_outputFilename, _svgImage); //http://stackoverflow.com/questions/1879395/how-to-generate-a-stream-from-a-string using (MemoryStream stream = new MemoryStream()) using (StreamWriter writer = new StreamWriter(stream)) { writer.Write(_svgImage); writer.Flush(); stream.Position = 0; var wpfSettings = new WpfDrawingSettings(); wpfSettings.CultureInfo = wpfSettings.NeutralCultureInfo; var reader = new FileSvgReader(wpfSettings); _renderedSvg = reader.Read(stream); //ZoomPanControl.ScaleToFit(); //CanvasScroller.Visibility = Visibility.Visible; } //SvgViewer.UnloadDiagrams(); CanvasScroller.Visibility = Visibility.Hidden; SvgViewer.RenderDiagrams(_renderedSvg); Rect bounds = SvgViewer.Bounds; if (bounds.IsEmpty) { bounds = new Rect(0, 0, CanvasScroller.ActualWidth, CanvasScroller.ActualHeight); } ZoomPanControl.AnimatedZoomTo(bounds); _part8Complete = true; //Part8Button.IsEnabled = false; } else { CanvasScroller.Visibility = Visibility.Visible; } ImageDisplay.Source = BitmapToImageSource(CreateTransparentBitmap(_loadedImage.Width + 1, _loadedImage.Height + 1)); }
private ZoomPanControl GetZoomPanControl() { ZoomPanControl zoomAndPanControl = null; switch (_pageMode) { case ZoomPanPageMode.Scrollable: zoomAndPanControl = (this.DataContext as ScrollableZoomPanPage)?.ZoomPanContent; break; case ZoomPanPageMode.Infinite: zoomAndPanControl = (this.DataContext as InfiniteZoomPanPage)?.ZoomPanContent; break; } if (zoomAndPanControl == null) { throw new NullReferenceException("DataContext is not of type ZoomPanControl"); } return(zoomAndPanControl); }
private void CvZoomOut(Point point) { ZoomPanControl.ZoomAboutPoint(ZoomPanControl.ContentScale - 0.1, point); }