private async void _btnAddPerformance_Click(Object sender, EventArgs e) { var templateInfo = this.GetPerformanceTemplateInfo(); if (templateInfo == null) { return; } var dataItems = this.BuildPerformanceDataItems(templateInfo); if (dataItems != null && dataItems.Count > 0) { this._sfSavePerformanceFile.FileName = Config <UserInfoConfig> .Current.GetDefaultPerformanceTile(); var result = this._sfSavePerformanceFile.ShowDialog(); String savePath = this._sfSavePerformanceFile.FileName; WaitingForm.ShowWaiting("正在保存绩效文件..."); await this.TemplateManager.FillDataItemsAsync(templateInfo, dataItems, savePath, true); //添加至发信附件 EmailAttachmentInfo attachmentInfo = new EmailAttachmentInfo(savePath); this._lbSendAttachments.AddFirstAttachmentInfo(attachmentInfo); WaitingForm.HideWaiting(); } }
public static EmailAttachmentInfo Create(Attachment attachment, EmailDataInfo dataInfo = null) { EmailAttachmentInfo info = new EmailAttachmentInfo(attachment); info.EmailDataInfo = dataInfo; info.From = dataInfo?.From; return(info); }
private void _btnAddToSendAttachment_Click(Object sender, EventArgs e) { var attachmentInfo = this._lbReceviceAttachments.SelectedEmailAttachmentInfo; if (attachmentInfo == null) { return; } EmailAttachmentInfo newAttachmentInfo = new EmailAttachmentInfo(attachmentInfo.SavePath); this._lbSendAttachments.AddFirstAttachmentInfo(newAttachmentInfo, true); }
private void _btnAddAttachment_Click(Object sender, EventArgs e) { var result = this._ofSelectSendAttachment.ShowDialog(); if (result != DialogResult.OK) { return; } String filePath = this._ofSelectSendAttachment.FileName; EmailAttachmentInfo info = new EmailAttachmentInfo(filePath); this._lbSendAttachments.AddFirstAttachmentInfo(info, true); }
private void CustomDrawItem(Object sender, DrawItemEventArgs e) { if (e.Index == -1 || this.DesignMode) { return; } var obj = this.Items[e.Index]; EmailAttachmentInfo attachInfo = obj as EmailAttachmentInfo; if (attachInfo == null) { return; } var g = e.Graphics; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; var forceColor = e.ForeColor; var backgroundColor = e.BackColor; Int32 iconWidth = 30; Int32 textBeginX = iconWidth; Int32 textBeginY = 3; var backgroudRect = new Rectangle(e.Bounds.X - 1, e.Bounds.Y - 1, e.Bounds.Width + 1, e.Bounds.Height + 2); var attachmentFlagRect = new Rectangle(5, 5, 20, 20); if (this.MouseHoverItemIndex == e.Index) { backgroundColor = Color.FromArgb(190, 190, 190); } if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { backgroundColor = Color.FromArgb(175, 175, 175); } Brush backBrush = new SolidBrush(backgroundColor); g.FillRectangle(backBrush, backgroudRect); var nameRect = new Rectangle(textBeginX, textBeginY, e.Bounds.Width - iconWidth, e.Bounds.Height); var attachmentFlagImage = attachInfo.IsSaved ? this.SavedAttachmentFlagImage : this.DefaultAttachmentImage; if (attachmentFlagImage != null) { g.DrawImage(attachmentFlagImage, attachmentFlagRect); } //绘制附件名称属性 TextRenderer.DrawText(g, attachInfo.Name, e.Font, nameRect, e.ForeColor, TextFormatFlags.EndEllipsis); }
private void SendAttachmentListBox_DrawItem(Object sender, DrawItemEventArgs e) { if (!this.DrawReceiver) { return; } if (e.Index == -1 || this.DesignMode) { return; } var obj = this.Items[e.Index]; EmailAttachmentInfo attachInfo = obj as EmailAttachmentInfo; if (attachInfo == null) { return; } String receiver = attachInfo.ReceiverName; if (String.IsNullOrEmpty(attachInfo.ReceiverName)) { receiver = this.DefaultReceiverText; } if (!this.DefaultReceiverTextDrawSize.HasValue) { this.DefaultReceiverTextDrawSize = TextRenderer.MeasureText(this.DefaultReceiverText, e.Font); } var g = e.Graphics; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; var forceColor = e.ForeColor; var backgroundColor = e.BackColor; Int32 iconWidth = 30; Int32 textBeginX = iconWidth; Int32 textBeginY = 3; var defaultTextSize = this.DefaultReceiverTextDrawSize.Value; var backgroudRect = new Rectangle(e.Bounds.X - 1, e.Bounds.Y - 1, e.Bounds.Width + 1, e.Bounds.Height + 2); var receiverTextRect = new Rectangle( backgroudRect.Width - defaultTextSize.Width, textBeginY, defaultTextSize.Width, defaultTextSize.Height); //绘制附件名称属性 TextRenderer.DrawText(g, receiver, e.Font, receiverTextRect, e.ForeColor, TextFormatFlags.EndEllipsis); }
private void _btnSendEmail_Click(Object sender, EventArgs e) { if (this.EmailDataManager == null) { return; } var attachs = this._lbSendAttachments.AttachmentInfos; EmailAttachmentInfo[] attachmentInfoArray = new EmailAttachmentInfo[attachs.Count]; this._lbSendAttachments.AttachmentInfos.CopyTo(attachmentInfoArray); EmailSendForm form = new EmailSendForm(attachmentInfoArray.ToList()); form.OpenFileDialog = this._ofSelectSendAttachment; form.ShowDialog(); }
/// <summary> /// 添加指定附件信息到控件中,并指定对附件是否已保存的检查,开启后相同保存路径的附件或未保存的附件,无法通过此函数添加 /// </summary> /// <param name="info"></param> /// <param name="requiredSaved"></param> public void AddFirstAttachmentInfo(EmailAttachmentInfo info, Boolean checkSaved = false) { if (checkSaved) { if (!info.IsSaved) { return; } if (this.ExistedAttachmentInfoBySavePath(info.SavePath)) { return; } } this.AttachmentInfos.Insert(0, info); this.Items.Insert(0, info); this.Refresh(); }
public void SaveAttachmentInfo(EmailAttachmentInfo attachmentInfo) { //层次: 用户-》邮件ID-》文件名称 String directory = Path.Combine(this.AttachmentFloder, attachmentInfo.EmailDataInfo.UIDL); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } String path = Path.Combine(directory, attachmentInfo.Name); if (!File.Exists(path)) { attachmentInfo.Attachment.SaveAs(path, false); } attachmentInfo.IsSaved = true; attachmentInfo.SavePath = path; }
private void BuildEmailDataInfo(EmailDataInfo dataInfo, Mail mail, MailInfo info) { this.RemoveTrialInfo(mail); dataInfo.Mail = mail; dataInfo.Title = mail.Subject; dataInfo.MailInfo = info; dataInfo.Manager = this; dataInfo.AttachmentInfos.Clear(); foreach (var attachment in mail.Attachments) { var attachInfo = EmailAttachmentInfo.Create(attachment, dataInfo); String path = Path.Combine(this.AttachmentFloder, info.UIDL, attachInfo.Name); if (File.Exists(path)) { attachInfo.IsSaved = true; attachInfo.SavePath = path; } dataInfo.AttachmentInfos.Add(attachInfo); } }