Beispiel #1
0
 protected virtual void OnClipboardContentChanged(ClipboardContentChangedEventArgs e)
 {
     if (isStarted)
     {
         ClipboardContentChanged?.Invoke(this, e);
     }
 }
        private void ClipboardChangeTrackerOnClipboardContentChanged(object sender, ClipboardContentChangedEventArgs clipboardContentChangedEventArgs)
        {
            string textData = clipboardDataProvider.GetTextData();

            if (textData != null)
            {
                if (Uri.TryCreate(textData, UriKind.Absolute, out var imageUri))
                {
                    ViewModel.SetImage(imageUri);
                }

                return;
            }

            BitmapFrame imageData = clipboardDataProvider.GetImageData();

            if (imageData != null)
            {
                var encoder = new JpegBitmapEncoder();
                encoder.Frames.Add(imageData);

                using (var memoryStream = new MemoryStream())
                {
                    encoder.Save(memoryStream);
                    ViewModel.SetImage(memoryStream.ToArray());
                }
            }
        }