SvgHelper.cs 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. using DevExpress.Utils;
  2. using DevExpress.Utils.Svg;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data.SqlTypes;
  6. using System.Drawing;
  7. using System.IO;
  8. using System.IO.Ports;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Xml;
  13. namespace DxHelper
  14. {
  15. public static class SvgHelper
  16. {
  17. static readonly Dictionary<string, SvgImage> cache = new Dictionary<string, SvgImage>();
  18. /// <summary>
  19. /// 判断color是否为HtmlColor(HtmlColor格式如#A1B2C3)
  20. /// </summary>
  21. /// <param name="color"></param>
  22. /// <returns></returns>
  23. public static bool IsHtmlColor(string color)
  24. {
  25. if (!color.StartsWith("#")) return false;
  26. if (color.Length != 7) return false;
  27. string r = color.Substring(1, 2);
  28. string g = color.Substring(3, 2);
  29. string b = color.Substring(5, 2);
  30. bool r1 = byte.TryParse(r, System.Globalization.NumberStyles.HexNumber, null, out _);
  31. bool r2 = byte.TryParse(g, System.Globalization.NumberStyles.HexNumber, null, out _);
  32. bool r3 = byte.TryParse(b, System.Globalization.NumberStyles.HexNumber, null, out _);
  33. return r1 & r2 & r3;
  34. }
  35. /// <summary>
  36. /// 将SvgImage转换为Image对象
  37. /// </summary>
  38. /// <param name="svg"></param>
  39. /// <param name="width"></param>
  40. /// <param name="height"></param>
  41. /// <returns></returns>
  42. public static Image SvgToImage(SvgImage svg, int width, int height)
  43. {
  44. var img = svg.Render(new Size(width, height), null, DefaultBoolean.False, DefaultBoolean.False);
  45. return img;
  46. }
  47. /// <summary>
  48. /// 将文件转换为SvgImage对象
  49. /// </summary>
  50. /// <param name="svgFile"></param>
  51. /// <returns></returns>
  52. public static SvgImage LoadFromFile(string svgFile)
  53. {
  54. return SvgLoader.LoadFromFile(svgFile);
  55. }
  56. /// <summary>
  57. /// 新增图片(➕号)
  58. /// </summary>
  59. /// <param name="color"></param>
  60. /// <param name="width"></param>
  61. /// <param name="height"></param>
  62. /// <returns></returns>
  63. public static SvgImage CreateAdd(string color = "#039C23", int width = 24, int height = 24)
  64. {
  65. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  66. + $"<path fill='{color}' d='M27,14h-9V5c0-0.5-0.5-1-1-1h-2c-0.5,0-1,0.5-1,1v9H5c-0.5,0-1,0.5-1,1v2c0,0.5,0.5,1,1,1h9v9c0,0.5,0.5,1,1,1h2c0.5,0,1-0.5,1-1v-9h9c0.5,0,1-0.5,1-1v-2C28,14.5,27.5,14,27,14z'/>"
  67. + "</svg>";
  68. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  69. var svg = SvgLoader.LoadFromStream(ms);
  70. ms.Dispose();
  71. return svg;
  72. }
  73. /// <summary>
  74. /// 编辑图片
  75. /// </summary>
  76. /// <param name="color"></param>
  77. /// <param name="width"></param>
  78. /// <param name="height"></param>
  79. /// <returns></returns>
  80. public static SvgImage CreateEdit(string color = "#1177D7", int width = 24, int height = 24)
  81. {
  82. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  83. + $"<path fill='{color}' d='M27.6,8.2l-3.8-3.8c-0.5-0.5-1.4-0.5-1.9,0l-2.5,2.5l5.8,5.8l2.5-2.5C28.1,9.6,28.1,8.8,27.6,8.2z'/>"
  84. + $"<polygon fill='{color}' points='4,28 9.8,28 4,22.2'/>"
  85. + $"<rect fill='{color}' x='5.8' y='13.4' transform='matrix(0.707 -0.7072 0.7072 0.707 -8.0721 15.4048)' width='17.6' height='8.2'/>"
  86. + "</svg>";
  87. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  88. var svg = SvgLoader.LoadFromStream(ms);
  89. ms.Dispose();
  90. return svg;
  91. }
  92. /// <summary>
  93. /// 移除图片(➖号)
  94. /// </summary>
  95. /// <param name="color"></param>
  96. /// <param name="width"></param>
  97. /// <param name="height"></param>
  98. /// <returns></returns>
  99. public static SvgImage CreateRemove(string color = "#1177D7", int width = 24, int height = 24)
  100. {
  101. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  102. + $"<path fill='{color}' d='M27,18H5c-0.6,0-1-0.5-1-1v-2c0-0.6,0.4-1,1-1h22c0.5,0,1,0.4,1,1v2C28,17.5,27.5,18,27,18z'/>"
  103. + "</svg>";
  104. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  105. var svg = SvgLoader.LoadFromStream(ms);
  106. ms.Dispose();
  107. return svg;
  108. }
  109. /// <summary>
  110. /// 创建一个Svg圆.该圆的圆心在ViewBox的中心
  111. /// </summary>
  112. /// <param name="colorKey">用于生成颜色的一个key,相同的key具有相同的颜色,当colorKey为html颜色时则使用此颜色(如#A1B2FF)</param>
  113. /// <param name="opacity">透明度,默认不透明</param>
  114. /// <param name="viewBoxWidth">视口宽度,默认32px</param>
  115. /// <param name="viewBoxHeight">视口高度,默认32px</param>
  116. /// <param name="radius">半径,默认16px</param>
  117. /// <param name="offsetX">圆心的X轴偏移量,负向左偏移,正向右偏移,默认为0处于视口中心</param>
  118. /// <returns></returns>
  119. public static SvgImage CreateCycle(string colorKey, double opacity = 1, int viewBoxWidth = 32, int viewBoxHeight = 32, int radius = 16, double offsetX = 0)
  120. {
  121. if (colorKey == null) colorKey = "";
  122. if (cache.ContainsKey(colorKey))
  123. return cache[colorKey];
  124. SvgImage svg = new SvgImage();
  125. SvgRoot root = SvgRoot.Create(new SvgElementProperties(), viewBox: new SvgViewBox(0, 0, viewBoxWidth, viewBoxHeight));
  126. svg.Elements.Add(root);
  127. string colorStr;
  128. if (IsHtmlColor(colorKey))
  129. colorStr = colorKey;
  130. else
  131. colorStr = ColorHelper.GetHtmlColor(colorKey);
  132. SvgElementProperties props = new SvgElementProperties
  133. {
  134. Fill = colorStr,
  135. Opacity = opacity//透明度
  136. };
  137. SvgCircle circle = SvgCircle.Create(props, viewBoxWidth / 2 + offsetX, viewBoxHeight / 2, radius);
  138. root.Elements.Add(circle);
  139. //SvgImage未公开Width和Height属性的公共写入,需要通过以下方式可对width和Size赋值
  140. MemoryStream ms = new MemoryStream();
  141. svg.Save(ms);
  142. svg = ms.ToArray();
  143. cache.Add(colorKey, svg);
  144. ms.Dispose();
  145. return svg;
  146. }
  147. /// <summary>
  148. /// 删除或关闭图片(一个叉叉)
  149. /// </summary>
  150. /// <param name="colorStr"></param>
  151. /// <param name="opacity"></param>
  152. /// <returns></returns>
  153. public static SvgImage CreateClose(string colorStr = "#D11C1C", double opacity = 1)
  154. {
  155. if (string.IsNullOrWhiteSpace(colorStr))
  156. colorStr = $"#D11C1C";
  157. string xml = $"<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox='0 0 32 32'>\r\n<g>\r\n<path opacity=\"{opacity}\" fill=\"{colorStr}\" d=\"M18.8,16l6.9-6.9c0.4-0.4,0.4-1,0-1.4l-1.4-1.4c-0.4-0.4-1-0.4-1.4,0L16,13.2L9.1,6.3c-0.4-0.4-1-0.4-1.4,0\r\nL6.3,7.7c-0.4,0.4-0.4,1,0,1.4l6.9,6.9l-6.9,6.9c-0.4,0.4-0.4,1,0,1.4l1.4,1.4c0.4,0.4,1,0.4,1.4,0l6.9-6.9l6.9,6.9\r\nc0.4,0.4,1,0.4,1.4,0l1.4-1.4c0.4-0.4,0.4-1,0-1.4L18.8,16z\"/>\r\n</g>\r\n</svg>";
  158. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  159. var svg = SvgLoader.LoadFromStream(ms);
  160. ms.Dispose();
  161. return svg;
  162. }
  163. /// <summary>
  164. /// 清除图片(一个橡皮擦)
  165. /// </summary>
  166. /// <returns></returns>
  167. public static SvgImage CreateClear()
  168. {
  169. string xml = $"<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox='0 0 32 32'>\r\n<path class=\"Blue\" d=\"M16.1,23.1l-4.4,4.4c-0.7,0.7-1.9,0.7-2.6,0l-6.6-6.6c-0.7-0.7-0.7-1.9,0-2.6L6.9,14L16.1,23.1z\"/><path class=\"Red\" d=\"M27.5,11.8l-10,10l-9.2-9.2l10-10c0.7-0.7,1.9-0.7,2.6,0l6.6,6.6C28.2,9.9,28.2,11,27.5,11.8z\"/></svg>";
  170. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  171. var svg = SvgLoader.LoadFromStream(ms);
  172. ms.Dispose();
  173. return svg;
  174. }
  175. /// <summary>
  176. /// 测距图片
  177. /// </summary>
  178. /// <returns></returns>
  179. public static SvgImage CreateDistanceLine()
  180. {
  181. string xml = $"<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox='0 0 32 32'>"
  182. + "<path class=\"Blue\" d=\"M27,8c-1.7,0-3,1.3-3,3c0,0.5,0.1,0.9,0.3,1.3l-6,6C17.9,18.1,17.5,18,17,18s-0.9,0.1-1.3,0.3l-2-2\r\n\t\tc0.2-0.4,0.3-0.8,0.3-1.3c0-1.7-1.3-3-3-3s-3,1.3-3,3c0,0.5,0.1,0.9,0.3,1.3l-2,2C5.9,18.1,5.5,18,5,18c-1.7,0-3,1.3-3,3s1.3,3,3,3\r\n\t\ts3-1.3,3-3c0-0.5-0.1-0.9-0.3-1.3l2-2c0.4,0.2,0.8,0.3,1.3,0.3s0.9-0.1,1.3-0.3l2,2C14.1,20.1,14,20.5,14,21c0,1.7,1.3,3,3,3\r\n\t\ts3-1.3,3-3c0-0.5-0.1-0.9-0.3-1.3l6-6c0.4,0.2,0.8,0.3,1.3,0.3c1.7,0,3-1.3,3-3S28.7,8,27,8z M5,22c-0.6,0-1-0.4-1-1s0.4-1,1-1\r\n\t\ts1,0.4,1,1S5.6,22,5,22z M11,16c-0.6,0-1-0.4-1-1s0.4-1,1-1s1,0.4,1,1S11.6,16,11,16z M17,22c-0.6,0-1-0.4-1-1s0.4-1,1-1s1,0.4,1,1\r\n\t\tS17.6,22,17,22z M27,12c-0.6,0-1-0.4-1-1s0.4-1,1-1s1,0.4,1,1S27.6,12,27,12z\"/>"
  183. + "</svg>";
  184. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  185. var svg = SvgLoader.LoadFromStream(ms);
  186. ms.Dispose();
  187. return svg;
  188. }
  189. /// <summary>
  190. /// 标点图片(一个五角星)
  191. /// </summary>
  192. /// <param name="color"></param>
  193. /// <param name="width"></param>
  194. /// <param name="height"></param>
  195. /// <returns></returns>
  196. public static SvgImage CreateMarkDot(string color = "#F12233", int width = 24, int height = 24)
  197. {
  198. string xml = $"<svg xmlns=\"http://www.w3.org/2000/svg\" width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  199. + $"<path fill='{color}' d=\"M6,8c0,1.1-0.9,2-2,2c-1.1,0-2-0.9-2-2s0.9-2,2-2C5.1,6,6,6.9,6,8z M10,22c-1.1,0-2,0.9-2,2s0.9,2,2,2c1.1,0,2-0.9,2-2S11.1,22,10,22z M18,16c-1.1,0-2,0.9-2,2s0.9,2,2,2c1.1,0,2-0.9,2-2S19.1,16,18,16z M22,8c-1.1,0-2,0.9-2,2c0,1.1,0.9,2,2,2c1.1,0,2-0.9,2-2C24,8.9,23.1,8,22,8z M28,4c-1.1,0-2,0.9-2,2s0.9,2,2,2c1.1,0,2-0.9,2-2S29.1,4,28,4z\"/><path class=\"Yellow\" d=\"M8,18c0,1.1-0.9,2-2,2c-1.1,0-2-0.9-2-2s0.9-2,2-2C7.1,16,8,16.9,8,18z M12,10c-1.1,0-2,0.9-2,2s0.9,2,2,2c1.1,0,2-0.9,2-2S13.1,10,12,10z M4,26c-1.1,0-2,0.9-2,2s0.9,2,2,2c1.1,0,2-0.9,2-2S5.1,26,4,26z M20,2c-1.1,0-2,0.9-2,2s0.9,2,2,2\r\n\tc1.1,0,2-0.9,2-2S21.1,2,20,2z M28,12c-1.1,0-2,0.9-2,2s0.9,2,2,2c1.1,0,2-0.9,2-2S29.1,12,28,12z\"/>"
  200. + "</svg>";
  201. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  202. var svg = SvgLoader.LoadFromStream(ms);
  203. ms.Dispose();
  204. return svg;
  205. }
  206. /// <summary>
  207. /// 接收天线
  208. /// </summary>
  209. /// <param name="color"></param>
  210. /// <param name="width"></param>
  211. /// <param name="height"></param>
  212. /// <returns></returns>
  213. public static SvgImage CreateAnt(string color = "#1177D7", int width = 24, int height = 24)
  214. {
  215. string xml = $"<svg xmlns=\"http://www.w3.org/2000/svg\" width='{width}px' height='{height}px' viewBox='0 0 329.871 329.871'>" + $"<path fill='{color}' d='M104.839,60c-8.284,0-15,6.716-15,15c0,8.284,6.716,15,15,15c74.439,0,135,60.561,135,135c0,8.284,6.716,15,15,15c8.284,0,15-6.716,15-15C269.839,134.018,195.82,60,104.839,60z'/> <path fill='{color}' d='M159.141,191.91l18.878-18.877c5.858-5.857,5.858-15.355,0.001-21.213c-5.858-5.858-15.355-5.858-21.214,0l-18.878,18.877l-76.34-76.34c-5.857-5.857-15.355-5.857-21.213,0c-53.791,53.791-53.791,141.314,0,195.105c26.057,26.059,60.701,40.408,97.553,40.408c36.852,0,71.496-14.35,97.553-40.408c5.857-5.857,5.857-15.355,0-21.213L159.141,191.91z'/>"
  216. + "</svg>";
  217. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  218. var svg = SvgLoader.LoadFromStream(ms);
  219. ms.Dispose();
  220. return svg;
  221. }
  222. /// <summary>
  223. /// 圆点
  224. /// </summary>
  225. /// <param name="color"></param>
  226. /// <param name="width"></param>
  227. /// <param name="height"></param>
  228. /// <returns></returns>
  229. public static SvgImage CreateGeoDot(string color = "#D11C1C", int width = 24, int height = 24)
  230. {
  231. string xml = $"<svg xmlns=\"http://www.w3.org/2000/svg\" width='{width}px' height='{height}px' viewBox='0 0 32 32'>" + $"<path fill='{color}' d='M16,2C10.5,2,6,6.5,6,12s10,18,10,18s10-12.5,10-18S21.5,2,16,2z M16,16c-2.2,0-4-1.8-4-4s1.8-4,4-4s4,1.8,4,4S18.2,16,16,16z'/>"
  232. + "</svg>";
  233. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  234. var svg = SvgLoader.LoadFromStream(ms);
  235. ms.Dispose();
  236. return svg;
  237. }
  238. /// <summary>
  239. /// 五角星图片
  240. /// </summary>
  241. /// <param name="color"></param>
  242. /// <param name="width"></param>
  243. /// <param name="height"></param>
  244. /// <returns></returns>
  245. public static SvgImage CreatePentagram(string color = "#1177D7", int width = 24, int height = 24)
  246. {
  247. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>" + $"<polygon fill='{color}' points='16,4 19.9,11.9 28.6,13.2 22.3,19.3 23.8,28 16,23.9 8.2,28 9.7,19.3 3.4,13.2 12.1,11.9'/>"
  248. + "</svg>";
  249. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  250. var svg = SvgLoader.LoadFromStream(ms);
  251. ms.Dispose();
  252. return svg;
  253. }
  254. /// <summary>
  255. /// 卫星图片
  256. /// </summary>
  257. /// <param name="color"></param>
  258. /// <param name="width"></param>
  259. /// <param name="height"></param>
  260. /// <returns></returns>
  261. public static SvgImage CreateSat(string color = "#1177D7", int width = 24, int height = 24)
  262. {
  263. string xml = $"<svg xmlns=\"http://www.w3.org/2000/svg\" width='{width}px' height='{height}px' viewBox='0 0 297.131 297.131'>"
  264. + $"<path fill='{color}' d='M196.826,68.171c17.691,0.002,32.084,14.405,32.084,32.108c0,5.54,4.492,10.033,10.033,10.033 c5.54,0,10.033-4.493,10.033-10.033c0-28.768-23.394-52.173-52.148-52.175h-0.001c-5.54,0-10.033,4.491-10.033,10.032 C186.794,63.679,191.286,68.171,196.826,68.171z'/>"
  265. + $"<path fill='{color}' d='M196.827,34.094c36.476,0.002,66.15,29.692,66.15,66.186c0,5.54,4.492,10.033,10.033,10.033 c5.541,0,10.033-4.493,10.033-10.033c0-47.558-38.677-86.25-86.217-86.252c-5.54,0-10.033,4.491-10.033,10.033 C186.794,29.601,191.286,34.094,196.827,34.094z'/>"
  266. + $"<path fill='{color}' d='M187.387,160.099c13.264-13.271,13.264-34.984,0-48.254l-2.119-2.12c-6.631-6.635-15.374-9.952-24.115-9.952 c-8.743,0-17.484,3.316-24.116,9.953l-27.294,27.307c-13.264,13.271-13.264,34.984,0,48.254l2.12,2.12 c6.631,6.635,15.374,9.952,24.114,9.952c8.744,0,17.485-3.316,24.117-9.953L187.387,160.099z'/> "
  267. + $"<path fill='{color}' d='M98.388,125.684l27.295-27.307c7.865-7.869,17.917-12.782,28.811-14.212l-8.862-26.783 c-0.492-1.485-1.323-2.834-2.43-3.94L92.722,2.94C90.841,1.058,88.287,0,85.626,0c-2.662,0-5.215,1.059-7.097,2.94L3.001,78.505 c-3.915,3.918-3.915,10.269,0.002,14.186l50.48,50.501c1.106,1.107,2.456,1.938,3.941,2.432l26.752,8.861 C85.579,143.943,90.31,133.767,98.388,125.684z'/>"
  268. + $"<path fill='{color}' d='M294.128,204.439l-50.481-50.499c-1.107-1.106-2.456-1.938-3.941-2.43l-26.753-8.864 c-1.403,10.541-6.134,20.718-14.212,28.8l-27.294,27.308c-7.865,7.869-17.916,12.782-28.809,14.212l8.862,26.781 c0.492,1.484,1.323,2.834,2.429,3.941l50.478,50.503c1.882,1.882,4.435,2.94,7.097,2.94s5.215-1.058,7.096-2.94l75.529-75.564 C298.045,214.708,298.045,208.357,294.128,204.439z'/>"
  269. + "</svg>";
  270. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  271. var svg = SvgLoader.LoadFromStream(ms);
  272. ms.Dispose();
  273. return svg;
  274. }
  275. public static SvgImage CreateRect(string color = "#1177D7", int width = 24, int height = 24)
  276. {
  277. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 512 512'>"
  278. + $"<path fill='{color}' d='M0,0v512h512V0H0z M465.5,465.5H46.5V46.5h418.9V465.5z'/>"
  279. + "</svg>";
  280. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  281. var svg = SvgLoader.LoadFromStream(ms);
  282. ms.Dispose();
  283. return svg;
  284. }
  285. /// <summary>
  286. /// 时隙参估图片
  287. /// </summary>
  288. /// <param name="color"></param>
  289. /// <param name="width"></param>
  290. /// <param name="height"></param>
  291. /// <returns></returns>
  292. public static SvgImage CreateSlotCg(string color = "#1177D7", int width = 24, int height = 24)
  293. {
  294. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  295. + $"<path fill='{color}' d='M6,30H2V2h4V30z M12,2H8v28h4V2z M18,2h-4v28h4V2z M24,2h-4v28h4V2z M30,2h-4v28h4V2z'/>"
  296. + "</svg>";
  297. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  298. var svg = SvgLoader.LoadFromStream(ms);
  299. ms.Dispose();
  300. return svg;
  301. }
  302. /// <summary>
  303. /// 导出图像图片
  304. /// </summary>
  305. /// <returns></returns>
  306. public static SvgImage CreateExportImg()
  307. {
  308. string xml = $"<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox='0 0 32 32'>" + "<style type=\"text/css\">\r\n\t.Black{fill:#727272;}\r\n\t.Blue{fill:#1177D7;}\r\n\t.Red{fill:#D11C1C;}\r\n\t.st0{opacity:0.2;}\r\n</style>\r\n<path class=\"Black\" d=\"M8,4h18v6h2V3c0-0.5-0.5-1-1-1H7C6.5,2,6,2.5,6,3v7h2V4z\"/>\r\n<path class=\"Black\" d=\"M26,28H8V16H6v13c0,0.5,0.5,1,1,1h20c0.5,0,1-0.5,1-1V16h-2V28z\"/>\r\n<path class=\"Red\" d=\"M29,8H5C4.4,8,4,8.4,4,9v10c0,0.6,0.4,1,1,1h24c0.6,0,1-0.4,1-1V9C30,8.4,29.6,8,29,8z M9.5,17.9H8v-7.7h1.5\r\n\tV17.9z M18.9,17.9h-1.5v-4.6c0-0.5,0-1,0.1-1.6l0,0c-0.1,0.5-0.2,0.8-0.2,1l-1.6,5.2h-1.3l-1.6-5.2c0-0.1-0.1-0.5-0.2-1.1l0,0\r\n\tc0,0.8,0.1,1.4,0.1,2v4.3h-1.4v-7.7h2.2l1.4,4.6c0.1,0.4,0.2,0.7,0.2,1.1l0,0c0.1-0.4,0.2-0.8,0.3-1.1l1.4-4.6H19v7.7H18.9z\r\n\t M26,17.3c-0.7,0.4-1.5,0.7-2.5,0.7c-1.1,0-2-0.3-2.6-1S20,15.4,20,14.2s0.3-2.2,1-3s1.6-1.1,2.8-1.1c0.7,0,1.4,0.1,1.9,0.3V12\r\n\tc-0.5-0.3-1.2-0.5-1.9-0.5c-0.6,0-1.2,0.2-1.6,0.7s-0.6,1.1-0.6,1.9c0,0.8,0.2,1.4,0.5,1.8c0.4,0.4,0.8,0.6,1.5,0.6\r\n\tc0.4,0,0.7-0.1,0.9-0.2v-1.5h-1.4v-1.4H26V17.3z\"/>\r\n<g class=\"st0\">\r\n\t<path class=\"Blue\" d=\"M29,8H5C4.4,8,4,8.4,4,9v10c0,0.6,0.4,1,1,1h24c0.6,0,1-0.4,1-1V9C30,8.4,29.6,8,29,8z M9.5,17.9H8v-7.7h1.5\r\n\t\tV17.9z M18.9,17.9h-1.5v-4.6c0-0.5,0-1,0.1-1.6l0,0c-0.1,0.5-0.2,0.8-0.2,1l-1.6,5.2h-1.3l-1.6-5.2c0-0.1-0.1-0.5-0.2-1.1l0,0\r\n\t\tc0,0.8,0.1,1.4,0.1,2v4.3h-1.4v-7.7h2.2l1.4,4.6c0.1,0.4,0.2,0.7,0.2,1.1l0,0c0.1-0.4,0.2-0.8,0.3-1.1l1.4-4.6H19v7.7H18.9z M26,17.3c-0.7,0.4-1.5,0.7-2.5,0.7c-1.1,0-2-0.3-2.6-1S20,15.4,20,14.2s0.3-2.2,1-3s1.6-1.1,2.8-1.1c0.7,0,1.4,0.1,1.9,0.3V12\r\n\t\tc-0.5-0.3-1.2-0.5-1.9-0.5c-0.6,0-1.2,0.2-1.6,0.7s-0.6,1.1-0.6,1.9c0,0.8,0.2,1.4,0.5,1.8c0.4,0.4,0.8,0.6,1.5,0.6\r\n\t\tc0.4,0,0.7-0.1,0.9-0.2v-1.5h-1.4v-1.4H26V17.3z\"/>\r\n</g>"
  309. + "</svg>";
  310. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  311. var svg = SvgLoader.LoadFromStream(ms);
  312. ms.Dispose();
  313. return svg;
  314. }
  315. public static SvgImage CreateImport(int width = 24, int height = 24)
  316. {
  317. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  318. + $"<path fill='#727272' d='M12,12H8V6h4V12z M24,17v1v9c0,0.6-0.4,1-1,1H3c-0.6,0-1-0.4-1-1V7c0-0.6,0.4-1,1-1h3v8h14L24,17z M20,18H6v6h14V18z'/>"
  319. + "<polygon fill='#039C23' points='32,6 24,6 24,2 16,8 24,14 24,10 32,10'/>"
  320. + "</svg>";
  321. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  322. var svg = SvgLoader.LoadFromStream(ms);
  323. ms.Dispose();
  324. return svg;
  325. }
  326. /// <summary>
  327. /// 导出Excel图片
  328. /// </summary>
  329. /// <returns></returns>
  330. public static SvgImage CreateExportXlsx()
  331. {
  332. string xml = $"<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox='0 0 32 32'>" + "<style type=\"text/css\">\r\n\t.Green{fill:#039C23;}\r\n\t.Black{fill:#727272;}\r\n\t.Blue{fill:#1177D7;}\r\n\t.st0{opacity:0.3;}\r\n</style>\r\n<path class=\"Black\" d=\"M8,4h18v6h2V3c0-0.5-0.5-1-1-1H7C6.5,2,6,2.5,6,3v7h2V4z\"/>\r\n<path class=\"Black\" d=\"M26,28H8V18H6v11c0,0.5,0.5,1,1,1h20c0.5,0,1-0.5,1-1V18h-2V28z\"/>\r\n<path class=\"Green\" d=\"M31,8H3C2.4,8,2,8.4,2,9v10c0,0.6,0.4,1,1,1h28c0.6,0,1-0.4,1-1V9C32,8.4,31.6,8,31,8z M9.1,18l-1.3-2.5\r\n\tc-0.1-0.1-0.1-0.3-0.2-0.5l0,0c0,0.1-0.1,0.3-0.2,0.5L6.1,18H4l2.5-3.9l-2.2-3.9h2.1l1.1,2.3c0.1,0.2,0.2,0.4,0.2,0.7l0,0\r\n\tc0-0.2,0.1-0.4,0.2-0.7l1.2-2.3H11L8.7,14l2.4,3.9L9.1,18L9.1,18z M16.7,18h-4.6v-7.7h1.7v6.3h2.9V18z M22.4,16.9\r\n\tc-0.2,0.3-0.4,0.5-0.7,0.7s-0.6,0.3-1,0.4s-0.8,0.1-1.2,0.1c-0.4,0-0.8,0-1.2-0.1c-0.4-0.1-0.7-0.2-1-0.3V16c0.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s0.4,0.2,0.6,0.3\r\n\t\tc0.3,0.1,0.6,0.3,0.8,0.4c0.2,0.1,0.5,0.3,0.6,0.5c0.2,0.2,0.3,0.4,0.4,0.6s0.1,0.5,0.1,0.8C22.6,16.3,22.5,16.6,22.4,16.9z M28.1,18l-1.3-2.5c-0.1-0.1-0.1-0.3-0.2-0.5l0,0c0,0.1-0.1,0.3-0.2,0.5L25.1,18H23l2.5-3.9l-2.2-3.9h2.1l1.1,2.3\r\n\t\tc0.1,0.2,0.2,0.4,0.2,0.7l0,0c0-0.2,0.1-0.4,0.2-0.7l1.2-2.3H30L27.7,14l2.4,3.9L28.1,18L28.1,18z\"/>\r\n</g>"
  333. + "</svg>";
  334. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  335. var svg = SvgLoader.LoadFromStream(ms);
  336. ms.Dispose();
  337. return svg;
  338. }
  339. /// <summary>
  340. /// 导出Csv图片
  341. /// </summary>
  342. /// <returns></returns>
  343. public static SvgImage CreateExportCsv()
  344. {
  345. string xml = $"<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox='0 0 32 32'>" + "<style type=\"text/css\">.Black{fill:#727272;}.Blue{fill:#1177D7;}</style><path class=\"Black\" d=\"M8,4h18v6h2V3c0-0.5-0.5-1-1-1H7C6.5,2,6,2.5,6,3v7h2V4z\"/>\r\n<path class=\"Black\" d=\"M26,28H8V18H6v11c0,0.5,0.5,1,1,1h20c0.5,0,1-0.5,1-1V18h-2V28z\"/>\r\n<path class=\"Blue\" d=\"M29,8h-1h-2H8H6H5C4.4,8,4,8.4,4,9v10c0,0.6,0.4,1,1,1h1h2h18h2h1c0.6,0,1-0.4,1-1V9C30,8.4,29.6,8,29,8z\r\n\t M12.9,12c-0.5-0.3-1-0.5-1.6-0.5c-0.7,0-1.2,0.2-1.6,0.7C9.2,12.6,9,13.3,9,14c0,0.7,0.2,1.3,0.6,1.8s0.9,0.7,1.6,0.7\r\n\tc0.6,0,1.2-0.2,1.7-0.5v1.6c-0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,0.4c0.2,0.1,0.4,0.3,0.6,0.5\r\n\tc0.2,0.2,0.3,0.4,0.4,0.6c0.1,0.2,0.1,0.5,0.1,0.8C19.5,16.1,19.4,16.5,19.2,16.8z M26,13.2l-1.5,4.7h-1.8L20.3,10H22l1.5,5.5\r\n\tc0.1,0.3,0.1,0.5,0.1,0.8h0c0-0.2,0.1-0.5,0.2-0.8l1.5-5.5H26h1L26,13.2z\"/>"
  346. + "</svg>";
  347. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  348. var svg = SvgLoader.LoadFromStream(ms);
  349. ms.Dispose();
  350. return svg;
  351. }
  352. /// <summary>
  353. /// 时差线图片
  354. /// </summary>
  355. /// <returns></returns>
  356. public static SvgImage CreateDtoLine(string color = "#039C23", int width = 24, int height = 24)
  357. {
  358. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  359. + $"<path fill='{color}' d='M32,16c0,4.4-3.6,8-8,8c-0.2,0-0.3,0-0.5,0c1.6-2.3,2.5-5.1,2.5-8s-0.9-5.6-2.5-8c0.2,0,0.3,0,0.5,0C28.4,8,32,11.6,32,16z M14,16c0-3.9,2.3-7.5,5.8-9.1C17.7,5.1,15,4,12,4C5.4,4,0,9.4,0,16c0,6.6,5.4,12,12,12c3,0,5.7-1.1,7.8-2.9C16.3,23.5,14,19.9,14,16z M21.3,8.5C18.2,9.6,16,12.5,16,16s2.2,6.4,5.3,7.5C23,21.5,24,18.9,24,16S23,10.5,21.3,8.5z'/>"
  360. + "</svg>";
  361. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  362. var svg = SvgLoader.LoadFromStream(ms);
  363. ms.Dispose();
  364. return svg;
  365. }
  366. /// <summary>
  367. /// 频差线图片
  368. /// </summary>
  369. /// <returns></returns>
  370. public static SvgImage CreateDfoLine(string color = "#039C23", int width = 24, int height = 24)
  371. {
  372. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  373. + $"<path opacity='0.75' fill='{color}' d='M20.6,8.6C17.8,10.8,16,14.2,16,18c0,0.6-0.1,1.1-0.4,1.6C15,21,13.6,22,12,22c-2.2,0-4-1.8-4-4c0-3.3-2.7-6-6-6v2v2c1.1,0,2,0.9,2,2c0,4.4,3.6,8,8,8c0.7,0,1.4-0.1,2-0.3c0,0,0.1,0,0.1,0c0.2-0.1,0.5-0.1,0.7-0.2c0.1,0,0.1,0,0.2-0.1c0.3-0.1,0.5-0.2,0.8-0.4c0.1-0.1,0.3-0.2,0.4-0.2c0.1-0.1,0.2-0.1,0.3-0.2c0.2-0.1,0.3-0.2,0.4-0.3c0.1-0.1,0.2-0.2,0.3-0.2c1.7-1.5,2.7-3.6,2.7-6c0-2.7,1.4-5.1,3.4-6.6c1.3-0.9,2.9-1.4,4.6-1.4V8.3V6C25.2,6,22.6,7,20.6,8.6z'/>"
  374. + $"<path fill='{color}' d='M14,20c0.6,0,1.1-0.1,1.6-0.4C15,21,13.6,22,12,22c-2.2,0-4-1.8-4-4c0-3.3-2.7-6-6-6l2-2c3.3,0,6,2.7,6,6C10,18.2,11.8,20,14,20z M20,18c0,2.4-1.1,4.5-2.7,6c0.1-0.1,0.3-0.2,0.4-0.3l2-2c1.4-1.4,2.3-3.4,2.3-5.7c0-1.7,0.5-3.3,1.4-4.6C21.4,12.9,20,15.3,20,18z M28,6v2.3V10l2-2V4L28,6z'/>"
  375. + $"<path opacity='0.5' fill='{color}' d='M20.6,8.6C22.6,7,25.2,6,28,6l2-2C26.2,4,22.8,5.8,20.6,8.6z'/>"
  376. + "</svg>";
  377. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  378. var svg = SvgLoader.LoadFromStream(ms);
  379. ms.Dispose();
  380. return svg;
  381. }
  382. /// <summary>
  383. /// 测向线图片
  384. /// </summary>
  385. /// <returns></returns>
  386. public static SvgImage CreateCxLine(string color1 = "#FFB115", string color2 = "#039C23", int width = 24, int height = 24)
  387. {
  388. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  389. + $"<rect x='8.9' y='15' fill='{color1}' transform='matrix(0.7071 -0.7071 0.7071 0.7071 -6.6274 16)' width='14.1' height='2'/>"
  390. + $"<path fill='{color2}' d='M10,26H4v-4h6V26z M28,6h-6v4h6V6z'/>"
  391. + "</svg>";
  392. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  393. var svg = SvgLoader.LoadFromStream(ms);
  394. ms.Dispose();
  395. return svg;
  396. }
  397. /// <summary>
  398. /// GDOP
  399. /// </summary>
  400. /// <returns></returns>
  401. public static SvgImage CreateGDOP(string color = "#1177D7", int width = 24, int height = 24)
  402. {
  403. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  404. + $"<path opacity='0.35' fill='#727272' d='M16,0C7.2,0,0,7.2,0,16s7.2,16,16,16s16-7.2,16-16S24.8,0,16,0z M16,30C8.3,30,2,23.7,2,16S8.3,2,16,2\ts14,6.3,14,14S23.7,30,16,30z M16,6C10.5,6,6,10.5,6,16c0,5.5,4.5,10,10,10s10-4.5,10-10C26,10.5,21.5,6,16,6z M16,24c-4.4,0-8-3.6-8-8s3.6-8,8-8s8,3.6,8,8S20.4,24,16,24z M16,12c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4s4-1.8,4-4C20,13.8,18.2,12,16,12zM16,18c-1.1,0-2-0.9-2-2c0-1.1,0.9-2,2-2s2,0.9,2,2C18,17.1,17.1,18,16,18z'/>"
  405. + $"<path fill='{color}' d='M15,4c-0.6,0-1,0.4-1,1c0,0.6,0.4,1,1,1c6.1,0,11,4.9,11,11c0,4.4-3.6,8-8,8s-8-3.6-8-8c0-2.8,2.2-5,5-5s5,2.2,5,5c0,1.7-1.3,3-3,3s-3-1.3-3-3c0-0.6,0.4-1,1-1s1,0.4,1,1c0,0.6,0.4,1,1,1s1-0.4,1-1c0-1.7-1.3-3-3-3s-3,1.3-3,3c0,2.8,2.2,5,5,5s5-2.2,5-5c0-3.9-3.1-7-7-7s-7,3.1-7,7c0,5.5,4.5,10,10,10s10-4.5,10-10C28,9.8,22.2,4,15,4z'/>"
  406. + "</svg>";
  407. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  408. var svg = SvgLoader.LoadFromStream(ms);
  409. ms.Dispose();
  410. return svg;
  411. }
  412. /// <summary>
  413. /// 查看参估结果
  414. /// </summary>
  415. /// <returns></returns>
  416. public static SvgImage CreateShowCafRes(string color = "#387CB7", int width = 24, int height = 24)
  417. {
  418. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  419. + $"<path fill='{color}' d='M27,2H1C0.5,2,0,2.5,0,3v7h28V3C28,2.5,27.5,2,27,2z'/>"
  420. + $"<path opacity='0.5' fill='#737374' d='M26,16.2V10h2v6.9C27.4,16.6,26.7,16.4,26,16.2z M14.1,24.7L13.9,24H2V10H0v15c0,0.5,0.5,1,1,1h13.8C14.4,25.3,14.2,24.8,14.1,24.7z'/>"
  421. + $"<path fill='#737374' d='M24,18c-5.7,0-8,6-8,6s2.3,6,8,6s8-6,8-6S29.7,18,24,18z M24,28c-2.2,0-4-1.8-4-4c0-2.2,1.8-4,4-4c2.2,0,4,1.8,4,4C28,26.2,26.2,28,24,28z M26,24c0,1.1-0.9,2-2,2s-2-0.9-2-2s0.9-2,2-2S26,22.9,26,24z'/>"
  422. + "</svg>";
  423. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  424. var svg = SvgLoader.LoadFromStream(ms);
  425. ms.Dispose();
  426. return svg;
  427. }
  428. /// <summary>
  429. /// 查看测向结果
  430. /// </summary>
  431. /// <returns></returns>
  432. public static SvgImage CreateShowCxRes(string color = "#1177D7", int width = 24, int height = 24)
  433. {
  434. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  435. + $"<polygon fill='{color}' points='25.4,9.4 30,14 30,2 18,2 22.6,6.6 16,13.2 9.4,6.6 14,2 2,2 2,14 6.6,9.4 13.2,16 6.6,22.6 2,18 2,30 14,30 9.4,25.4 16,18.8 22.6,25.4 18,30 30,30 30,18 25.4,22.6 18.8,16'/>"
  436. + "</svg>";
  437. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  438. var svg = SvgLoader.LoadFromStream(ms);
  439. ms.Dispose();
  440. return svg;
  441. }
  442. /// <summary>
  443. /// 查看检测结果
  444. /// </summary>
  445. /// <returns></returns>
  446. public static SvgImage CreateShowCheckRes(string color = "#1177D7", int width = 24, int height = 24)
  447. {
  448. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  449. + $"<path opacity='0.5' fill='#727272' d='M14,24H2v-8h12V24z M28,16H16v8h12V16z'/>"
  450. + $"<polygon fill='{color}' points='30,8 28,8 28,4 26,4 26,8 16,8 16,4 14,4 14,8 4,8 4,4 2,4 2,8 0,8 0,10 2,10 2,14 4,14 4,10 14,10 14,14 16,14 16,10 26,10 26,14 28,14 28,10 30,10'/>"
  451. + "</svg>";
  452. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  453. var svg = SvgLoader.LoadFromStream(ms);
  454. ms.Dispose();
  455. return svg;
  456. }
  457. /// <summary>
  458. /// 手动定位
  459. /// </summary>
  460. /// <returns></returns>
  461. public static SvgImage CreatePosManual(string color = "#1177D7", int width = 24, int height = 24)
  462. {
  463. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  464. + $"<path fill='{color}' d='M29,14h-3.1c-0.2-2.3-1.1-4.4-2.5-6l2.2-2.2c0.4-0.4,0.4-1,0-1.4s-1-0.4-1.4,0L22,6.5c-1.7-1.4-3.8-2.3-6-2.5\r\nV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oryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  467. var svg = SvgLoader.LoadFromStream(ms);
  468. ms.Dispose();
  469. return svg;
  470. }
  471. /// <summary>
  472. /// 重新定位
  473. /// </summary>
  474. /// <returns></returns>
  475. public static SvgImage CreateRepos(string color = "#1177D7", int width = 24, int height = 24)
  476. {
  477. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  478. + $"<path fill='{color}' d='M16,30L16,30L16,30C14.5,28.3,6,13.5,6,11C6,5.5,10.5,0,16,0s10,5.5,10,11C26,13.5,17.5,28.3,16,30z'/>"
  479. + $"<path fill='#FFFFFF' d='M16,4c3.3,0,6,2.7,6,6s-2.7,6-6,6s-6-2.7-6-6S12.7,4,16,4z'/>"
  480. + "</svg>";
  481. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  482. var svg = SvgLoader.LoadFromStream(ms);
  483. ms.Dispose();
  484. return svg;
  485. }
  486. /// <summary>
  487. /// 使用镜像点
  488. /// </summary>
  489. /// <returns></returns>
  490. public static SvgImage CreateUseMirr(string color = "#1177D7", int width = 24, int height = 24)
  491. {
  492. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  493. + $"<polygon fill='#727272' points='4,28 4,2 2,2 2,30 30,30 30,28'/>"
  494. + $"<path fill='{color}' d='M26,18c0-6.6-5.4-12-12-12V2V0L6,8l8,8v-6c4.4,0,8,3.6,8,8h-6l8,8l8-8H26z'/>"
  495. + "</svg>";
  496. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  497. var svg = SvgLoader.LoadFromStream(ms);
  498. ms.Dispose();
  499. return svg;
  500. }
  501. /// <summary>
  502. /// 跳转|转到
  503. /// </summary>
  504. /// <returns></returns>
  505. public static SvgImage CreateGoto(string color = "#1177D7", int width = 24, int height = 24)
  506. {
  507. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  508. + $"<path fill='{color}' d='M18,8l10,10L18,28v-8H5c-0.5,0-1-0.5-1-1V4h4v12h10V8z'/>"
  509. + "</svg>";
  510. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  511. var svg = SvgLoader.LoadFromStream(ms);
  512. ms.Dispose();
  513. return svg;
  514. }
  515. /// <summary>
  516. /// 信号识别
  517. /// </summary>
  518. /// <returns></returns>
  519. public static SvgImage CreateSigProc(int width = 24, int height = 24)
  520. {
  521. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  522. + $"<circle fill='#039C23' cx='9' cy='9' r='7'/>"
  523. + $"<path fill='#FFB115' d='M24.5,2.4c0.3-0.6,0.8-0.6,1.1,0l6.3,12.5c0.3,0.6,0.1,1.1-0.5,1.1H18.7c-0.6,0-0.8-0.5-0.5-1.1L24.5,2.4z'/>"
  524. + $"<path fill='#D11C1C' d='M2.4,25.9c-0.5-0.5-0.5-1.3,0-1.8l5.7-5.7c0.5-0.5,1.3-0.5,1.8,0l5.7,5.7c0.5,0.5,0.5,1.3,0,1.8l-5.7,5.7 c-0.5,0.5-1.3,0.5-1.8,0L2.4,25.9z'/>"
  525. + "</svg>";
  526. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  527. var svg = SvgLoader.LoadFromStream(ms);
  528. ms.Dispose();
  529. return svg;
  530. }
  531. /// <summary>
  532. /// 目标轨迹
  533. /// </summary>
  534. /// <returns></returns>
  535. public static SvgImage CreateTrack(int width = 24, int height = 24)
  536. {
  537. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  538. + $"<polygon fill='#039C23' points='4,8 10,2 16,8 12,8 12,14 8,14 8,8'/>"
  539. + $"<path fill='#FFB115' d='M19.5,4H28v8.5l-2.8-2.8l-4.2,4.2l-2.8-2.8l4.2-4.2L19.5,4z M14,19.5V28H5.5l2.8-2.8l-4.2-4.2l2.8-2.8l4.2,4.2L14,19.5z'/>"
  540. + $"<polygon fill='#D11C1C' points='18,24 24,30 30,24 26,24 26,18 22,18 22,24'/>"
  541. + "</svg>";
  542. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  543. var svg = SvgLoader.LoadFromStream(ms);
  544. ms.Dispose();
  545. return svg;
  546. }
  547. public static SvgImage CreateInfo(string color = "#1177D7", int width = 24, int height = 24)
  548. {
  549. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  550. + $"<path fill='{color}' d='M16,2C8.3,2,2,8.3,2,16s6.3,14,14,14s14-6.3,14-14S23.7,2,16,2z M16,6c1.1,0,2,0.9,2,2s-0.9,2-2,2s-2-0.9-2-2S14.9,6,16,6z M20,24h-8v-2h2v-8h-2v-2h2h4v10h2V24z'/>"
  551. + $"<path fill='{color}' d='M16,2C8.3,2,2,8.3,2,16s6.3,14,14,14s14-6.3,14-14S23.7,2,16,2z M16,6c1.1,0,2,0.9,2,2s-0.9,2-2,2s-2-0.9-2-2S14.9,6,16,6z M20,24h-8v-2h2v-8h-2v-2h2h4v10h2V24z'/>"
  552. + "</svg>";
  553. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  554. var svg = SvgLoader.LoadFromStream(ms);
  555. ms.Dispose();
  556. return svg;
  557. }
  558. public static SvgImage CreateWarning(string color = "#FFB115", int width = 24, int height = 24)
  559. {
  560. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  561. + $"<path fill='{color}' d='M14.9,4.7c0.6-1,1.5-1,2.1,0l12.7,21.5c0.6,1,0.1,1.8-1,1.8H3.3c-1.2,0-1.6-0.8-1-1.8L14.9,4.7z'/>"
  562. + $"<circle fill='#727272' cx='16' cy='22' r='2'/>"
  563. + $"<rect x='14' y='10' fill='#727272' width='4' height='8'/>"
  564. + "</svg>";
  565. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  566. var svg = SvgLoader.LoadFromStream(ms);
  567. ms.Dispose();
  568. return svg;
  569. }
  570. public static SvgImage CreateError(string color = "#D11C1C", int width = 24, int height = 24)
  571. {
  572. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  573. + $"<path fill='{color}' d='M16,2C8.3,2,2,8.3,2,16s6.3,14,14,14s14-6.3,14-14S23.7,2,16,2z M16,24c-1.1,0-2-0.9-2-2s0.9-2,2-2s2,0.9,2,2S17.1,24,16,24z M18,18h-4V8h4V18z'/>"
  574. + "</svg>";
  575. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  576. var svg = SvgLoader.LoadFromStream(ms);
  577. ms.Dispose();
  578. return svg;
  579. }
  580. public static SvgImage CreateRefresh(string color = "#039C23", int width = 24, int height = 24)
  581. {
  582. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  583. + $"<path fill='{color}' d='M24.5,7.5C22.3,5.3,19.3,4,16,4C10.1,4,5.1,8.3,4.2,14h4.1c0.9-3.4,4-6,7.7-6c2.2,0,4.2,0.9,5.6,2.4L18,14h5.7h4.1H28V4L24.5,7.5z'/>"
  584. + $"<path fill='{color}' d='M16.2,24c-2.2,0-4.2-0.9-5.6-2.4l3.6-3.6H8.4H4.4H4.2v10l3.5-3.5c2.2,2.2,5.2,3.5,8.5,3.5C22.1,28,27,23.7,28,18h-4.1C23,21.4,19.9,24,16.2,24z'/>"
  585. + "</svg>";
  586. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  587. var svg = SvgLoader.LoadFromStream(ms);
  588. ms.Dispose();
  589. return svg;
  590. }
  591. public static SvgImage CreateDownload(string color = "#1177D7", int width = 24, int height = 24)
  592. {
  593. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  594. + $"<path fill='{color}' d='M25.2,9.2L18,16.3V2h-4v14.3L6.8,9.2L4,12l12,12l12-12L25.2,9.2z M28,30H4v-4h24V30z'/>"
  595. + "</svg>";
  596. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  597. var svg = SvgLoader.LoadFromStream(ms);
  598. ms.Dispose();
  599. return svg;
  600. }
  601. public static SvgImage CreateTskStateStoped(string color = "#D11C1C", int width = 24, int height = 24)
  602. {
  603. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  604. + $"<path fill='{color}' d='M16,4C9.4,4,4,9.4,4,16s5.4,12,12,12s12-5.4,12-12S22.6,4,16,4z M16,8c1.5,0,2.9,0.4,4.1,1.1l-11,11C8.4,18.9,8,17.5,8,16C8,11.6,11.6,8,16,8zM16,24c-1.5,0-2.8-0.4-4-1.1L22.9,12c0.7,1.2,1.1,2.5,1.1,4C24,20.4,20.4,24,16,24z'/>"
  605. + "</svg>";
  606. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  607. var svg = SvgLoader.LoadFromStream(ms);
  608. ms.Dispose();
  609. return svg;
  610. }
  611. public static SvgImage CreateTskStateWaitToRun(string color = "#1177D7", int width = 24, int height = 24)
  612. {
  613. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  614. + $"<polygon fill='#727272' points='16,16 16,10 14,10 14,18 22,18 22,16 '/>"
  615. + $"<path fill='{color}' d='M16,2C11.6,2,7.7,4,5.2,7.2L2,4v10h0.2h4H12l-4-4c1.8-2.4,4.7-4,8-4c5.5,0,10,4.5,10,10c0,5.5-4.5,10-10,10c-4.8,0-8.9-3.4-9.8-8h-4c1,6.8,6.8,12,13.8,12c7.7,0,14-6.3,14-14S23.7,2,16,2z'/>"
  616. + "</svg>";
  617. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  618. var svg = SvgLoader.LoadFromStream(ms);
  619. ms.Dispose();
  620. return svg;
  621. }
  622. public static SvgImage CreateTskStateRunning(string color = "#039C23", int width = 24, int height = 24)
  623. {
  624. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  625. + $"<path fill='{color}' d='M16,2C8.3,2,2,8.3,2,16s6.3,14,14,14s14-6.3,14-14S23.7,2,16,2z M12,22V10l10,6L12,22z'/>"
  626. + "</svg>";
  627. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  628. var svg = SvgLoader.LoadFromStream(ms);
  629. ms.Dispose();
  630. return svg;
  631. }
  632. public static SvgImage CreateTskStateStopping(string color = "#D11C1C", int width = 24, int height = 24)
  633. {
  634. string xml = $"<svg xmlns='http://www.w3.org/2000/svg\' width='{width}px' height='{height}px' viewBox='0 0 32 32'>"
  635. + $"<polygon fill='#727272' points='16,16 16,8 14,8 14,18 24,18 24,16'/>"
  636. + $"<path fill='{color}' d='M16,2C8.3,2,2,8.3,2,16s6.3,14,14,14s14-6.3,14-14S23.7,2,16,2z M16,26c-5.5,0-10-4.5-10-10c0-5.5,4.5-10,10-10s10,4.5,10,10C26,21.5,21.5,26,16,26z'/>"
  637. + "</svg>";
  638. MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));
  639. var svg = SvgLoader.LoadFromStream(ms);
  640. ms.Dispose();
  641. return svg;
  642. }
  643. }
  644. }