Example #1
0
 public override MaskedSurface TryGetMaskedSurface(IWin32Window window, IPdnDataObject clipData)
 {
     using (PaintDotNet.SystemLayer.Clipboard.Transaction transaction = PaintDotNet.SystemLayer.Clipboard.Open(window))
     {
         MaskedSurface surface = transaction.TryGetManagedData(typeof(MaskedSurface)) as MaskedSurface;
         if (surface == null)
         {
             return(null);
         }
         if (surface.IsDisposed)
         {
             return(null);
         }
         return(surface);
     }
 }
Example #2
0
        private static MaskedSurface GetClipboardImageImpl(IWin32Window currentWindow, IPdnDataObject clipData)
        {
            CleanupManager.RequestCleanup();
            using (PaintDotNet.SystemLayer.Clipboard.Transaction transaction = PaintDotNet.SystemLayer.Clipboard.Open(currentWindow))
            {
                if (transaction.IsManagedDataPresent(typeof(MaskedSurface)))
                {
                    try
                    {
                        MaskedSurface surface2 = transaction.TryGetManagedData(typeof(MaskedSurface)) as MaskedSurface;
                        if ((surface2 != null) && !surface2.IsDisposed)
                        {
                            return(surface2);
                        }
                        if (surface2 != null)
                        {
                            bool isDisposed = surface2.IsDisposed;
                        }
                    }
                    catch (OutOfMemoryException)
                    {
                        throw;
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            Surface clipboardImageAsSurface = GetClipboardImageAsSurface(currentWindow, clipData);

            if (clipboardImageAsSurface != null)
            {
                return(new MaskedSurface(ref clipboardImageAsSurface, true));
            }
            return(null);
        }