public override MaskedSurface TryGetMaskedSurface(IWin32Window window, IPdnDataObject clipData) { using (PaintDotNet.SystemLayer.Clipboard.Transaction transaction = PaintDotNet.SystemLayer.Clipboard.Open(window)) { return(ClipboardUtil.ClipboardRetriever.ConvertToMaskedSurface(ref transaction.TryGetEmf(), true)); } }
public override bool IsDataMaybeAvailable(IWin32Window window, IPdnDataObject clipData) { using (PaintDotNet.SystemLayer.Clipboard.Transaction transaction = PaintDotNet.SystemLayer.Clipboard.Open(window)) { if (transaction.IsManagedDataPresent(typeof(MaskedSurface))) { return(clipData.GetDataPresent(typeof(MaskedSurface))); } } return(false); }
public override bool IsDataMaybeAvailable(IWin32Window window, IPdnDataObject clipData) { string[] strArray; if (!clipData.GetDataPresent(PdnDataObjectFormats.FileDrop)) { return(false); } using (PaintDotNet.SystemLayer.Clipboard.Transaction transaction = PaintDotNet.SystemLayer.Clipboard.Open(window)) { strArray = transaction.TryGetFileDropData(); } return(((strArray != null) && (strArray.Length == 1)) && (IsImageFileName(strArray[0]) && File.Exists(strArray[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); } }
public override MaskedSurface TryGetMaskedSurface(IWin32Window window, IPdnDataObject clipData) { using (PaintDotNet.SystemLayer.Clipboard.Transaction transaction = PaintDotNet.SystemLayer.Clipboard.Open(window)) { uint formatID = PaintDotNet.SystemLayer.Clipboard.RegisterFormat("PNG"); Image image = null; if (!transaction.TryGetRawNativeData(formatID, delegate(Stream stream) { image = Image.FromStream(stream, false, true); })) { return(null); } if (image != null) { return(ClipboardUtil.ClipboardRetriever.ConvertToMaskedSurface(ref image, false)); } } return(null); }
public static bool IsClipboardImageMaybeAvailable(IWin32Window currentWindow, IPdnDataObject clipData) { try { bool flag3; bool flag = false; using (PaintDotNet.SystemLayer.Clipboard.Transaction transaction = PaintDotNet.SystemLayer.Clipboard.Open(currentWindow)) { if (transaction.IsManagedDataPresent(typeof(MaskedSurface))) { flag = clipData.GetDataPresent(typeof(MaskedSurface)); } } if (!clipData.GetDataPresent(PdnDataObjectFormats.FileDrop)) { flag3 = false; } else { string[] data = clipData.GetData(PdnDataObjectFormats.FileDrop) as string[]; if (((data != null) && (data.Length == 1)) && (IsImageFileName(data[0]) && File.Exists(data[0]))) { flag3 = true; } else { flag3 = false; } } bool dataPresent = clipData.GetDataPresent(PdnDataObjectFormats.Bitmap, true); bool flag5 = clipData.GetDataPresent(PdnDataObjectFormats.Dib, true); bool flag6 = clipData.GetDataPresent(PdnDataObjectFormats.EnhancedMetafile, true); bool flag7 = clipData.GetDataPresent("PNG", false); return(((((flag | flag3) | dataPresent) | flag5) | flag6) | flag7); } catch (Exception) { return(false); } }
public override unsafe MaskedSurface TryGetMaskedSurface(IWin32Window window, IPdnDataObject clipData) { Surface result = null; using (PaintDotNet.SystemLayer.Clipboard.Transaction transaction = PaintDotNet.SystemLayer.Clipboard.Open(window)) { bool flag = transaction.TryGetRawNativeData(8, delegate(UnsafeBufferLock buffer) { Size size; byte *pBitmapInfo = (byte *)buffer.Address; int ncbBitmapInfo = (int)buffer.Size; if (PdnGraphics.TryGetBitmapInfoSize(pBitmapInfo, ncbBitmapInfo, out size)) { Surface disposeMe = new Surface(size.Width, size.Height); bool flag = false; try { using (Bitmap bitmap = disposeMe.CreateAliasedBitmap(true)) { flag = PdnGraphics.TryCopyFromBitmapInfo(bitmap, pBitmapInfo, ncbBitmapInfo); } disposeMe.DetectAndFixDishonestAlpha(); } finally { if (flag) { result = disposeMe; } else { DisposableUtil.Free <Surface>(ref disposeMe); } } } }); } return(ClipboardUtil.ClipboardRetriever.ConvertToMaskedSurface(ref result)); }
public override MaskedSurface TryGetMaskedSurface(IWin32Window window, IPdnDataObject clipData) { string[] strArray; using (PaintDotNet.SystemLayer.Clipboard.Transaction transaction = PaintDotNet.SystemLayer.Clipboard.Open(window)) { strArray = transaction.TryGetFileDropData(); } if (strArray == null) { return(null); } if (strArray.Length != 1) { return(null); } string fileName = strArray[0]; if (!IsImageFileName(fileName)) { return(null); } File.Exists(fileName); return(ClipboardUtil.ClipboardRetriever.ConvertToMaskedSurface(ref Image.FromFile(fileName), false)); }
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); }
private static unsafe Surface GetClipboardImageAsSurface(IWin32Window currentWindow, IPdnDataObject clipData) { Image image = null; Surface surface = null; if (((image == null) && (surface == null)) && clipData.GetDataPresent(PdnDataObjectFormats.FileDrop)) { try { string[] strArray = null; using (PaintDotNet.SystemLayer.Clipboard.Transaction transaction = PaintDotNet.SystemLayer.Clipboard.Open(currentWindow)) { strArray = transaction.TryGetFileDropData(); } if ((strArray != null) && (strArray.Length == 1)) { string fileName = strArray[0]; if (IsImageFileName(fileName) && File.Exists(fileName)) { image = Image.FromFile(fileName); surface = Surface.CopyFromGdipImage(image, false); image.Dispose(); image = null; } } } catch (OutOfMemoryException) { throw; } catch (Exception) { } } if (((image == null) && (surface == null)) && clipData.GetDataPresent(PdnDataObjectFormats.Dib, true)) { try { using (PaintDotNet.SystemLayer.Clipboard.Transaction transaction2 = PaintDotNet.SystemLayer.Clipboard.Open(currentWindow)) { bool flag = transaction2.TryGetRawNativeData(8, delegate(UnsafeBufferLock buffer) { Size size; byte *pBitmapInfo = (byte *)buffer.Address; int ncbBitmapInfo = (int)buffer.Size; if (PdnGraphics.TryGetBitmapInfoSize(pBitmapInfo, ncbBitmapInfo, out size)) { surface = new Surface(size.Width, size.Height); bool flag = false; try { using (Bitmap bitmap = surface.CreateAliasedBitmap(true)) { flag = PdnGraphics.TryCopyFromBitmapInfo(bitmap, pBitmapInfo, ncbBitmapInfo); } surface.DetectAndFixDishonestAlpha(); } finally { if ((surface != null) && !flag) { surface.Dispose(); surface = null; } } } }); } } catch (OutOfMemoryException) { throw; } catch (Exception) { } } if (((image == null) && (surface == null)) && (clipData.GetDataPresent(PdnDataObjectFormats.Bitmap, true) || clipData.GetDataPresent(PdnDataObjectFormats.EnhancedMetafile, true))) { try { image = clipData.GetData(PdnDataObjectFormats.Bitmap, true) as Image; } catch (OutOfMemoryException) { throw; } catch (Exception) { } if (image == null) { try { using (PaintDotNet.SystemLayer.Clipboard.Transaction transaction3 = PaintDotNet.SystemLayer.Clipboard.Open(currentWindow)) { image = transaction3.TryGetEmf(); Image image1 = image; } } catch (OutOfMemoryException) { throw; } catch (Exception) { } } } if (((image == null) && (surface == null)) && clipData.GetDataPresent("PNG", false)) { try { bool flag2 = false; using (PaintDotNet.SystemLayer.Clipboard.Transaction transaction4 = PaintDotNet.SystemLayer.Clipboard.Open(currentWindow)) { uint formatID = PaintDotNet.SystemLayer.Clipboard.RegisterFormat("PNG"); flag2 = transaction4.TryGetRawNativeData(formatID, delegate(Stream stream) { image = Image.FromStream(stream, false, true); }); } if (flag2 && (image != null)) { surface = Surface.CopyFromGdipImage(image, false); DisposableUtil.Free <Image>(ref image); } } catch (OutOfMemoryException) { throw; } catch (Exception) { } } if ((surface != null) && (image != null)) { throw new InternalErrorException("both surface and image are non-null"); } if ((surface == null) && (image != null)) { surface = Surface.CopyFromGdipImage(image, true); } return(surface); }