本文整理汇总了C#中IScript.Run方法的典型用法代码示例。如果您正苦于以下问题:C# IScript.Run方法的具体用法?C# IScript.Run怎么用?C# IScript.Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IScript
的用法示例。
在下文中一共展示了IScript.Run方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: pbRenderTarget_Paint
private void pbRenderTarget_Paint( object sender, PaintEventArgs args )
{
var nowUtc = DateTime.UtcNow;
var dt = (float)(nowUtc-PreviousFrameUtc).TotalSeconds;
PreviousFrameUtc = nowUtc;
if ( dt<0 ) dt=0;
if ( dt>1 ) dt=1;
T += dt;
if ( LastCompiledScript != null ) try
{
var w = pbRenderTarget.ClientSize.Width;
var h = pbRenderTarget.ClientSize.Height;
using ( var bitmap = new Bitmap(w,h) )
{
using ( var fx = Graphics.FromImage(bitmap) )
{
var script = LastCompiledScript;
var args2 = new ScriptRunArgs(fx,new Rectangle(0,0,w,h),T,dt);
Exception ex = null;
var render = new Thread(()=>{
try
{
script.Run(args2);
}
catch ( Exception tex )
{
ex = tex;
}
});
render.Start();
if (!render.Join(200))
{
render.Interrupt();
render.Abort();
LastCompiledScript = new ErrorScript( Font, "Script timed out rendering" );
LastCompiledScript.Run(args2);
}
else if ( ex != null )
{
throw ex;
}
}
args.Graphics.DrawImage( bitmap, new Rectangle(0,0,w,h) );
}
}
catch ( Exception e )
{
if (!CodeExceptions)
{
CodeExceptions = true;
lvErrors.Items.Add( new ListViewItem(new[]{"Exception", "Exception running script"}) );
lvErrors.Items.Add( new ListViewItem(new[]{"Exception Type", e.GetType().FullName}) );
lvErrors.Items.Add( new ListViewItem(new[]{"Exception Message", e.Message}) );
}
}
}