protected override ClipboardItem CreateNew(ClipboardSnapshot snapshot)
#endif
        {

#if !NETFX_CORE
            if (snapshot.HasFormat(KnownClipboardFormats.CF_UNICODETEXT)) //general text data
#else
            if(snapshot.HasFormat(StandardDataFormats.Text))
#endif
            {

#if !NETFX_CORE
                IntPtr textPointer = snapshot.FetchDataPointer(KnownClipboardFormats.CF_UNICODETEXT);

                try
                {

                    string value = Marshal.PtrToStringUni(textPointer);
#else
                var value = (string)snapshot.FetchData(StandardDataFormats.Text);
#endif

                    var result = new ClipboardText();
                    result.Text = value;

                    return result;

#if !NETFX_CORE

                }
                finally
                {

                    if (textPointer != IntPtr.Zero)
                    {
                        Marshal.FreeHGlobal(textPointer);
                    }

                }

#endif

            }
            else
            {
                throw new InvalidOperationException("The text format was not known");
            }
        }
        protected override ClipboardItem CreateNew(ClipboardSnapshot snapshot)
#endif
        {

            try
            {

                if (snapshot.HasFormat(KnownClipboardFormats.CF_DIBV5))
                //device independent bitmap (with transparency - yay!)
                {
                    IntPtr pointer = IntPtr.Zero;

                    try
                    {

                        pointer = snapshot.FetchDataPointer(KnownClipboardFormats.CF_DIBV5);

                        var infoHeader =
                            (BITMAPV5HEADER)Marshal.PtrToStructure(pointer, typeof(BITMAPV5HEADER));

                        using (
                            var bitmap = new Bitmap((int)infoHeader.bV5Width, (int)infoHeader.bV5Height,
                                                    (int)(infoHeader.bV5SizeImage / infoHeader.bV5Height),
                                                    PixelFormat.Format32bppArgb,
                                                    new IntPtr(pointer.ToInt64() + infoHeader.bV5Size)))
                        {

                            var bitmapSource = new RenderTargetBitmap((int)infoHeader.bV5Width,
                                                                      (int)infoHeader.bV5Height,
                                                                      96, 96, PixelFormats.Pbgra32);
                            var visual = new DrawingVisual();
                            var drawingContext = visual.RenderOpen();

                            drawingContext.DrawImage(CreateBitmapSourceFromBitmap(bitmap),
                                                     new Rect(0, 0, (int)infoHeader.bV5Width,
                                                              (int)infoHeader.bV5Height));

                            drawingContext.Close();

                            bitmapSource.Render(visual);

                            var result = new ClipboardImage();
                            result.Image = bitmapSource;

                            return result;

                        }

                    }
                    finally
                    {
                        if (pointer != IntPtr.Zero)
                        {
                            Marshal.FreeHGlobal(pointer);
                        }
                    }

                }
            }
            catch (ArgumentException)
            {
                //this dibv5 format was faulty. let's roll back to normal dib.
            }

            //TODO: do we need the below or don't we? will the above work for all formats?
            if (snapshot.HasFormat(KnownClipboardFormats.CF_DIB)) //device independent bitmap
            {
                byte[] buffer = snapshot.FetchData(KnownClipboardFormats.CF_DIB);

                var infoHeader =
                    ApiHelper.ByteArrayToStructure<BITMAPINFOHEADER>(buffer);

                int fileHeaderSize = Marshal.SizeOf(typeof(BITMAPFILEHEADER));
                int infoHeaderSize = infoHeader.biSize;
                int fileSize = fileHeaderSize + infoHeader.biSize + infoHeader.biSizeImage;

                var fileHeader = new BITMAPFILEHEADER();
                fileHeader.bfType = BITMAPFILEHEADER.BM;
                fileHeader.bfSize = fileSize;
                fileHeader.bfReserved1 = 0;
                fileHeader.bfReserved2 = 0;
                fileHeader.bfOffBits = fileHeaderSize + infoHeaderSize + infoHeader.biClrUsed * 4;

                byte[] fileHeaderBytes =
                    ApiHelper.StructureToByteArray(fileHeader);

                var bitmapStream = new MemoryStream();
                bitmapStream.Write(fileHeaderBytes, 0, fileHeaderSize);
                bitmapStream.Write(buffer, 0, buffer.Length);
                bitmapStream.Seek(0, SeekOrigin.Begin);

                BitmapFrame bitmap = BitmapFrame.Create(bitmapStream);

                var result = new ClipboardImage();
                result.Image = bitmap;

                return result;
            }

            if(snapshot.HasFormat(KnownClipboardFormats.CF_ENHMETAFILE))
            {
                byte[] buffer = snapshot.FetchData(KnownClipboardFormats.CF_ENHMETAFILE);
                using (var memoryStream = new MemoryStream(buffer))
                {
                    using(var metafile = new Metafile(memoryStream))
                    {
                        using (var bitmap = new Bitmap(metafile.Width, metafile.Height))
                        {
                            using (var graphics = Graphics.FromImage(bitmap))
                            {
                                graphics.DrawImage(metafile, 0, 0);

                                var result = new ClipboardImage();
                                result.Image = CreateBitmapSourceFromBitmap(bitmap);

                                return result;
                            }
                        }
                    }
                }
            }

            var formatResult = string.Empty;
            foreach (var format in snapshot.FormatPriorities)
            {
                formatResult += format + ", ";
            }
            if (!string.IsNullOrEmpty(formatResult))
            {
                formatResult = formatResult.Substring(0, formatResult.Length - 2);
            }

            throw new InvalidOperationException("None of the image formats from " + ClipboardSource.ApplicationNameFromWindowHandle(snapshot.OutsideClipboardOwnerHandle) + " were known (" + formatResult + ")");

        }
        protected override ClipboardItem CreateNew(ClipboardSnapshot snapshot)
#endif
        {

            //does it have one or multiple files?
#if !NETFX_CORE
            if (snapshot.HasFormat(KnownClipboardFormats.CF_HDROP))
#else
            if(snapshot.HasFormat(StandardDataFormats.StorageItems))
#endif
            {
#if !NETFX_CORE

                IntPtr pointer = snapshot.FetchDataPointer(KnownClipboardFormats.CF_HDROP);
                try
                {

                    var paths = new List<string>();

                    //get amount of files. see http://msdn.microsoft.com/en-us/library/windows/desktop/bb776408(v=vs.85).aspx
                    int fileCount = DragQueryFile(pointer, -1, null, 0);

#else

                var data = (IEnumerable<IStorageItem>) snapshot.FetchData(StandardDataFormats.StorageItems);
                var paths = data.ToList();
                int fileCount = paths.Count();
 
#endif

                    if (fileCount > 0)
                    {
#if !NETFX_CORE
                        for (int i = 0; i < fileCount; i++)
                        {
                            int fileNameLength = DragQueryFile(pointer, i, null, 0) + 1;

                            var fileNameBuilder = new StringBuilder(fileNameLength);
                            DragQueryFile(pointer, i, fileNameBuilder, fileNameBuilder.Capacity);

                            string fileName = fileNameBuilder.ToString();
                            paths.Add(fileName);
                        }
#endif

                        if (fileCount > 1)
                        {
                            var result = new ClipboardFileCollection();
                            result.Paths = paths;

                            return result;
                        }
                        else
                        {
                            var result = new ClipboardFile();
                            result.Path = paths.First();

                            result.Icon = IconHelper.GetIcon(result.Path, true, 64);

                            return result;
                        }
                    }

                    return null;

#if !NETFX_CORE

                }
                finally
                {
                    if (pointer != IntPtr.Zero)
                    {
                        Marshal.FreeHGlobal(pointer);
                    }
                }
#endif

            }
            else
            {
                throw new InvalidOperationException("Can't create file collection clipboard item when there is no recognizable file data present");
            }
        }