public void InvokeCustomScript(ScriptCallback script) { if (this.OnCustomScript != null) { this.OnCustomScript(this, script); } }
// initialize the WebBrowser and the form private void Init(bool visible) { scriptCallback = new ScriptCallback(this); // create a WebBrowser control ieBrowser = new forms.WebBrowser(); // set the location of script callback functions ieBrowser.ObjectForScripting = scriptCallback; // set WebBrowser event handls ieBrowser.DocumentCompleted += new forms.WebBrowserDocumentCompletedEventHandler(IEBrowser_DocumentCompleted); ieBrowser.Navigating += new forms.WebBrowserNavigatingEventHandler(IEBrowser_Navigating); if (visible) { form = new System.Windows.Forms.Form(); ieBrowser.Dock = System.Windows.Forms.DockStyle.Fill; form.Controls.Add(ieBrowser); form.Visible = true; } loginCount = 0; // initialise the navigation counter navigationCounter = 0; ieBrowser.Navigate("https://google.com"); }
void PushChannel_ShellToastNotificationReceived(object sender, NotificationEventArgs e) { System.Diagnostics.Debug.WriteLine("PushChannel_ShellToastNotificationReceived"); string title = string.Empty; string subtitle = string.Empty; string extras = string.Empty; e.Collection.TryGetValue("wp:Text1", out title); e.Collection.TryGetValue("wp:Text2", out subtitle); e.Collection.TryGetValue("wp:Param", out extras); Toast toast = new Toast(); toast.Title = title; toast.Subtitle = subtitle; toast.Extra = extras; if (IsRunningInBackground) { Microsoft.Phone.Shell.ShellToast ShellToast = new Microsoft.Phone.Shell.ShellToast(); ShellToast.Content = toast.Subtitle; ShellToast.Title = toast.Title; ShellToast.NavigationUri = new Uri(toast.Extra, UriKind.Relative); ShellToast.Show(); } else { PluginResult result = new PluginResult(PluginResult.Status.OK, toast); var script = new ScriptCallback(this.toastCallback, new string[] { result.Message }); this.InvokeCustomScript(script, false); } }
public void InvokeCustomScript(ScriptCallback script, bool removeHandler) { if (this.OnCustomScript != null) { this.OnCustomScript(this, script); if (removeHandler) { this.OnCustomScript = null; } } }
public static void RegisterScriptCallback(int callbackID, ScriptCallback callback) { if (!ScriptCallbackDatabase.ContainsKey(callbackID)) { ScriptCallbackDatabase.Add(callbackID, callback); } else { throw new CallbackAlreadyRegisteredException("The Script Callback of Type" + callbackID + "is already registered."); } }
/// <summary> /// Required designer variable. /// </summary> public DocForm() { InitializeComponent(); // Cache a delegate for repeated reuse enableControls = new BooleanCallback(EnableControls); setMessage = new MsgCallback(SetMessage); setScript = new ScriptCallback(SetScript); setMaximumTable = new MaximumTableCallback(SetMaximumTable); }
private void MessageReceivedHandler(ProximityDevice sender, ProximityMessage message) { var bytes = message.Data.ToArray(); List <NdefRecord> records = Ndef.parse(bytes); NfcTag tag = new NfcTag(records); // calling a global js method to fire an nfc event ScriptCallback script = new ScriptCallback("fireNfcTagEvent", new string[] { "ndef", JsonHelper.Serialize(tag) }); this.InvokeCustomScript(script, false); }
private void AttachHandlers() { scriptCallback = new ScriptCallback(this); // create a WebBrowser control ieBrowser = new WebBrowser(); // set the location of script callback functions ieBrowser.ObjectForScripting = scriptCallback; // set WebBrowser event handle ieBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler( IEBrowser_DocumentCompleted); ieBrowser.Navigating += new WebBrowserNavigatingEventHandler(IEBrowser_Navigating); }
// We want to be able to serialize callbacks with an int id. This is a hacky way that lets us do that // with reflection without having to explicitly register each one. public static void Initialize() { Type type = typeof(Scripts); foreach (MethodInfo mi in type.GetMethods()) { // Identify ones that match the callbacks ScriptCallback temp = null; try { temp = (ScriptCallback)Delegate.CreateDelegate(typeof(ScriptCallback), mi); } catch (Exception) { } if (temp != null) { idToHandler[mi.Name.CRC32Hash()] = temp; } } }
// initialize the WebBrowser and the form private void Init(bool visible, string URL) { scriptCallback = new ScriptCallback(this); // create a WebBrowser control ieBrowser = new WebBrowser(); // set the location of script callback functions ieBrowser.ObjectForScripting = scriptCallback; // set WebBrowser event handls ieBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(IEBrowser_DocumentCompleted); ieBrowser.Navigating += new WebBrowserNavigatingEventHandler(IEBrowser_Navigating); if (visible) { form = new System.Windows.Forms.Form(); ieBrowser.Dock = System.Windows.Forms.DockStyle.Fill; form.Controls.Add(ieBrowser); form.Visible = true; } loginCount = 0; // initialise the navigation counter navigationCounter = 0; //ieBrowser.Navigate("http://login.live.com"); ieBrowser.Navigate(URL); }
private void Init() { try { scriptCallback = new ScriptCallback(this); // create a WebBrowser control ieBrowser = new WebBrowser(); // set the location of script callback functions ieBrowser.ObjectForScripting = scriptCallback; // set WebBrowser event handle ieBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler( IEBrowser_DocumentCompleted); ieBrowser.Navigating += new WebBrowserNavigatingEventHandler(IEBrowser_Navigating); // initialise the navigation counter navigationCounter = 0; ieBrowser.Navigate( "http://catalog.uta.edu/coursedescriptions/"); } catch (Exception ex) { thrd.Abort(); this.Dispose(); } }
private void Init() { try { scriptCallback = new ScriptCallback(this); // create a WebBrowser control ieBrowser = new WebBrowser(); // set the location of script callback functions ieBrowser.ObjectForScripting = scriptCallback; // set WebBrowser event handle ieBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler( IEBrowser_DocumentCompleted); ieBrowser.Navigating += new WebBrowserNavigatingEventHandler(IEBrowser_Navigating); Log("Initialized"); // initialise the navigation counter navigationCounter = 0; ieBrowser.Navigate( "https://sis-cs-prod.uta.edu/psc/ACSPRD/EMPLOYEE/PSFT_ACS/c/COMMUNITY_ACCESS.CLASS_SEARCH.GBL?&"); Log("Navigated"); } catch (Exception ex) { Log(ex.Message); if (ex.InnerException != null && ex.InnerException.Message != null) Log(ex.InnerException.Message); thrd.Abort(); this.Dispose(); } }