爱洋酱

导航

C#获取到系统剪切板中复制的图片资源,展示到程序中

     IDataObject iData = Clipboard.GetDataObject();
        private void BasePage_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            //Ctrl+V 粘贴
            if ((e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) || e.KeyboardDevice.IsKeyDown(Key.RightCtrl)) && e.KeyboardDevice.IsKeyDown(Key.V))
            {
                if (iData.GetDataPresent(DataFormats.FileDrop))
                {
var files = Clipboard.GetFileDropList(); if (files.Count == 0) { return; } if (files[0] != null) { image_ocr.Source = new BitmapImage(new Uri(files[0])); } } } } }

 

posted on 2022-08-03 18:35  爱洋酱  阅读(492)  评论(0编辑  收藏  举报