This project has moved and is read-only. For the latest updates, please go here.

Zoom in SvgPictureBox

Topics: SVG
May 6, 2011 at 1:25 PM

How do you zoom in and out using the svgpicturebox control?

 

Frank

Coordinator
May 6, 2011 at 1:56 PM

Hello Frank,

Sorry, this feature is not implemented. I never thought about interest in the GDI
renderer, but concentrated on the WPF renderer, since I needed that for my work.

I trying to release the version 1.0 and then redesign most parts of the GDI, providing it
with testing applications, controls and viewers. This will address this issue.

Best regards,
Paul. 

May 8, 2011 at 3:20 AM
Edited May 8, 2011 at 3:30 AM

Here's a quick and dirty way to get zoom features with svgpicturebox:

myXml is the XmlDocument

private void TheZoomer(float Zint)  

     {

            String LocalScale = "";
            if (myXml.LastChild.Attributes["transform"] != null)

            { 

               LocalScale = myXml.LastChild.Attributes["transform"].Value;  

         }    

       else 

   {  

             XmlAttribute scaxml = myXml.CreateAttribute("transform");  

             scaxml.Value = "scale(1.0)";    

           myXml.LastChild.Attributes.Append(scaxml);  

             LocalScale = "scale(1.0)";  

         }      

      string parsIt = LocalScale.Replace("scale(", "").Replace(")", "");    

     string[] parts = parsIt.Split(',');  

   float[] ops = new float[parts.Length];

            for (int i = 0; i < parts.Length; i++) 

           {                

  ops[i] = float.Parse(parts[i]) + Zint;

if(ops[i] >0 )

                 LocalScale = ops[i].ToString() + ",";

            }

            LocalScale = LocalScale.Substring(0, LocalScale.Length - 1);

            LocalScale = "scale(" + LocalScale + ")";

            myXml.LastChild.Attributes["transform"].Value = LocalScale;

            SVGPicture.LoadXml(myXml.OuterXml);

        }

Coordinator
May 12, 2011 at 12:20 AM
Edited May 12, 2011 at 12:23 AM

Hello Frank,

Sorry for the late reply, thanks for the codes.

I am looking at the codes right now. Just some few things...

1. On the last line, is the SVGPicture class the same as SvgPictureBox or your customized implementions?
2. How is this used in your codes? In particular, how are you maintaining the zoom factor?

If possible, please can you summit an updated version of the SvgPictureBox, which works with this code?

Best regards,
Paul.