private void Initialize(MessageTemplate messageTemplate) { tbEmailBody.Tick += new Editor.TickDelegate(emailEditor_Tick); _isNew = messageTemplate == null; _messageTemplate = messageTemplate; List <EmailAccount> emailAccounts = ServicesProvider.GetInstance().GetEmailAccountServices().LoadAll(); cmbEmailAccount.Items.Clear(); cmbEmailAccount.ValueMember = "Id"; cmbEmailAccount.DisplayMember = "Email"; cmbEmailAccount.DataSource = emailAccounts; if (!_isNew) { tbName.Enabled = messageTemplate.IsDefault.HasValue && !messageTemplate.IsDefault.Value; tbName.Text = messageTemplate.Name; tbBccEmail.Text = messageTemplate.BccEmailAddresses; tbSubject.Text = messageTemplate.Subject; tbBody.Text = messageTemplate.Body.ToString(); cbSendSMS.Checked = messageTemplate.SendSMS.HasValue ? messageTemplate.SendSMS.Value : false; cbSendEmail.Checked = messageTemplate.SendEmail.HasValue ? messageTemplate.SendEmail.Value : true; tbEmailBody.Html = messageTemplate.EmailBody; if (messageTemplate != null && messageTemplate.EmailAccount != null) { cmbEmailAccount.SelectedValue = messageTemplate.EmailAccount.Id; } cbDefault.Checked = messageTemplate.IsDefault.HasValue ? messageTemplate.IsDefault.Value : false; cbActive.Checked = messageTemplate.IsActive; } cmbTokens.DataSource = MessageTokenProvider.GetListOfAllowedTokens(); }
private void cmbTokens_SelectedIndexChanged(object sender, EventArgs e) { if (cmbTokens.SelectedItem.ToString() != String.Empty && cmbTokens.SelectedItem.ToString() != MessageTokenProvider.GetListOfAllowedTokens()[0]) { tbBody.Text = tbBody.Text.Insert(tbBody.SelectionStart, cmbTokens.SelectedItem.ToString()); } cmbTokens.SelectedIndex = 0; }