Thank you for helping me! I would like to change the whole data of a path (SVG) using code, so that I can move the position of the path to a specific direction. For example, steve helps me with the following code to add 1 to x in all (x,y) pair to move the path (SVG) to theright direction : Steve's code (but the first x (311) doesn't change. There is some bug)
var data = @"M311.97458,250.39993L213.97533,248.39996 222.37435,216.7998C222.37435,216.7998 ......589.5753,173.99994,593.1753,179.9999......334.3039,253.21373 311.97458,250.39993 z"; '
var replaced = Regex.Replace(data, "((?=[^, ])\d+\.\d+),", (match) => (double.Parse(match.Groups[1].Value) + 1).ToString()+",")
// output: M311.97458,251.39993L214.97533,249.39996 223.37435,217.7998C223.37435,217.7998 ......590.5753,174.99994,594.1753,180.9999......335.3039,254.21373 312.97458,251.39993 z
After I get the output, I tried to put it into data. I wrote a.SetValue(Path.DataProperty,replace)
and a.SetValue(Path.DataProperty,Geometry.Parse(replace))
, but they both don't work. The result shows that
Unprocessed error: System.FormatException: the format of input string is not correct.
How can I alter the output into a correct format for the data of a path(SVG) ? Or should I change my previous code?
Thank you!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…