/VascoMailer/frmEditMail.cs

https://bitbucket.org/anzeci/vascomailer · C# · 294 lines · 271 code · 23 blank · 0 comment · 9 complexity · 92251b30d982facdded40f2665bb1d46 MD5 · raw file

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using static VascoIntegracija.Lib.EmailService;
  11. namespace VascoMailer
  12. {
  13. public partial class VascoMailEdit : Form
  14. {
  15. public mshtml.IHTMLDocument2 m_htmlDoc;
  16. public EmailPredloga Predloga;
  17. public VascoMailEdit()
  18. {
  19. InitializeComponent();
  20. htmlEditor.Navigate("about:blank");
  21. m_htmlDoc = htmlEditor.Document.DomDocument as mshtml.IHTMLDocument2;
  22. m_htmlDoc.designMode = "on";
  23. InitFonts();
  24. }
  25. private void InitFonts()
  26. {
  27. string[] arFonts = new string[] {"Choose Font Style ...",
  28. "Allegro BT",
  29. "Arial",
  30. "Arial Baltic",
  31. "Arial Black",
  32. "Arial CE",
  33. "Arial CYR",
  34. "Arial Greek",
  35. "Arial Narrow",
  36. "Arial TUR",
  37. "AvantGarde Bk BT",
  38. "BankGothic Md BT",
  39. "Basemic",
  40. "Basemic Symbol",
  41. "Basemic Times",
  42. "Batang",
  43. "BatangChe",
  44. "Benguiat Bk BT",
  45. "BernhardFashion BT",
  46. "BernhardMod BT",
  47. "Book Antiqua",
  48. "Bookman Old Style",
  49. "Bremen Bd BT",
  50. "Century Gothic",
  51. "Charlesworth",
  52. "Comic Sans MS",
  53. "CommonBullets",
  54. "CopprplGoth Bd BT",
  55. "Courier",
  56. "Courier New",
  57. "Courier New Baltic",
  58. "Courier New CE",
  59. "Courier New CYR",
  60. "Courier New Greek",
  61. "Courier New TUR",
  62. "Dauphin",
  63. "Dotum",
  64. "DotumChe",
  65. "Dungeon",
  66. "English111 Vivace BT",
  67. "Estrangelo Edessa",
  68. "Fixedsys",
  69. "Franklin Gothic Medium",
  70. "Futura Lt BT",
  71. "Futura Md BT",
  72. "Futura XBlk BT",
  73. "FuturaBlack BT",
  74. "Garamond",
  75. "Gautami",
  76. "Georgia",
  77. "GoudyHandtooled BT",
  78. "GoudyOlSt BT",
  79. "Gulim",
  80. "GulimChe",
  81. "Gungsuh",
  82. "GungsuhChe",
  83. "Haettenschweiler",
  84. "Humanst521 BT",
  85. "Impact",
  86. "Kabel Bk BT",
  87. "Kabel Ult BT",
  88. "Kingsoft Phonetic Plain",
  89. "Latha",
  90. "Lithograph",
  91. "LithographLight",
  92. "Lucida Console",
  93. "Lucida Sans Unicode",
  94. "Mangal",
  95. "Marlett",
  96. "Microsoft Sans Serif",
  97. "MingLiU",
  98. "Modern",
  99. "Monotype Corsiva",
  100. "MS Gothic",
  101. "MS Mincho",
  102. "MS Outlook",
  103. "MS PGothic",
  104. "MS PMincho",
  105. "MS Sans Serif",
  106. "MS Serif",
  107. "MS UI Gothic",
  108. "MT Extra",
  109. "MV Boli",
  110. "Myriad Condensed Web",
  111. "Myriad Web",
  112. "OzHandicraft BT",
  113. "Palatino Linotype",
  114. "PMingLiU",
  115. "PosterBodoni BT",
  116. "Raavi",
  117. "Roman",
  118. "Script",
  119. "Serifa BT",
  120. "Serifa Th BT",
  121. "Shruti",
  122. "Small Fonts",
  123. "Souvenir Lt BT",
  124. "Staccato222 BT",
  125. "Swiss911 XCm BT",
  126. "Sylfaen",
  127. "Symbol",
  128. "System",
  129. "Tahoma",
  130. "Terminal",
  131. "Times New Roman",
  132. "Times New Roman Baltic",
  133. "Times New Roman CE",
  134. "Times New Roman CYR",
  135. "Times New Roman Greek",
  136. "Times New Roman TUR",
  137. "Trebuchet MS",
  138. "Tunga",
  139. "TypoUpright BT",
  140. "Verdana",
  141. "VisualUI",
  142. "Webdings",
  143. "Wingdings",
  144. "Wingdings 2",
  145. "Wingdings 3",
  146. "WP Arabic Sihafa",
  147. "WP ArabicScript Sihafa",
  148. "WP BoxDrawing",
  149. "WP CyrillicA",
  150. "WP CyrillicB",
  151. "WP Greek Century",
  152. "WP Greek Courier",
  153. "WP Greek Helve",
  154. "WP Hebrew David",
  155. "WP IconicSymbolsA",
  156. "WP IconicSymbolsB",
  157. "WP Japanese",
  158. "WP MathA",
  159. "WP MathB",
  160. "WP MathExtendedA",
  161. "WP MathExtendedB",
  162. "WP MultinationalA Courier",
  163. "WP MultinationalA Helve",
  164. "WP MultinationalA Roman",
  165. "WP MultinationalB Courier",
  166. "WP MultinationalB Helve",
  167. "WP MultinationalB Roman",
  168. "WP Phonetic",
  169. "WP TypographicSymbols",
  170. "WSTCzec",
  171. "WSTEngl",
  172. "WSTFren",
  173. "WSTGerm",
  174. "WSTItal",
  175. "WSTSpan",
  176. "WSTSwed",
  177. "ZapfEllipt BT",
  178. "Zurich Ex BT"};
  179. int i;
  180. int nCount = arFonts.Length;
  181. for (i = 0; i <= nCount - 1; i++)
  182. {
  183. lstFont.Items.Add(arFonts[i]);
  184. }
  185. lstFont.SelectedIndex = 0;
  186. lstSize.Items.Add("Font Size ... ");
  187. for (i = 1; i <= 7; i++)
  188. {
  189. lstSize.Items.Add(i);
  190. }
  191. lstSize.SelectedIndex = 0;
  192. }
  193. private void btnB_Click(object sender, EventArgs e)
  194. {
  195. m_htmlDoc.execCommand("Bold", false);
  196. htmlEditor.Focus();
  197. }
  198. private void btnI_Click(object sender, EventArgs e)
  199. {
  200. m_htmlDoc.execCommand("Italic", false);
  201. htmlEditor.Focus();
  202. }
  203. private void btnU_Click(object sender, EventArgs e)
  204. {
  205. m_htmlDoc.execCommand("Underline", false);
  206. htmlEditor.Focus();
  207. }
  208. private void btnC_Click(object sender, EventArgs e)
  209. {
  210. if (colorDlg.ShowDialog() == DialogResult.OK)
  211. {
  212. string v = String.Format("#{0:x2}{1:x2}{2:x2}", colorDlg.Color.R, colorDlg.Color.G, colorDlg.Color.B);
  213. m_htmlDoc.execCommand("ForeColor", false, v);
  214. }
  215. htmlEditor.Focus();
  216. }
  217. private void button1_Click(object sender, EventArgs e)
  218. {
  219. int start = m_htmlDoc.body.innerHTML.IndexOf("[odjava]");
  220. int stop = m_htmlDoc.body.innerHTML.IndexOf("[/odjava]");
  221. if (start >= stop)
  222. {
  223. var confirmResult = MessageBox.Show("Nekje v dokumentu morate obvezo uporabiti link za odjavo. Primer [odjava]Odjava[/odjava]. Ali želite nadaljevati brez odjavne povezave?",
  224. "Link za odjavo",
  225. MessageBoxButtons.YesNo);
  226. if (confirmResult == DialogResult.No)
  227. return;
  228. }
  229. Predloga.SPOROCILO = m_htmlDoc.body.innerHTML;
  230. Predloga.NASLOV = txtSubject.Text;
  231. this.DialogResult = DialogResult.OK;
  232. Close();
  233. }
  234. private void VascoMailEdit_Shown(object sender, EventArgs e)
  235. {
  236. m_htmlDoc.body.innerHTML = Predloga.SPOROCILO;
  237. txtSubject.Text = Predloga.NASLOV;
  238. htmlEditor.Focus();
  239. }
  240. private void btnP_Click(object sender, EventArgs e)
  241. {
  242. m_htmlDoc.execCommand("InsertImage", true);
  243. }
  244. private void lstSize_SelectedIndexChanged(object sender, EventArgs e)
  245. {
  246. string size = lstSize.Text;
  247. lstSize.SelectedIndex = 0;
  248. m_htmlDoc.execCommand("fontsize", true, size);
  249. htmlEditor.Focus();
  250. }
  251. private void button2_Click(object sender, EventArgs e)
  252. {
  253. m_htmlDoc.execCommand("InsertOrderedList", false);
  254. htmlEditor.Focus();
  255. }
  256. private void button3_Click(object sender, EventArgs e)
  257. {
  258. m_htmlDoc.execCommand("InsertUnorderedList", false);
  259. htmlEditor.Focus();
  260. }
  261. private void button4_Click(object sender, EventArgs e)
  262. {
  263. frmVpisiLink frm = new frmVpisiLink();
  264. if (frm.ShowDialog() == DialogResult.OK)
  265. {
  266. m_htmlDoc.execCommand("createlink", false, frm.link);
  267. htmlEditor.Focus();
  268. }
  269. }
  270. }
  271. }