Пример #1
0
        private async void OnPaste(object sender, TextControlPasteEventArgs e)
        {
            var dataPackageView = Windows.ApplicationModel.DataTransfer.Clipboard.GetContent();

            if (dataPackageView.Contains(Windows.ApplicationModel.DataTransfer.StandardDataFormats.Bitmap))
            {
                e.Handled = true;
                var bitmap = await dataPackageView.GetBitmapAsync();

                var file = await bitmap.SaveCacheFile($"Clipboard - {DateTime.Now:yyyy-mm-dd HH-mm-ss}");

                UploadFile?.Invoke(this, file);
            }
            else if (dataPackageView.Contains(Windows.ApplicationModel.DataTransfer.StandardDataFormats.StorageItems))
            {
                e.Handled = true;
                var files = (await dataPackageView.GetStorageItemsAsync())
                            .Select(it => it as StorageFile)
                            .ToArray();
                UploadFile?.Invoke(this, files.FirstOrDefault());
            }
        }