protected void imgAdd_Command(object sender, CommandEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } // Find the appropriate image List <GoogleMediaItem> items = new List <GoogleMediaItem>(RetrievedGooglePhotos.mediaItems); GoogleMediaItem clickedItem = items.Find(i => i.productUrl.CompareOrdinal((string)e.CommandArgument) == 0); if (clickedItem == null) { throw new ArgumentOutOfRangeException("Can't find item with id " + e.CommandArgument); } PositionEventArgs pea = new PositionEventArgs(null, clickedItem.mediaMetadata.CreationTime); ImportingGooglePhoto?.Invoke(sender, pea); MFBPostedFile pf = RetrievedGooglePhotos.ImportImage(e.CommandArgument.ToString()); if (pf == null) { return; } MFBPendingImage pi = AddPostedFile(pf, pea.ExpectedPosition); rptGPhotos.DataSource = RetrievedGooglePhotos.mediaItems; rptGPhotos.DataBind(); pnlGPResult.Visible = RetrievedGooglePhotos.mediaItems.Any(); }
protected MFBPendingImage AddPostedFile(MFBPostedFile pf, LatLong ll) { if (pf == null) { throw new ArgumentNullException(nameof(pf)); } string szKey = FileObjectSessionKey(pf.FileID); PendingIDs.Add(szKey); MFBPendingImage result = new MFBPendingImage(pf, szKey); if (ll != null) { result.Location = ll; } Session[szKey] = result; UploadComplete?.Invoke(this, new EventArgs()); RefreshPreviewList(); return(result); }
protected void ProcessClipboardImage() { // Regardless of mode, see if there's a clipboard image if (!String.IsNullOrEmpty(hImg.Value)) { try { MFBPostedFile pf = new MFBPostedFile(hImg.Value); if (ValidateFileType(MFBImageInfo.ImageTypeFromFile(pf))) { // create a pending file. string szKey = FileObjectSessionKey(pf.FileName); PendingIDs.Add(szKey); Session[szKey] = new MFBPendingImage(pf, szKey); RefreshPreviewList(); UploadComplete?.Invoke(this, new EventArgs()); } } catch (FormatException) { } // if it's bad data, just don't do anything. hImg.Value = string.Empty; // don't send it back down the wire!!! } }