本文整理汇总了C#中ScriptCoreLib.WithEachIndex方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptCoreLib.WithEachIndex方法的具体用法?C# ScriptCoreLib.WithEachIndex怎么用?C# ScriptCoreLib.WithEachIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScriptCoreLib
的用法示例。
在下文中一共展示了ScriptCoreLib.WithEachIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Application
/// <summary>
/// This is a javascript application.
/// </summary>
/// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
public Application(IApp page)
{
var y = page.ThePath_y;
var x = page.ThePath_x;
var z = page.ThePath_z;
page.TheText.textContent = "pointer lock movement";
// script: error JSC1000: No implementation found for this native method, please implement [static Microsoft.CSharp.RuntimeBinder.Binder.IsEvent(Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags, System.String, System.Type)]
//pp.setAttribute("d", pp.getAttribute("d") + " l100,-10 ");
var history =
new { x = 0.0, y = 0.0, z = 0.0 }.ToEmptyList();
50.Times(
delegate
{
history.Add(
// vec2?
new { x = 0.0, y = 0.0, z = 0.0 }
);
}
);
var movementX = 0.0;
var movementY = 0.0;
var movementZ = 0.0;
Native.Document.body.onmousedown +=
e =>
{
Native.Document.body.requestPointerLock();
};
Native.Document.body.onmousemove +=
e =>
{
if (Native.Document.body == Native.Document.pointerLockElement)
{
movementX += e.movementX;
movementY += e.movementY;
}
};
new ScriptCoreLib.JavaScript.Runtime.Timer(
delegate
{
history.Add(
// vec2?
new { x = movementX, y = movementY, z = movementZ }
);
movementX = 0;
movementY = 0;
movementZ = 0;
if (history.Count > 500)
{
history.RemoveAt(0);
}
// http://www.w3.org/TR/SVG/paths.html#PathDataMovetoCommands
var xw = new StringBuilder().Append("M10,200 ");
var yw = new StringBuilder().Append("M10,300 ");
var zw = new StringBuilder().Append("M10,400 ");
history.WithEachIndex(
(p, i) =>
{
xw.Append(" L" + (10 + 2 * i) + "," + (p.x + 200));
yw.Append(" L" + (10 + 2 * i) + "," + (p.y + 300));
zw.Append(" L" + (10 + 2 * i) + "," + (p.z + 400));
}
);
xw.Append(" L" + (10 + 2 * history.Count) + "," + (201));
yw.Append(" L" + (10 + 2 * history.Count) + "," + (301));
zw.Append(" L" + (10 + 2 * history.Count) + "," + (401));
//Console.WriteLine(new { xw, yw });
y.d = yw.ToString();
x.d = xw.ToString();
z.d = zw.ToString();
}
).StartInterval(1000 / 10);
//.........这里部分代码省略.........