本文整理汇总了C#中TransferDataType类的典型用法代码示例。如果您正苦于以下问题:C# TransferDataType类的具体用法?C# TransferDataType怎么用?C# TransferDataType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransferDataType类属于命名空间,在下文中一共展示了TransferDataType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetData
public override void SetData (TransferDataType type, Func<object> dataSource)
{
var pboard = NSPasteboard.GeneralPasteboard;
pboard.ClearContents ();
owner.DataSource = dataSource;
pboard.AddTypes (new[] { type.ToUTI () }, owner);
}
示例2: BuildTargetTable
public static Gtk.TargetList BuildTargetTable(TransferDataType[] types)
{
var tl = new Gtk.TargetList ();
foreach (var tt in types)
tl.AddTable (CreateTargetEntries (tt));
return tl;
}
示例3: IsTypeAvailable
public override bool IsTypeAvailable (TransferDataType type)
{
if (type == null)
throw new ArgumentNullException ("type");
return WindowsClipboard.ContainsData (type.ToWpfDataFormat ());
}
示例4: SetData
public override void SetData (TransferDataType type, Func<object> dataSource)
{
if (type == null)
throw new ArgumentNullException ("type");
if (dataSource == null)
throw new ArgumentNullException ("dataSource");
if (type == TransferDataType.Html) {
WindowsClipboard.SetData (type.ToWpfDataFormat (), GenerateCFHtml (dataSource ().ToString ()));
} else if (type == TransferDataType.Image) {
var img = dataSource() as Xwt.Drawing.Image;
if (img != null)
{
var src = img.ToBitmap().GetBackend() as WpfImage;
WindowsClipboard.SetData (type.ToWpfDataFormat (), src.MainFrame);
}
>>>>>>> f981e414c3bfee29f5dc508cd099be9b67e0bc9e
} else {
if(type == TransferDataType.Uri) {
currentDataObject.SetFileDropList((StringCollection)(dataSource()));
} else {
currentDataObject.SetData(type.ToWpfDataFormat(), dataSource());
}
}
WindowsClipboard.SetDataObject(currentDataObject);
}
示例5: GetData
public override object GetData(TransferDataType type)
{
if (type == null)
throw new ArgumentNullException ("type");
while (!IsTypeAvailable (type))
Thread.Sleep (1);
return WindowsClipboard.GetData (type.ToWpfDataFormat ());
}
示例6: BeginGetData
public override IAsyncResult BeginGetData(TransferDataType type, AsyncCallback callback, object state)
{
if (type == null)
throw new ArgumentNullException ("type");
if (callback == null)
throw new ArgumentNullException ("callback");
return Task<object>.Factory.StartNew (s => GetData (type), state)
.ContinueWith (t => callback (t));
}
示例7: SetData
public override void SetData (TransferDataType type, Func<object> dataSource)
{
clipboard.SetWithData ((Gtk.TargetEntry[])Util.BuildTargetTable (new TransferDataType[] { type }),
delegate (Gtk.Clipboard cb, Gtk.SelectionData data, uint id) {
TransferDataType ttype = Util.AtomToType (data.Target.Name);
if (ttype == type)
Util.SetSelectionData (data, data.Target.Name, dataSource ());
},
delegate {
});
}
示例8: SetData
public override void SetData (TransferDataType type, Func<object> dataSource, bool cleanClipboardFirst = true)
{
var pboard = NSPasteboard.GeneralPasteboard;
if(cleanClipboardFirst) {
pboard.ClearContents();
}
var owner = new PasteboardOwner();
owner.DataSource = dataSource;
pboard.AddTypes (new[] { type.ToUTI () }, owner);
}
示例9: SetData
public override void SetData (TransferDataType type, Func<object> dataSource)
{
if (type == null)
throw new ArgumentNullException ("type");
if (dataSource == null)
throw new ArgumentNullException ("dataSource");
if (type == TransferDataType.Html) {
WindowsClipboard.SetData (type.ToWpfDataFormat (), GenerateCFHtml (dataSource ().ToString ()));
} else {
WindowsClipboard.SetData (type.ToWpfDataFormat (), dataSource ());
}
}
示例10: IsTypeAvailable
public override bool IsTypeAvailable (TransferDataType type)
{
if (type == TransferDataType.Text)
return clipboard.WaitIsTextAvailable ();
if (type == TransferDataType.Image)
return clipboard.WaitIsImageAvailable ();
foreach (var at in GetAtomsForType (type)) {
if (clipboard.WaitIsTargetAvailable (at))
return true;
}
return false;
}
示例11: GetData
public override object GetData(TransferDataType type)
{
if (type == null)
throw new ArgumentNullException ("type");
if (!IsTypeAvailable (type))
return null;
var data = WindowsClipboard.GetData (type.ToWpfDataFormat ());
if (type == TransferDataType.Image)
return ApplicationContext.Toolkit.WrapImage(ImageHandler.LoadFromImageSource((System.Windows.Media.ImageSource)data));
return data;
}
示例12: GetData
public override object GetData (TransferDataType type)
{
if (type == TransferDataType.Text)
return clipboard.WaitForText ();
if (type == TransferDataType.Text)
return clipboard.WaitForImage ();
TransferDataStore store = new TransferDataStore ();
foreach (var at in GetAtomsForType (type)) {
var data = clipboard.WaitForContents (at);
Util.GetSelectionData (ApplicationContext, data, store);
}
return ((ITransferData)store).GetValue (type);
}
示例13: GetData
public object GetData(TransferDataType type)
{
if (type == null)
throw new ArgumentNullException ("type");
while (!IsTypeAvailable (type))
Thread.Sleep (1);
if (type == TransferDataType.Image)
return WindowsClipboard.GetImage ();
if (type == TransferDataType.Rtf)
return WindowsClipboard.GetText (TextDataFormat.Rtf);
if (type == TransferDataType.Text) {
if (WindowsClipboard.ContainsText (TextDataFormat.UnicodeText))
return WindowsClipboard.GetText();
return WindowsClipboard.GetText (TextDataFormat.Text);
}
throw new NotImplementedException();
}
示例14: GetData
public override object GetData (TransferDataType type)
{
if (type == TransferDataType.Uri)
return (Uri)NSUrl.FromPasteboard (NSPasteboard.GeneralPasteboard);
var data = NSPasteboard.GeneralPasteboard.GetDataForType (type.ToUTI ());
if (data == null)
return null;
if (type == TransferDataType.Text)
return data.ToString ();
if (type == TransferDataType.Image)
return new NSImage (data);
unsafe {
var bytes = new byte [data.Length];
using (var stream = new UnmanagedMemoryStream ((byte*)data.Bytes, bytes.Length))
stream.Read (bytes, 0, bytes.Length);
return TransferDataSource.DeserializeValue (bytes);
}
}
示例15: IsTypeAvailable
public override bool IsTypeAvailable(TransferDataType type)
{
return NSPasteboard.GeneralPasteboard.Types.Contains (type.ToUTI ());
}