Guest User

TableTranslation.cs

a guest
Jul 14th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.90 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Forms;
  7.  
  8. namespace imgMessCons
  9. {
  10. class TableTranslation
  11. {
  12. private List<Char> tableTranslation;
  13.  
  14. public TableTranslation()
  15. {
  16. this.tableTranslation = new List<char>();
  17.  
  18. //part first - english capital letters
  19.  
  20. this.tableTranslation.Add('A');
  21. this.tableTranslation.Add('B');
  22. this.tableTranslation.Add('C');
  23. this.tableTranslation.Add('D');
  24. this.tableTranslation.Add('E');
  25. this.tableTranslation.Add('F');
  26. this.tableTranslation.Add('G');
  27. this.tableTranslation.Add('H');
  28. this.tableTranslation.Add('I');
  29. this.tableTranslation.Add('J');
  30. this.tableTranslation.Add('K');
  31. this.tableTranslation.Add('L');
  32. this.tableTranslation.Add('M');
  33. this.tableTranslation.Add('N');
  34. this.tableTranslation.Add('O');
  35. this.tableTranslation.Add('P');
  36. this.tableTranslation.Add('Q');
  37. this.tableTranslation.Add('R');
  38. this.tableTranslation.Add('S');
  39. this.tableTranslation.Add('T');
  40. this.tableTranslation.Add('U');
  41. this.tableTranslation.Add('V');
  42. this.tableTranslation.Add('W');
  43. this.tableTranslation.Add('X');
  44. this.tableTranslation.Add('Y');
  45. this.tableTranslation.Add('Z');
  46.  
  47. // part second - english small letters
  48.  
  49. this.tableTranslation.Add('a');
  50. this.tableTranslation.Add('b');
  51. this.tableTranslation.Add('c');
  52. this.tableTranslation.Add('d');
  53. this.tableTranslation.Add('e');
  54. this.tableTranslation.Add('f');
  55. this.tableTranslation.Add('g');
  56. this.tableTranslation.Add('h');
  57. this.tableTranslation.Add('i');
  58. this.tableTranslation.Add('j');
  59. this.tableTranslation.Add('k');
  60. this.tableTranslation.Add('l');
  61. this.tableTranslation.Add('m');
  62. this.tableTranslation.Add('n');
  63. this.tableTranslation.Add('o');
  64. this.tableTranslation.Add('p');
  65. this.tableTranslation.Add('q');
  66. this.tableTranslation.Add('r');
  67. this.tableTranslation.Add('s');
  68. this.tableTranslation.Add('t');
  69. this.tableTranslation.Add('u');
  70. this.tableTranslation.Add('v');
  71. this.tableTranslation.Add('w');
  72. this.tableTranslation.Add('x');
  73. this.tableTranslation.Add('y');
  74. this.tableTranslation.Add('z');
  75.  
  76. //part third - ukrainian and russian capital letters
  77.  
  78. this.tableTranslation.Add('А');
  79. this.tableTranslation.Add('Б');
  80. this.tableTranslation.Add('В');
  81. this.tableTranslation.Add('Г');
  82. this.tableTranslation.Add('Д');
  83. this.tableTranslation.Add('Е');
  84. this.tableTranslation.Add('Ё');
  85. this.tableTranslation.Add('Ж');
  86. this.tableTranslation.Add('З');
  87. this.tableTranslation.Add('И');
  88. this.tableTranslation.Add('Й');
  89. this.tableTranslation.Add('К');
  90. this.tableTranslation.Add('Л');
  91. this.tableTranslation.Add('М');
  92. this.tableTranslation.Add('Н');
  93. this.tableTranslation.Add('О');
  94. this.tableTranslation.Add('П');
  95. this.tableTranslation.Add('Р');
  96. this.tableTranslation.Add('С');
  97. this.tableTranslation.Add('Т');
  98. this.tableTranslation.Add('У');
  99. this.tableTranslation.Add('Ф');
  100. this.tableTranslation.Add('Х');
  101. this.tableTranslation.Add('Ц');
  102. this.tableTranslation.Add('Ч');
  103. this.tableTranslation.Add('Ш');
  104. this.tableTranslation.Add('Щ');
  105. this.tableTranslation.Add('Ъ');
  106. this.tableTranslation.Add('Ы');
  107. this.tableTranslation.Add('Ь');
  108. this.tableTranslation.Add('Э');
  109. this.tableTranslation.Add('Ю');
  110. this.tableTranslation.Add('Я');
  111.  
  112. this.tableTranslation.Add('Ґ');
  113. this.tableTranslation.Add('І');
  114. this.tableTranslation.Add('Ї');
  115. this.tableTranslation.Add('Є');
  116.  
  117. //part fourth - russian and ukrainian small letters
  118.  
  119. this.tableTranslation.Add('а');
  120. this.tableTranslation.Add('б');
  121. this.tableTranslation.Add('в');
  122. this.tableTranslation.Add('г');
  123. this.tableTranslation.Add('д');
  124. this.tableTranslation.Add('е');
  125. this.tableTranslation.Add('ё');
  126. this.tableTranslation.Add('ж');
  127. this.tableTranslation.Add('з');
  128. this.tableTranslation.Add('и');
  129. this.tableTranslation.Add('й');
  130. this.tableTranslation.Add('к');
  131. this.tableTranslation.Add('л');
  132. this.tableTranslation.Add('м');
  133. this.tableTranslation.Add('н');
  134. this.tableTranslation.Add('о');
  135. this.tableTranslation.Add('п');
  136. this.tableTranslation.Add('р');
  137. this.tableTranslation.Add('с');
  138. this.tableTranslation.Add('т');
  139. this.tableTranslation.Add('у');
  140. this.tableTranslation.Add('ф');
  141. this.tableTranslation.Add('х');
  142. this.tableTranslation.Add('ц');
  143. this.tableTranslation.Add('ч');
  144. this.tableTranslation.Add('ш');
  145. this.tableTranslation.Add('щ');
  146. this.tableTranslation.Add('ъ');
  147. this.tableTranslation.Add('ы');
  148. this.tableTranslation.Add('ь');
  149. this.tableTranslation.Add('э');
  150. this.tableTranslation.Add('ю');
  151. this.tableTranslation.Add('я');
  152.  
  153. this.tableTranslation.Add('ґ');
  154. this.tableTranslation.Add('і');
  155. this.tableTranslation.Add('ї');
  156. this.tableTranslation.Add('є');
  157.  
  158. //part fifth - spesial symbols
  159.  
  160. this.tableTranslation.Add('0');
  161. this.tableTranslation.Add('1');
  162. this.tableTranslation.Add('2');
  163. this.tableTranslation.Add('3');
  164. this.tableTranslation.Add('4');
  165. this.tableTranslation.Add('5');
  166. this.tableTranslation.Add('6');
  167. this.tableTranslation.Add('7');
  168. this.tableTranslation.Add('8');
  169. this.tableTranslation.Add('9');
  170.  
  171. this.tableTranslation.Add('≠');
  172. this.tableTranslation.Add('>');
  173. this.tableTranslation.Add('<');
  174. this.tableTranslation.Add('≥');
  175. this.tableTranslation.Add('≤');
  176. this.tableTranslation.Add('+');
  177. this.tableTranslation.Add('±');
  178. this.tableTranslation.Add('∓');
  179. this.tableTranslation.Add('(');
  180. this.tableTranslation.Add(')');
  181. this.tableTranslation.Add('{');
  182. this.tableTranslation.Add('}');
  183. this.tableTranslation.Add('[');
  184. this.tableTranslation.Add(']');
  185. this.tableTranslation.Add('-');
  186. this.tableTranslation.Add('*');
  187. this.tableTranslation.Add('÷');
  188. this.tableTranslation.Add('∙');
  189. this.tableTranslation.Add('^');
  190. this.tableTranslation.Add('&');
  191. this.tableTranslation.Add('\\');
  192. this.tableTranslation.Add('/');
  193. this.tableTranslation.Add('|');
  194. this.tableTranslation.Add('@');
  195. this.tableTranslation.Add('#');
  196. this.tableTranslation.Add('$');
  197. this.tableTranslation.Add('&');
  198. this.tableTranslation.Add('_');
  199. this.tableTranslation.Add('~');
  200. this.tableTranslation.Add('`');
  201.  
  202. this.tableTranslation.Add('\'');
  203. this.tableTranslation.Add('\"');
  204. this.tableTranslation.Add('\n');
  205. this.tableTranslation.Add('\t');
  206. this.tableTranslation.Add('\v');
  207. this.tableTranslation.Add('\b');
  208. this.tableTranslation.Add('\r');
  209. this.tableTranslation.Add('\a');
  210. this.tableTranslation.Add('\0');
  211.  
  212. this.tableTranslation.Add(':');
  213. this.tableTranslation.Add('.');
  214. this.tableTranslation.Add(',');
  215. this.tableTranslation.Add('!');
  216. this.tableTranslation.Add('?');
  217. this.tableTranslation.Add(';');
  218. this.tableTranslation.Add(' ');
  219. this.tableTranslation.Add('№');
  220.  
  221. //extra special symbol - for all undefined other symbols
  222.  
  223. this.tableTranslation.Add('☻');
  224.  
  225. //extra special symbol - end of string
  226.  
  227. this.tableTranslation.Add('☺');
  228.  
  229. }
  230.  
  231. public int GetLength()
  232. {
  233. return this.tableTranslation.Count;
  234. }
  235.  
  236. public char GetSymbol(int key)
  237. {
  238. char ch;
  239. if ((key < 0) && (key > 255))
  240. {
  241. ch = this.tableTranslation[this.tableTranslation.Count - 2];
  242. }
  243. else
  244. {
  245. ch = this.tableTranslation[key];
  246. }
  247. return ch;
  248. }
  249.  
  250. public int GetIndex(char ch)
  251. {
  252. int key = 0;
  253.  
  254. try
  255. {
  256. key = this.tableTranslation.IndexOf(ch);
  257. }
  258. catch (Exception e)
  259. {
  260.  
  261. }
  262.  
  263. if((key < 0) || (key > 255))
  264. {
  265. key = this.tableTranslation.Count - 2;
  266. }
  267.  
  268. return key;
  269. }
  270.  
  271. }
  272. }
Add Comment
Please, Sign In to add comment