private void txtTitle_TextChanged(object sender, EventArgs e) { if (this._existingIsSelected) { IAttachmentInfo selectedItem = this.cbExisting.SelectedItem as IAttachmentInfo; if (selectedItem == null) { return; } IAttachmentInfo attachmentInfo = this._bredPackage.ImageManifest.Where <IAttachmentInfo>((Func <IAttachmentInfo, bool>)(im => im.AttachmentId == selectedItem.AttachmentId)).FirstOrDefault <IAttachmentInfo>(); if (attachmentInfo == null || (uint)Operators.CompareString(attachmentInfo.Title, this.txtTitle.Text, false) <= 0U) { return; } attachmentInfo.Title = this.txtTitle.Text; this._bredPackage.UpdateAttachmentInfo(attachmentInfo); } else { IAttachmentInfo selectedItem = this.lbPending.SelectedItem as IAttachmentInfo; if (selectedItem == null) { return; } selectedItem.Title = this.txtTitle.Text; } }
private void cbExisting_SelectedIndexChanged(object sender, EventArgs e) { if (this.cbExisting.SelectedItem == null) { this.gbDetails.Visible = false; } else { this.gbDetails.Visible = true; IAttachmentInfo selectedItem = this.cbExisting.SelectedItem as IAttachmentInfo; if (selectedItem == null) { return; } IAttachmentInfo attachmentInfo = this._bredPackage.ImageManifest.Where <IAttachmentInfo>((Func <IAttachmentInfo, bool>)(im => im.AttachmentId == selectedItem.AttachmentId)).FirstOrDefault <IAttachmentInfo>(); if (attachmentInfo == null) { return; } this.txtTitle.Text = attachmentInfo.Title; this.txtDescription.Text = attachmentInfo.Description; Image image; using (Stream stream = (Stream) new MemoryStream(this._bredPackage.RetrieveAttachmentData(attachmentInfo.AttachmentId))) image = Image.FromStream(stream); if (!Information.IsNothing((object)image)) { int thumbWidth = checked ((int)Math.Round(Math.Min(240.0, unchecked ((double)checked (180 * image.Width) / (double)image.Height)))); this.pbImage.Image = image.GetThumbnailImage(thumbWidth, 180, new Image.GetThumbnailImageAbort(this.ThumbnailCallback), IntPtr.Zero); image.Dispose(); } this._existingIsSelected = true; } }
static string ReadAsContent(IAttachmentInfo attachment) { using (var stream = attachment.OpenRead()) { return(ReadAsContent(stream)); } }
public void MoveFromPendingToExisting(IAttachmentInfo pendingAttachmentInfo) { IAttachmentInfo attachmentInfo = this._bredPackage.CreateAttachmentInfo(this._siteGuid, this._invGuid, this._inventoryClass, pendingAttachmentInfo.FileName, new Guid?()); attachmentInfo.Title = pendingAttachmentInfo.Title; attachmentInfo.Description = pendingAttachmentInfo.Description; this._bredPackage.UpdateAttachmentInfo(attachmentInfo); this._pendingList.Remove(this._pendingList.Find((Predicate <IAttachmentInfo>)(p => Operators.CompareString(p.FileName, pendingAttachmentInfo.FileName, false) == 0))); }
protected override AttachmentResult ExecuteAttach(IAttachmentInfo attachmentInfo) { string rtn; if (attachmentInfo != null) { rtn = apiClient.attachToContactWithAttachment(ppolAccount, userName, password, toAddress, ccEmails, bccAddressList, subject, body, attachmentInfo.FileName, ReadAsContent(attachmentInfo)); } else { rtn = apiClient.attachToContact(ppolAccount, userName, password, toAddress, ccEmails, bccAddressList, subject, body); } return(Parse(rtn)); }
private void btnDeleteExisting_Click(object sender, EventArgs e) { IAttachmentInfo selectedItem = this.cbExisting.SelectedItem as IAttachmentInfo; if (selectedItem == null) { return; } IAttachmentInfo attachmentInfo = this._bredPackage.ImageManifest.Where <IAttachmentInfo>((Func <IAttachmentInfo, bool>)(im => im.AttachmentId == selectedItem.AttachmentId)).FirstOrDefault <IAttachmentInfo>(); if (attachmentInfo == null) { return; } this._bredPackage.DeleteAttachmentInfo(attachmentInfo); this.RefreshControls(); this.gbDetails.Visible = false; }
private void lbPending_SelectedIndexChanged(object sender, EventArgs e) { this.gbDetails.Visible = false; IAttachmentInfo selectedItem = this.lbPending.SelectedItem as IAttachmentInfo; if (selectedItem == null) { return; } this.txtTitle.Text = selectedItem.Title; this.txtDescription.Text = selectedItem.Description; Image image = Image.FromFile(selectedItem.FileName); int thumbWidth = checked ((int)Math.Round(Math.Min(240.0, Math.Max(180.0, unchecked ((double)checked (180 * image.Width) / (double)image.Height))))); int thumbHeight = checked ((int)Math.Round(Math.Min(180.0, unchecked ((double)checked (240 * image.Height) / (double)image.Width)))); this.pbImage.Image = image.GetThumbnailImage(thumbWidth, thumbHeight, new Image.GetThumbnailImageAbort(this.ThumbnailCallback), IntPtr.Zero); image.Dispose(); this.gbDetails.Visible = true; this._existingIsSelected = false; }
protected abstract AttachmentResult ExecuteAttach(IAttachmentInfo attachmentInfo);