EmailContactsDlg.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /**
  2. Licensed Materials - Property of IBM
  3. IBM Cognos Products: DOCS
  4. (C) Copyright IBM Corp. 2005
  5. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
  6. IBM Corp.
  7. */
  8. using System;
  9. using System.Drawing;
  10. using System.Collections;
  11. using System.ComponentModel;
  12. using System.Windows.Forms;
  13. using cognosdotnet_10_2;
  14. namespace Email
  15. {
  16. /// <summary>
  17. /// Summary description for EmailContactsDlg.
  18. /// </summary>
  19. public class EmailContactsDlg : System.Windows.Forms.Form
  20. {
  21. private System.Windows.Forms.Button buttonSendEmail;
  22. private System.Windows.Forms.Button buttonCancel;
  23. private System.Windows.Forms.TextBox emailSubjectTB;
  24. private System.Windows.Forms.RichTextBox emailBodyRTB;
  25. private System.Windows.Forms.Label emailAddressLBL;
  26. private System.Windows.Forms.Label emailSubjectLBL;
  27. private System.Windows.Forms.Label emailBodyLBL;
  28. private System.Windows.Forms.ComboBox emailAddressCB;
  29. /// <summary>
  30. /// Required designer variable.
  31. /// </summary>
  32. private System.ComponentModel.Container components = null;
  33. public EmailContactsDlg()
  34. {
  35. //
  36. // Required for Windows Form Designer support
  37. //
  38. InitializeComponent();
  39. //
  40. // TODO: Add any constructor code after InitializeComponent call
  41. //
  42. }
  43. /// <summary>
  44. /// Clean up any resources being used.
  45. /// </summary>
  46. protected override void Dispose( bool disposing )
  47. {
  48. if( disposing )
  49. {
  50. if(components != null)
  51. {
  52. components.Dispose();
  53. }
  54. }
  55. base.Dispose( disposing );
  56. }
  57. #region Windows Form Designer generated code
  58. /// <summary>
  59. /// Required method for Designer support - do not modify
  60. /// the contents of this method with the code editor.
  61. /// </summary>
  62. private void InitializeComponent()
  63. {
  64. System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(EmailContactsDlg));
  65. this.emailAddressLBL = new System.Windows.Forms.Label();
  66. this.emailSubjectLBL = new System.Windows.Forms.Label();
  67. this.emailBodyLBL = new System.Windows.Forms.Label();
  68. this.emailSubjectTB = new System.Windows.Forms.TextBox();
  69. this.emailBodyRTB = new System.Windows.Forms.RichTextBox();
  70. this.buttonSendEmail = new System.Windows.Forms.Button();
  71. this.buttonCancel = new System.Windows.Forms.Button();
  72. this.emailAddressCB = new System.Windows.Forms.ComboBox();
  73. this.SuspendLayout();
  74. //
  75. // emailAddressLBL
  76. //
  77. this.emailAddressLBL.Location = new System.Drawing.Point(16, 16);
  78. this.emailAddressLBL.Name = "emailAddressLBL";
  79. this.emailAddressLBL.Size = new System.Drawing.Size(80, 23);
  80. this.emailAddressLBL.TabIndex = 0;
  81. this.emailAddressLBL.Text = "Email Address:";
  82. //
  83. // emailSubjectLBL
  84. //
  85. this.emailSubjectLBL.Location = new System.Drawing.Point(16, 56);
  86. this.emailSubjectLBL.Name = "emailSubjectLBL";
  87. this.emailSubjectLBL.Size = new System.Drawing.Size(80, 23);
  88. this.emailSubjectLBL.TabIndex = 1;
  89. this.emailSubjectLBL.Text = "Email Subject:";
  90. //
  91. // emailBodyLBL
  92. //
  93. this.emailBodyLBL.Location = new System.Drawing.Point(16, 104);
  94. this.emailBodyLBL.Name = "emailBodyLBL";
  95. this.emailBodyLBL.Size = new System.Drawing.Size(72, 16);
  96. this.emailBodyLBL.TabIndex = 2;
  97. this.emailBodyLBL.Text = "Email Body:";
  98. //
  99. // emailSubjectTB
  100. //
  101. this.emailSubjectTB.Location = new System.Drawing.Point(96, 56);
  102. this.emailSubjectTB.Name = "emailSubjectTB";
  103. this.emailSubjectTB.Size = new System.Drawing.Size(184, 20);
  104. this.emailSubjectTB.TabIndex = 4;
  105. this.emailSubjectTB.Text = "SDK Email Sample Report";
  106. //
  107. // emailBodyRTB
  108. //
  109. this.emailBodyRTB.Location = new System.Drawing.Point(96, 104);
  110. this.emailBodyRTB.Name = "emailBodyRTB";
  111. this.emailBodyRTB.Size = new System.Drawing.Size(184, 96);
  112. this.emailBodyRTB.TabIndex = 5;
  113. this.emailBodyRTB.Text = "This is an example of email body text";
  114. //
  115. // buttonSendEmail
  116. //
  117. this.buttonSendEmail.Location = new System.Drawing.Point(96, 216);
  118. this.buttonSendEmail.Name = "buttonSendEmail";
  119. this.buttonSendEmail.Size = new System.Drawing.Size(80, 24);
  120. this.buttonSendEmail.TabIndex = 6;
  121. this.buttonSendEmail.Text = "Send Email";
  122. this.buttonSendEmail.Click += new System.EventHandler(this.buttonSendEmail_Click);
  123. //
  124. // buttonCancel
  125. //
  126. this.buttonCancel.Location = new System.Drawing.Point(200, 216);
  127. this.buttonCancel.Name = "buttonCancel";
  128. this.buttonCancel.Size = new System.Drawing.Size(80, 23);
  129. this.buttonCancel.TabIndex = 7;
  130. this.buttonCancel.Text = "Cancel";
  131. this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
  132. //
  133. // emailAddressCB
  134. //
  135. this.emailAddressCB.Location = new System.Drawing.Point(96, 16);
  136. this.emailAddressCB.Name = "emailAddressCB";
  137. this.emailAddressCB.Size = new System.Drawing.Size(184, 21);
  138. this.emailAddressCB.TabIndex = 8;
  139. //
  140. // EmailContactsDlg
  141. //
  142. this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  143. this.ClientSize = new System.Drawing.Size(296, 254);
  144. this.Controls.Add(this.emailAddressCB);
  145. this.Controls.Add(this.buttonCancel);
  146. this.Controls.Add(this.buttonSendEmail);
  147. this.Controls.Add(this.emailBodyRTB);
  148. this.Controls.Add(this.emailSubjectTB);
  149. this.Controls.Add(this.emailBodyLBL);
  150. this.Controls.Add(this.emailSubjectLBL);
  151. this.Controls.Add(this.emailAddressLBL);
  152. this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
  153. this.Name = "EmailContactsDlg";
  154. this.Text = "Email Contacts";
  155. this.ResumeLayout(false);
  156. }
  157. #endregion
  158. public string emailAddress = "";
  159. public string emailSubject = "";
  160. public string emailBody = "";
  161. public bool isContactInfoSet = false;
  162. private void buttonCancel_Click(object sender, System.EventArgs e)
  163. {
  164. this.Close();
  165. }
  166. private void buttonSendEmail_Click(object sender, System.EventArgs e)
  167. {
  168. emailAddress = (string)emailAddressCB.SelectedItem;
  169. if (emailAddress == null)
  170. {
  171. emailAddress = "";
  172. }
  173. emailSubject = emailSubjectTB.Text;
  174. emailBody = emailBodyRTB.Text;
  175. isContactInfoSet = true;
  176. this.Close();
  177. }
  178. public void setAllUsersMode(bool isAllUsersMode)
  179. {
  180. if (isAllUsersMode)
  181. {
  182. emailAddressLBL.Visible = false;
  183. emailAddressCB.Visible = false;
  184. }
  185. else
  186. {
  187. emailAddressLBL.Visible = true;
  188. emailAddressCB.Visible = true;
  189. }
  190. }
  191. public void setContactEmails(addressSMTP[] contactList)
  192. {
  193. int nbContacts = contactList.GetLength(0);
  194. for (int i=0;i<nbContacts;i++)
  195. {
  196. emailAddressCB.Items.Add(contactList[i].Value);
  197. }
  198. }
  199. public void setSelectedEmailAddress(int value)
  200. {
  201. emailAddressCB.SelectedIndex = value;
  202. }
  203. }
  204. }