本文整理汇总了C#中Toolkit.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# Toolkit.Invoke方法的具体用法?C# Toolkit.Invoke怎么用?C# Toolkit.Invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Toolkit
的用法示例。
在下文中一共展示了Toolkit.Invoke方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadForToolkit
public NativeImageRef LoadForToolkit(Toolkit targetToolkit)
{
if (Toolkit == targetToolkit)
return this;
NativeImageRef newRef = null;
var r = NextRef;
while (r != this) {
if (r.toolkit == targetToolkit) {
newRef = r;
break;
}
r = r.NextRef;
}
if (newRef != null)
return newRef;
object newBackend = null;
if (sources != null) {
var frames = new List<object> ();
foreach (var s in sources) {
if (s.ImageLoader != null) {
var streams = s.ImageLoader ();
try {
if (streams.Length == 1) {
newBackend = targetToolkit.ImageBackendHandler.LoadFromStream (streams [0]);
} else {
var backends = new object [streams.Length];
for (int n = 0; n < backends.Length; n++) {
backends [n] = targetToolkit.ImageBackendHandler.LoadFromStream (streams [n]);
}
newBackend = targetToolkit.ImageBackendHandler.CreateMultiResolutionImage (backends);
}
} finally {
foreach (var st in streams)
st.Dispose ();
}
} else if (s.CustomImageLoader != null) {
targetToolkit.Invoke (() => newBackend = Image.FromCustomLoader (s.CustomImageLoader, s.Source, s.Tags).GetBackend());
} else if (s.ResourceAssembly != null) {
targetToolkit.Invoke (() => newBackend = Image.FromResource (s.ResourceAssembly, s.Source).GetBackend());
}
else if (s.Source != null)
targetToolkit.Invoke (() => newBackend = Image.FromFile (s.Source).GetBackend());
else if (s.DrawCallback != null)
newBackend = targetToolkit.ImageBackendHandler.CreateCustomDrawn (s.DrawCallback);
else if (s.StockId != null)
newBackend = targetToolkit.GetStockIcon (s.StockId).GetBackend ();
else
throw new NotSupportedException ();
frames.Add (newBackend);
}
newBackend = targetToolkit.ImageBackendHandler.CreateMultiSizeIcon (frames);
} else {
using (var s = new MemoryStream ()) {
toolkit.ImageBackendHandler.SaveToStream (backend, s, ImageFileType.Png);
s.Position = 0;
newBackend = targetToolkit.ImageBackendHandler.LoadFromStream (s);
}
}
newRef = new NativeImageRef (newBackend, targetToolkit);
newRef.NextRef = NextRef;
NextRef = newRef;
return newRef;
}