本文整理汇总了C#中ScriptObject类的典型用法代码示例。如果您正苦于以下问题:C# ScriptObject类的具体用法?C# ScriptObject怎么用?C# ScriptObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScriptObject类属于命名空间,在下文中一共展示了ScriptObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GMapAPI
public GMapAPI()
{
timer.Interval = TimeSpan.FromMilliseconds(100);
timer.Tick += new EventHandler(timer_Tick);
gload = (ScriptObject)HtmlPage.Window.GetProperty("GLoad");
if (gload == null)
{
HtmlElement scriptElement = HtmlPage.Document.CreateElement("script");
scriptElement.SetAttribute("type", "text/javascript");
string src = "http://maps.google.com/maps?file=api&v=2";
scriptElement.SetAttribute("src", src);
HtmlPage.Document.Body.AppendChild(scriptElement);
gload = (ScriptObject)HtmlPage.Window.GetProperty("GLoad");
if (gload == null)
{
timer.Start();
}
else
{
SetReady();
}
}
}
示例2: ScriptObjectEventInfo
public ScriptObjectEventInfo (string name, ScriptObject callback, EventInfo ei)
{
Name = name;
Callback = callback;
EventInfo = ei;
NativeMethods.html_object_retain (PluginHost.Handle, Callback.Handle);
}
示例3: Execute
public override bool Execute(ScriptObject scriptObject)
{
try
{
int cameranum = 0;
if (int.TryParse(scriptObject.ParseString(LoadedParams["cameranum"]), out cameranum))
{
if (cameranum > -1 && cameranum < ServiceProvider.DeviceManager.ConnectedDevices.Count)
{
ServiceProvider.DeviceManager.SelectedCameraDevice =
ServiceProvider.DeviceManager.ConnectedDevices[cameranum];
scriptObject.CameraDevice = ServiceProvider.DeviceManager.ConnectedDevices[cameranum];
}
else
{
ServiceProvider.ScriptManager.OutPut("Camera with number " + cameranum + "not exist");
}
}
else
{
ServiceProvider.ScriptManager.OutPut("Wrong camera number");
}
}
catch (Exception exception)
{
ServiceProvider.ScriptManager.OutPut("Exception on select camera " + exception.Message);
}
return true;
}
示例4: LoadScript
// must be called on UI thread
public static void LoadScript()
{
//0 indicates that the script was not injected.
if (0 != Interlocked.Exchange(ref _scriptInjected, 1))
return;
//JavaScript Debug - v0.4 - 6/22/2010
//http://benalman.com/projects/javascript-debug-console-log/
//Copyright (c) 2010 "Cowboy" Ben Alman
const string script = @"window.debug=(function(){var i=this,b=Array.prototype.slice,d=i.console,h={},f,g,m=9,c=[""error"",""warn"",""info"",""debug"",""log""],l=""assert clear count dir dirxml exception group groupCollapsed groupEnd profile profileEnd table time timeEnd trace"".split("" ""),j=l.length,a=[];while(--j>=0){(function(n){h[n]=function(){m!==0&&d&&d[n]&&d[n].apply(d,arguments)}})(l[j])}j=c.length;while(--j>=0){(function(n,o){h[o]=function(){var q=b.call(arguments),p=[o].concat(q);a.push(p);e(p);if(!d||!k(n)){return}d.firebug?d[o].apply(i,q):d[o]?d[o](q):d.log(q)}})(j,c[j])}function e(n){if(f&&(g||!d||!d.log)){f.apply(i,n)}}h.setLevel=function(n){m=typeof n===""number""?n:9};function k(n){return m>0?m>n:c.length+m<=n}h.setCallback=function(){var o=b.call(arguments),n=a.length,p=n;f=o.shift()||null;g=typeof o[0]===""boolean""?o.shift():false;p-=typeof o[0]===""number""?o.shift():n;while(p<n){e(a[p++])}};return h})();";
try
{
HtmlWindow window = HtmlPage.Window;
window.Eval(script);
// get handle to methods
_debugError = window.Eval("debug.error") as ScriptObject;
_debugWarn = window.Eval("debug.warn") as ScriptObject;
_debugInfo = window.Eval("debug.info") as ScriptObject;
_debugLog = window.Eval("debug.log") as ScriptObject;
}
catch (Exception ex)
{
Debug.WriteLine("Error loading debug.log script: " + ex);
}
}
示例5: HandleNavigate
public void HandleNavigate(ScriptObject state)
{
if (Navigate != null)
{
Navigate(this, new StateEventArgs() { State = state });
}
}
示例6: InitializeConsole
/// <summary>
/// Initializes the console for silverlight applications.
/// </summary>
/// <returns><c>true</c> if the console is available; otherwise <c>false</c>.</returns>
private bool InitializeConsole()
{
try
{
if (_console == null)
{
if (!_dispatcher.CheckAccess())
{
return false;
}
var window = HtmlPage.Window;
var isConsoleAvailable = (bool)window.Eval("typeof(console) != 'undefined' && typeof(console.log) != 'undefined'");
if (isConsoleAvailable)
{
var createLogFunction = (bool)window.Eval("typeof(catellog) === 'undefined'");
if (createLogFunction)
{
// Load the logging function into global scope:
const string logFunction = @"function catellog(msg) { console.log(msg); }";
string code = string.Format(@"if(window.execScript) {{ window.execScript('{0}'); }} else {{ eval.call(null, '{0}'); }}", logFunction);
window.Eval(code);
}
_console = window.Eval("catellog") as ScriptObject;
}
}
}
catch (Exception)
{
}
return (_console != null);
}
示例7: Call
public object Call(ScriptObject[] args)
{
for (int i = 0; i < args.Length; ++i) {
output += args[i].ToString() + "\n";
}
return null;
}
示例8: Execute
public override bool Execute(ScriptObject scriptObject)
{
ServiceProvider.ScriptManager.OutPut("Bulb capture started");
Executing = true;
if (scriptObject.CameraDevice != null)
{
if (scriptObject.CameraDevice.IsoNumber != null)
scriptObject.CameraDevice.IsoNumber.SetValue(Iso);
Thread.Sleep(200);
if (scriptObject.CameraDevice.FNumber != null)
scriptObject.CameraDevice.FNumber.SetValue(Aperture);
Thread.Sleep(200);
}
scriptObject.StartCapture();
Thread.Sleep(200);
for (int i = 0; i < CaptureTime; i++)
{
if (ServiceProvider.ScriptManager.ShouldStop)
break;
Thread.Sleep(1000);
ServiceProvider.ScriptManager.OutPut(string.Format("Bulb capture in progress .... {0}/{1}", i + 1,
CaptureTime));
}
scriptObject.StopCapture();
Thread.Sleep(200);
Executing = false;
IsExecuted = true;
ServiceProvider.ScriptManager.OutPut("Bulb capture done");
return true;
}
示例9: Execute
public override bool Execute(ScriptObject scriptObject)
{
int time = 0;
int.TryParse(scriptObject.ParseString(LoadedParams["time"]), out time);
Executing = true;
DateTime currTime = DateTime.Now;
if (LoadedParams["for"] == "camera" && ServiceProvider.DeviceManager.SelectedCameraDevice != null)
{
ServiceProvider.ScriptManager.OutPut(string.Format("Waiting .... for camera"));
while (ServiceProvider.DeviceManager.SelectedCameraDevice.IsBusy)
{
if (ServiceProvider.ScriptManager.ShouldStop)
break;
Thread.Sleep(100);
}
}
double dif = time - (DateTime.Now - currTime).TotalSeconds;
if (dif > 0)
{
ServiceProvider.ScriptManager.OutPut(string.Format("Waiting .... {0}s", dif));
while ((DateTime.Now - currTime).TotalSeconds < time)
{
if (ServiceProvider.ScriptManager.ShouldStop)
break;
Thread.Sleep(100);
}
}
Executing = false;
IsExecuted = true;
return true;
}
示例10: readAsArrayBuffer
public void readAsArrayBuffer(ScriptObject scriptBlob)
{
App.Current.RootVisual.Dispatcher.BeginInvoke((Action<ScriptObject>)delegate(ScriptObject blob)
{
this.readAsArrayBufferSync(blob);
}, new object[]{scriptBlob});
}
示例11: NavigateTo
public void NavigateTo(string controlName, ScriptObject parameterList)
{
var paramList = parameterList.ConvertTo<List<object>>();
var launcher = pageLaunchers[controlName];
LayoutRoot.Children.Clear();
var form = launcher(paramList);
LayoutRoot.Children.Add(form);
}
示例12: ScriptObjectEventInfo
// extract common [SecurityCritical] parts of the public .ctors
private ScriptObjectEventInfo (ScriptObject callback)
{
if (callback == null)
throw new ArgumentNullException ("callback");
Callback = callback;
NativeMethods.html_object_retain (PluginHost.Handle, Callback.Handle);
}
示例13: Register
public static void Register(ScriptObject builtins)
{
if (builtins == null) throw new ArgumentNullException(nameof(builtins));
var mathObject = ScriptObject.From(typeof(MathFunctions));
mathObject.SetValue("round", new DelegateCustomFunction(Round), true);
builtins.SetValue("math", mathObject, true);
}
示例14: isf_get
/**
* Conducts an Isolated Storage data retrieval operation on
* files identified by or in Objects in a given collection.
* @param dataArray a ScriptObject consisting of ScriptObjects that each either identify or contain
* identifying and operation related data pertaining to a data item to be retrieved
* @param optionsDic a ScriptObject containing auxiliary data pertinent to the to-be-conducted operation
* @param operationID a String uniquely identifying this storage operation in the
* client-side scripting environment in which it was created
*/
public void isf_get(ScriptObject dataArraySO, ScriptObject optionsSO, String operationID)
{
//Will contain key-value pairs each consisting of the name of a file in Isolated Storage
//denoted or represented by an element in dataArray, and the contents of that file
Dictionary<String, Object> keyValuePairsDic = new Dictionary<String, Object>();
int processedItemCount = 0;
/**
* Concludes the over-arching retrieval operation, passing to a Javascript function capable of handling
* such an event the number of files successfully read along with the data resulting from the operation.
* @param e the Exception responsible for concluding the over-arching get operation
*/
Action<Exception> completeGet = delegate(Exception e)
{
Object[] argArray = (e == null ? new Object[] { processedItemCount, keyValuePairsDic }
: new Object[] { processedItemCount, keyValuePairsDic, e });
complete(operationID, argArray);
};
/**
* Performs a read operation on the file identified by the currently processing ScriptObject
* in {@code dataArraySO} located in the directory specified by {@code optionsSO}.
* @param store an IsolatedStorageFile manifestation of the facility containing
* the file identified by {@code directoryPath} and {@code dataObject}
* @param directoryPath a String of the path to the Directory containing the file to be read
* @param dataObject an Object either identifying, or containing identifying and
* operation-related data pertaining to a data item to be processed
*/
Action<IsolatedStorageFile, String, Object> get = delegate(IsolatedStorageFile store, String directoryPath, Object dataObject)
{
String fileName;
String dataFormat;
String dataEncoding;
if (dataObject is ScriptObject)
{
ScriptObject dataSO = (ScriptObject)dataObject;
fileName = dataSO.GetProperty("key").ToString();
dataFormat = (dataSO.GetProperty("dataFormat") != null ? (String)dataSO.GetProperty("dataFormat") : (String)optionsSO.GetProperty("dataFormat"));
dataEncoding = (dataSO.GetProperty("dataEncoding") != null ? (String)dataSO.GetProperty("dataEncoding") : (String)optionsSO.GetProperty("dataEncoding"));
}
else
{
fileName = dataObject.ToString();
dataFormat = (String)optionsSO.GetProperty("dataFormat");
dataEncoding = (String)optionsSO.GetProperty("dataEncoding");
}
keyValuePairsDic[fileName] = readFile(store, directoryPath + fileName, dataFormat, dataEncoding);
processedItemCount++;
};
isf_getOrRemove(dataArraySO, optionsSO, get, completeGet);
}
示例15: Execute
public override bool Execute(ScriptObject scriptObject)
{
foreach (ICameraDevice cameraDevice in ServiceProvider.DeviceManager.ConnectedDevices)
{
ICameraDevice device = cameraDevice;
new Thread(() => Capture(device)).Start();
}
return true;
}