本文整理汇总了C#中ScriptCoreLib.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptCoreLib.Add方法的具体用法?C# ScriptCoreLib.Add怎么用?C# ScriptCoreLib.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScriptCoreLib
的用法示例。
在下文中一共展示了ScriptCoreLib.Add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
{
// can we inject ourselves into a chrome tab
// before the page loads?
// http://stackoverflow.com/questions/19191679/chrome-extension-inject-js-before-page-load
// If you want to dynamically run a script as soon as possible, then call chrome.tabs.executeScript when the chrome.webNavigation.onCommitted event is triggered.
// when does that happen?
// if we are able to preload, would we be able to act as adblock?
// as per X:\jsc.svn\examples\javascript\chrome\extensions\ChromeExtensionShadowExperiment\ChromeExtensionShadowExperiment\Application.cs
// first lets get this test running in chrome
dynamic self = Native.self;
dynamic self_chrome = self.chrome;
object self_chrome_tabs = self_chrome.tabs;
if (self_chrome_tabs != null)
{
#region Installed
chrome.runtime.Installed += delegate
{
// our API does not have a Show
new chrome.Notification
{
Message = "ChromeExtensionPreShadow Installed!"
};
};
#endregion
// what about
// Error code: ERR_INTERNET_DISCONNECTED
var once = new { tabId = default(TabIdInteger), url = default(string) }.ToEmptyList();
new { }.With(
async delegate
{
// X:\jsc.svn\examples\javascript\chrome\extensions\ChromeExtensionWithWorker\ChromeExtensionWithWorker\Application.cs
var code = await new WebClient().DownloadStringTaskAsync(
new Uri(Worker.ScriptApplicationSource, UriKind.Relative)
);
new chrome.Notification
{
Message = "code " + new { code.Length }
};
chrome.webNavigation.Committed +=
async z =>
{
// 0:5212ms at Delay {{ _title = , _message = webNavigation! Committed {{ url = http://example.com/, tabId = 99, transitionType = typed, transitionQualifiers = from_address_bar }} }}
if (z.url.StartsWith("https://www.google.ee/_/chrome/newtab?"))
{
//Unchecked runtime.lastError while running tabs.executeScript: Cannot access a chrome:// URL
return;
}
// 0:487298ms at Delay {
// {
// _title = , _message = webNavigation!Committed {
// {
// url = chrome://chrome/extensions/, tabId = 158, transitionType = auto_bookmark, transitionQualifiers = }} }} view-source:41478
//Unchecked runtime.lastError while running tabs.executeScript: Cannot access a chrome:// URL
if (z.transitionType == "auto_subframe")
{
// this seems to be an ad?
// https://developer.chrome.com/extensions/history
return;
}
if (z.url.StartsWith("chrome-devtools://"))
return;
if (z.url.StartsWith("chrome://"))
return;
// now would be nice to check if this tab was already injected.
once.Add(new { z.tabId, z.url });
var n = new chrome.Notification
//.........这里部分代码省略.........
示例2: Application
//.........这里部分代码省略.........
{
map,
useScreenCoordinates = false,
//color = 0xff0000
color = 0xffffff
}
);
var sprite = new THREE.Sprite(xcrateMaterial);
//floor
//sprite2.position.set(0, -200, 0);
// left middle
//sprite2.position.set(200, 0, 0);
//sprite.position.set(250, -50, 50);
//lineTo.Add(sprite.position);
//sprite2.position.set(0, 0, 200);
//sprite2.position.set(-100, 0, 0);
sprite.scale.set(
canvas.width * 0.5,
canvas.height * 0.5,
//64, 64,
1.0); // imageWidth, imageHeight
scene.add(sprite);
others.Add(
new
{
ui,
canvas,
map,
sprite
}
);
var sw = Stopwatch.StartNew();
Native.window.onframe += delegate
{
// can we get some of the crazy c++ template bitmapbuffer code from the past?
map.needsUpdate = true;
var offset = Math.PI * 2 * ((double)(index + 1) / others.Count);
sprite.position.x = 300;
sprite.position.z = Math.Sin(sw.ElapsedMilliseconds * 0.00001 + offset) * 120;
sprite.position.y = Math.Cos(sw.ElapsedMilliseconds * 0.00001 + offset) * 120;
};
};
#endregion
add(
new NotificationLayout
{
// keep attributes around?
示例3: 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)
{
page.clear.WhenClicked(
delegate
{
//page.search.Clear();
page.search.value = "";
}
);
new IHTMLButton { innerText = "Install" }.AttachToDocument().With(
btn =>
{
// http://help.adobe.com/en_US/air/build/WSfffb011ac560372f-5d0f4f25128cc9cd0cb-7ffd.html
btn.onclick +=
delegate
{
service.Install("assets/AndroidListApplications/foo.apk");
};
}
);
var items = new
{
div = default(IHTMLDiv),
packageName = "",
name = "",
Remove = default(IHTMLButton),
Launch = default(IHTMLButton)
}.ToEmptyList();
Action queryIntentActivities =
async delegate
{
var a = new List<string>();
// Send data from JavaScript to the server tier
await service.queryIntentActivities(
yield: (packageName, name, icon_base64, label) =>
{
#region yield
a.Add(packageName);
// already have it
if (items.Any(k => k.packageName == packageName))
return;
var div = new IHTMLDiv();
div.style.margin = "1em";
if (Native.Document.body.firstChild == null)
div.AttachToDocument();
else
Native.Document.body.insertBefore(div, Native.Document.body.firstChild);
new IHTMLImage { src = "data:image/png;base64," + icon_base64 }.AttachTo(div);
new IHTMLSpan { innerText = label }.AttachTo(div);
var Remove = new IHTMLButton { innerText = "Remove" }.AttachTo(div).WhenClicked(
btn =>
{
// http://help.adobe.com/en_US/air/build/WSfffb011ac560372f-5d0f4f25128cc9cd0cb-7ffd.html
if (!Native.window.confirm("Remove " + name + "?"))
return;
service.Remove(packageName, name);
}
);
//div.appendChild(new { icon_base64.Length }.ToString());
var Launch = new IHTMLButton { innerText = "Launch" }.AttachTo(div).WhenClicked(
btn =>
{
// http://help.adobe.com/en_US/air/build/WSfffb011ac560372f-5d0f4f25128cc9cd0cb-7ffd.html
service.Launch(packageName, name);
}
);
var LaunchFloat = new IHTMLButton { innerText = "Launch Float" }.AttachTo(div).WhenClicked(
btn =>
{
service.Launch(packageName, name,
ExtraKey: "Float",
ExtraValue: "Float"
);
}
);
//.........这里部分代码省略.........
示例4: 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);
//.........这里部分代码省略.........
示例5: Application
//.........这里部分代码省略.........
Native.window.onblur +=
delegate
{
AtResize();
};
new ScriptCoreLib.JavaScript.Runtime.Timer(
delegate
{
AtResize();
}
).StartInterval(1000 / 2);
#endregion
// what is attaching what?
// what about await
var svgcursor1ghost = new cursor1().AttachTo(page.content).ToSVG();
var svgcursor1 = new cursor1().AttachTo(page.content).ToSVG();
svgcursor1.fill += svgcursor1ghost.fill;
var vcursor = new cursor1().AttachTo(fvs.GetHTMLTarget()).ToSVG();
var Shadows = new List<Form>();
Func<Form, Form> CreateShadow =
_fw =>
{
FormStyler.AtFormCreated = LikeVirtualWindow;
var fwshadow = new Form();
Shadows.Add(fwshadow);
fwshadow.BackColor = Color.Transparent;
FormStyler.AtFormCreated = FormStyler.LikeWindowsClassic;
fwshadow.Width = Native.screen.width / 4;
fwshadow.Height = Native.screen.height / 4;
fwshadow.Show();
Action fwshadow_update = delegate
{
fwshadow.MoveTo(_fw.Left, _fw.Top);
fwshadow.SizeTo(_fw.Width, _fw.Height);
};
_fw.LocationChanged +=
delegate
{
fwshadow_update();
};
_fw.SizeChanged +=
delegate
{
fwshadow_update();
};
fwshadow_update();
_fw.BringToFront();