private void Main() { if (File.Exists(_svgFile)) { SetSvgSize(_svgFile, spnWidth.Value, spnHeight.Value); } } private void SetSvgSize(string file,decimal width,decimal height) { XmlDocument xml = new XmlDocument(); xml.Load(file); var node = xml.DocumentElement; UpdateAttribute(node, "width", width.ToString()); UpdateAttribute(node, "height", height.ToString()); xml.Save(file); } private void UpdateAttribute(XmlNode node,string attrName,string value) { var atts = node.Attributes; for (int i = 0; i < atts.Count; i++) { if (atts[i].Name.Equals(attrName,StringComparison.CurrentCultureIgnoreCase)) { atts[i].Value = value; return; } } XmlAttribute tmp = node.OwnerDocument.CreateAttribute(attrName); tmp.Value = value; node.Attributes.Append(tmp); }
C#修改SVG图片显示大小
免责声明:文章转载自《C#修改SVG图片显示大小》仅用于学习参考。如对内容有疑问,请及时联系本站处理。
上篇android在windows下面coco2dx平台搭建以及一些常见问题的解决sort命令实践下篇
宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=