本文整理汇总了C#中TransferDataType类的典型用法代码示例。如果您正苦于以下问题:C# TransferDataType类的具体用法?C# TransferDataType怎么用?C# TransferDataType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransferDataType类属于命名空间,在下文中一共展示了TransferDataType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:StEvUgnIn,项目名称:xwt,代码行数:7,代码来源:MacClipboardBackend.cs
示例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;
}
开发者ID:samclarke,项目名称:xwt,代码行数:7,代码来源:Util.cs
示例3: IsTypeAvailable
public override bool IsTypeAvailable (TransferDataType type)
{
if (type == null)
throw new ArgumentNullException ("type");
return WindowsClipboard.ContainsData (type.ToWpfDataFormat ());
}
开发者ID:m13253,项目名称:xwt,代码行数:7,代码来源:ClipboardBackend.cs
示例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);
}
开发者ID:TheBrainTech,项目名称:xwt,代码行数:26,代码来源:ClipboardBackend.cs
示例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 ());
}
开发者ID:Gaushick,项目名称:xwt,代码行数:10,代码来源:ClipboardBackend.cs
示例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));
}
开发者ID:Gaushick,项目名称:xwt,代码行数:10,代码来源:ClipboardBackend.cs
示例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 {
});
}
开发者ID:StEvUgnIn,项目名称:xwt,代码行数:11,代码来源:ClipboardBackend.cs
示例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);
}
开发者ID:TheBrainTech,项目名称:xwt,代码行数:11,代码来源:MacClipboardBackend.cs
示例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 ());
}
}
开发者ID:m13253,项目名称:xwt,代码行数:12,代码来源:ClipboardBackend.cs
示例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;
}
开发者ID:StEvUgnIn,项目名称:xwt,代码行数:13,代码来源:ClipboardBackend.cs
示例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;
}
开发者ID:akrisiun,项目名称:xwt,代码行数:14,代码来源:ClipboardBackend.cs
示例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);
}
开发者ID:StEvUgnIn,项目名称:xwt,代码行数:15,代码来源:ClipboardBackend.cs
示例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();
}
开发者ID:joncham,项目名称:xwt,代码行数:21,代码来源:ClipboardBackend.cs
示例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);
}
}
开发者ID:StEvUgnIn,项目名称:xwt,代码行数:21,代码来源:MacClipboardBackend.cs
示例15: IsTypeAvailable
public override bool IsTypeAvailable(TransferDataType type)
{
return NSPasteboard.GeneralPasteboard.Types.Contains (type.ToUTI ());
}
开发者ID:akrisiun,项目名称:xwt,代码行数:4,代码来源:MacClipboardBackend.cs
示例16: BeginGetData
public abstract IAsyncResult BeginGetData (TransferDataType type, AsyncCallback callback, object state);
开发者ID:TheBrainTech,项目名称:xwt,代码行数:1,代码来源:ClipboardBackend.cs
示例17: GetData
public abstract object GetData (TransferDataType type);
开发者ID:TheBrainTech,项目名称:xwt,代码行数:1,代码来源:ClipboardBackend.cs
示例18: IsTypeAvailable
public abstract bool IsTypeAvailable (TransferDataType type);
开发者ID:TheBrainTech,项目名称:xwt,代码行数:1,代码来源:ClipboardBackend.cs
示例19: SetData
public abstract void SetData (TransferDataType type, Func<object> dataSource, bool cleanClipboardFirst = true);
开发者ID:TheBrainTech,项目名称:xwt,代码行数:1,代码来源:ClipboardBackend.cs
示例20: CreateTargetEntries
static Gtk.TargetEntry[] CreateTargetEntries(TransferDataType type)
{
lock (dragTargets) {
Gtk.TargetEntry[] entries;
if (dragTargets.TryGetValue (type, out entries))
return entries;
uint id = targetIdCounter++;
if (type == TransferDataType.Uri) {
Gtk.TargetList list = new Gtk.TargetList ();
list.AddUriTargets (id);
entries = (Gtk.TargetEntry[])list;
}
else if (type == TransferDataType.Text) {
Gtk.TargetList list = new Gtk.TargetList ();
list.AddTextTargets (id);
//HACK: work around gtk_selection_data_set_text causing crashes on Mac w/ QuickSilver, Clipbard History etc.
if (Platform.IsMac) {
list.Remove ("COMPOUND_TEXT");
list.Remove ("TEXT");
list.Remove ("STRING");
}
entries = (Gtk.TargetEntry[])list;
}
else if (type == TransferDataType.Rtf) {
Gdk.Atom atom;
if (Platform.IsMac)
atom = Gdk.Atom.Intern ("NSRTFPboardType", false); //TODO: use public.rtf when dep on MacOS 10.6
else
atom = Gdk.Atom.Intern ("text/rtf", false);
entries = new Gtk.TargetEntry[] { new Gtk.TargetEntry (atom, 0, id) };
}
else {
entries = new Gtk.TargetEntry[] { new Gtk.TargetEntry (Gdk.Atom.Intern ("application/" + type.Id, false), 0, id) };
}
foreach (var a in entries.Select (e => e.Target))
atomToType [a] = type;
return dragTargets [type] = entries;
}
}
开发者ID:samclarke,项目名称:xwt,代码行数:42,代码来源:Util.cs
注:本文中的TransferDataType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论