protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        if (e == null)
        {
            throw new ArgumentNullException("e");
        }
        if (e.State != AjaxControlToolkit.AjaxFileUploadState.Success)
        {
            return;
        }

        string szKey = FileObjectSessionKey(e.FileId);

        PendingIDs.Add(szKey);
        Session[szKey] = new MFBPendingImage(new MFBPostedFile(e.FileName, e.ContentType, e.FileSize, e.GetContents(), e.FileId), szKey);
        e.DeleteTemporaryData();

        RefreshPreviewList();

        if (Mode == UploadMode.Legacy)
        {
            Mode = UploadMode.Ajax;
        }

        if (UploadComplete != null)
        {
            UploadComplete(this, e);
        }
    }
Ejemplo n.º 2
0
    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);
    }
Ejemplo n.º 3
0
 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!!!
     }
 }