52 lines
1.2 KiB
C#
52 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Lskj.PubUtils
|
|
{
|
|
/// <summary>
|
|
/// 剪切板公共方法
|
|
/// </summary>
|
|
public static class ClipboardHelper
|
|
{
|
|
/// <summary>
|
|
/// 查找剪切板图片
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static Image FindClipboardImage()
|
|
{
|
|
try
|
|
{
|
|
IDataObject data = Clipboard.GetDataObject();
|
|
if (data.GetDataPresent(typeof(Bitmap)))
|
|
{
|
|
return (Image)data.GetData(typeof(Bitmap));
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
}
|
|
return null;
|
|
}
|
|
/// <summary>
|
|
/// 剪切板是否包含图片
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static bool ContainsImage()
|
|
{
|
|
try
|
|
{
|
|
return Clipboard.ContainsImage();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
}
|