暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

TestingHelpData.cs 9.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. using System.Collections.Generic;
  2. namespace Unity.PlasticSCM.Editor.Help
  3. {
  4. internal static class TestingHelpData
  5. {
  6. internal static HelpData GetSample1()
  7. {
  8. HelpData result = new HelpData();
  9. result.CleanText = "There are some .private files" + System.Environment.NewLine + System.Environment.NewLine +
  10. "Do not panic, these are copies Plastic creates to preserve files it can't overwrite." + System.Environment.NewLine + System.Environment.NewLine +
  11. "Suppose you have a private file \"src / foo.c\", then switch your workspace to a branch where someone added \"src / foo.c\". Plastic downloads the new file because it is under source control and yours is not. But, it can't delete yours, so it renames it as .private.0." + System.Environment.NewLine + System.Environment.NewLine +
  12. "Makes sense?" + System.Environment.NewLine + System.Environment.NewLine +
  13. "Learn more:" + System.Environment.NewLine +
  14. "* You have some files ready to be added to version control" + System.Environment.NewLine +
  15. "* Are you missing any changes?" + System.Environment.NewLine +
  16. "* Tips to work with Visual Studio projects." + System.Environment.NewLine + System.Environment.NewLine +
  17. "This is just text after links (like this help link -> content2) to verify that the format is preserved." + System.Environment.NewLine + System.Environment.NewLine +
  18. "And then that another link at the end works, with some bold text at the end, final!!";
  19. // IMPORTANT! We need single EOL chars to calculate the positions,
  20. // otherwise positions are wrong calculated
  21. result.CleanText = result.CleanText.Replace("\r\n", "\n");
  22. result.FormattedBlocks = new List<HelpFormat>();
  23. result.FormattedBlocks.Add(new HelpFormat()
  24. {
  25. Type = HelpFormat.FormatType.Title,
  26. Position = 0,
  27. Length = 29
  28. });
  29. result.FormattedBlocks.Add(new HelpFormat()
  30. {
  31. Type = HelpFormat.FormatType.Bold,
  32. Position = result.CleanText.IndexOf("not panic"),
  33. Length = "not panic".Length
  34. });
  35. result.FormattedBlocks.Add(new HelpFormat()
  36. {
  37. Type = HelpFormat.FormatType.Underline,
  38. Position = result.CleanText.IndexOf("overwrite"),
  39. Length = "overwrite".Length
  40. });
  41. result.FormattedBlocks.Add(new HelpFormat()
  42. {
  43. Type = HelpFormat.FormatType.Bold,
  44. Position = result.CleanText.IndexOf("Makes sense?"),
  45. Length = "Makes sense?".Length
  46. });
  47. result.Links = new List<HelpLink>();
  48. result.Links.Add(new HelpLink()
  49. {
  50. Position = result.CleanText.IndexOf("You have some files ready to be added to version control"),
  51. Length = "You have some files ready to be added to version control".Length,
  52. Link = HelpLinkData.AsString(HelpLink.LinkType.Action, "plasticscm-pendingchanges-filestoadd")
  53. });
  54. result.Links.Add(new HelpLink()
  55. {
  56. Position = result.CleanText.IndexOf("Are you missing any changes?"),
  57. Length = "Are you missing any changes?".Length,
  58. Link = HelpLinkData.AsString(HelpLink.LinkType.Action, "plasticscm-pendingchanges-missingchanges")
  59. });
  60. result.Links.Add(new HelpLink()
  61. {
  62. Position = result.CleanText.IndexOf("Tips to work with Visual Studio projects."),
  63. Length = "Tips to work with Visual Studio projects.".Length,
  64. Link = HelpLinkData.AsString(HelpLink.LinkType.Action, "plasticscm-pendingchanges-visualstudio")
  65. });
  66. result.FormattedBlocks.Add(new HelpFormat()
  67. {
  68. Type = HelpFormat.FormatType.Bold,
  69. Position = result.CleanText.IndexOf("verify that the format is preserved"),
  70. Length = "verify that the format is preserved".Length
  71. });
  72. result.Links.Add(new HelpLink()
  73. {
  74. Position = result.CleanText.IndexOf("this help link"),
  75. Length = "this help link".Length,
  76. Link = HelpLinkData.AsString(HelpLink.LinkType.Help, "sample2")
  77. });
  78. result.Links.Add(new HelpLink()
  79. {
  80. Position = result.CleanText.IndexOf("another link at the end"),
  81. Length = "another link at the end".Length,
  82. Link = HelpLinkData.AsString(HelpLink.LinkType.Link, "https://www.google.com")
  83. });
  84. result.FormattedBlocks.Add(new HelpFormat()
  85. {
  86. Type = HelpFormat.FormatType.Bold,
  87. Position = result.CleanText.IndexOf("bold text at the end"),
  88. Length = "bold text at the end".Length
  89. });
  90. return result;
  91. }
  92. internal static HelpData GetSample2()
  93. {
  94. HelpData result = new HelpData();
  95. result.CleanText = "Alternative title to confirm that all is working" + System.Environment.NewLine + System.Environment.NewLine +
  96. "This is just another help example to ensure that the panel replaces the helps dynamically." + System.Environment.NewLine + System.Environment.NewLine +
  97. "If you're reading this text, means that the help changed its content dynamically, so we can navigate between help tips by clicking hyperlinks" + System.Environment.NewLine + System.Environment.NewLine +
  98. "Makes sense?" + System.Environment.NewLine + System.Environment.NewLine +
  99. "Learn more:" + System.Environment.NewLine +
  100. "* You have some files ready to be added to version control" + System.Environment.NewLine +
  101. "* Are you missing any changes?" + System.Environment.NewLine +
  102. "* Tips to work with Visual Studio projects." + System.Environment.NewLine + System.Environment.NewLine +
  103. "This is just text after links (like this help link -> content1) to verify that the format is preserved.";
  104. // IMPORTANT! We need single EOL chars to calculate the positions,
  105. // otherwise positions are wrong calculated
  106. result.CleanText = result.CleanText.Replace("\r\n", "\n");
  107. result.FormattedBlocks = new List<HelpFormat>();
  108. result.FormattedBlocks.Add(new HelpFormat()
  109. {
  110. Type = HelpFormat.FormatType.Title,
  111. Position = 0,
  112. Length = "Alternative title to confirm that all is working".Length
  113. });
  114. result.FormattedBlocks.Add(new HelpFormat()
  115. {
  116. Type = HelpFormat.FormatType.Bold,
  117. Position = result.CleanText.IndexOf("replaces the helps dynamically"),
  118. Length = "replaces the helps dynamically".Length
  119. });
  120. result.Links = new List<HelpLink>();
  121. result.Links.Add(new HelpLink()
  122. {
  123. Position = result.CleanText.IndexOf("You have some files ready to be added to version control"),
  124. Length = "You have some files ready to be added to version control".Length,
  125. Link = HelpLinkData.AsString(HelpLink.LinkType.Action, "plasticscm-pendingchanges-filestoadd")
  126. });
  127. result.Links.Add(new HelpLink()
  128. {
  129. Position = result.CleanText.IndexOf("Are you missing any changes?"),
  130. Length = "Are you missing any changes?".Length,
  131. Link = HelpLinkData.AsString(HelpLink.LinkType.Action, "plasticscm-pendingchanges-missingchanges")
  132. });
  133. result.Links.Add(new HelpLink()
  134. {
  135. Position = result.CleanText.IndexOf("Tips to work with Visual Studio projects."),
  136. Length = "Tips to work with Visual Studio projects.".Length,
  137. Link = HelpLinkData.AsString(HelpLink.LinkType.Action, "plasticscm-pendingchanges-visualstudio")
  138. });
  139. result.Links.Add(new HelpLink()
  140. {
  141. Position = result.CleanText.IndexOf("this help link"),
  142. Length = "this help link".Length,
  143. Link = HelpLinkData.AsString(HelpLink.LinkType.Help, "sample1")
  144. });
  145. return result;
  146. }
  147. class HelpLinkData
  148. {
  149. internal static string AsString(HelpLink.LinkType linkType, string linkContent)
  150. {
  151. string linkTypeString = string.Empty;
  152. switch (linkType)
  153. {
  154. case HelpLink.LinkType.Action:
  155. linkTypeString = ACTION;
  156. break;
  157. case HelpLink.LinkType.Help:
  158. linkTypeString = HELP;
  159. break;
  160. case HelpLink.LinkType.Link:
  161. linkTypeString = LINK;
  162. break;
  163. }
  164. return string.Concat(linkTypeString, SEPARATOR, linkContent);
  165. }
  166. const string ACTION = "action";
  167. const string HELP = "help";
  168. const string LINK = "link";
  169. const string SEPARATOR = ":";
  170. }
  171. }
  172. }