Beispiel #1
0
        private void BrowserScriptNotify(object sender, NotifyEventArgs e)
        {
            string wooterMarker = "wooterimage";
            var url = e.Value;
            Match match = this.regex.Match(url);

            if (url.StartsWith(wooterMarker))
            {
                url = url.Substring(wooterMarker.Length);
                DisplayAdditionalImage(url);
            }
            else if (match.Success)
            {
                url = match.Groups[1].Value;
                DisplayAdditionalImage(url);
            }
            else
            {
                try
                {
                    task.Uri = new Uri(url);
                    task.Show();
                }
                catch
                {
                }
            }
        }
Beispiel #2
0
 private void ScriptNotify(object sender, NotifyEventArgs e)
 {
     if (!string.IsNullOrEmpty(e.Value))
     {
         Uri navigateTo = utilities.processBBcodeLink(e.Value);
         if (navigateTo != null)
             NavigationService.Navigate(navigateTo);
     }
 }
 private void Browser_ScriptNotify(object sender, NotifyEventArgs e)
 {
     if (e.Value == "chooseAddress")
      {
     var task = new AddressChooserTask();
     task.Completed += task_Completed;
     task.Show();
      }
 }
 private void Browser_ScriptNotify(object sender, NotifyEventArgs e)
 {
     // if a page notifies that it should not be scrollable, disable
       // scrolling.
       if (e.Value == "noScroll")
       {
       _browserHelper.ScrollDisabled = true;
       }
 }
Beispiel #5
0
        private void browser_ScriptNotify(object sender, NotifyEventArgs e)
        {
            var response = new object[]
                {
                    DeviceStatus.ApplicationCurrentMemoryUsage,
                    DeviceStatus.ApplicationMemoryUsageLimit,
                    DeviceStatus.ApplicationPeakMemoryUsage,
                    DeviceStatus.DeviceTotalMemory
                };

            browser.InvokeScript("getMemoryUsageCallback", response.Select(c => c.ToString()).ToArray());
        }
        private void Browser_ScriptNotify(object sender, NotifyEventArgs e)
        {
            if (Debugger.IsAttached)
            {
                ScriptNotify newValue = new ScriptNotify()
                {
                    Value = e.Value,
                    Time = DateTime.Now,
                    FormattedTime = "at " + (DateTime.Now.Subtract(startTime)).TotalMilliseconds.ToString("0,000") + " milliseconds"
                };
                notifications.Add(newValue);

                DebugPanel.ScrollTo(newValue);
            }
        }
Beispiel #7
0
 private void FacebookLoginBrowser_ScriptNotify(object sender, NotifyEventArgs e)
 {
     FacebookOAuthResult authResult;
     if (FacebookOAuthResult.TryParse(e.Value, out authResult))
     {
         if (authResult.IsSuccess)
         {
             loggedIn = true;
             loginSucceeded(authResult);
         }
         else
         {
             MessageBox.Show(authResult.ErrorDescription);
         }
     }
 }
Beispiel #8
0
        private void Browser_ScriptNotify(object sender, NotifyEventArgs e)
        {
            switch (e.Value)
            {
                case "onload":
                    OnLoad();
                    break;
                case "opendialog":
                    IsDialogVisible = true;
                    break;
                case "closedialog":
                    IsDialogVisible = false;
                    break;

            }
        }
        void PART_Browser_ScriptNotify(object sender, NotifyEventArgs e)
        {
            switch (e.Value)
            {
                case "domready":
                    isDomReady = true;
                    Task.Delay(100).ContinueWith(
                        task => { this.UpdateText(this.Text); }, 
                        TaskScheduler.FromCurrentSynchronizationContext());
                    break;

                default:
                    // don't do any unnecessary binding if values are equal.
                    string text = GetValue(TextProperty) as string;
                    if (text != e.Value)
                        SetValue(TextProperty, e.Value);
                    break;
            }
        }
        private void Browser_ScriptNotify(object sender, NotifyEventArgs e)
        {
            if (e.Value.StartsWith("scrollDisabled:"))
              {
            var disabled = e.Value.Substring(15);
            _browserHelper.ScrollDisabled = disabled == "true";
              }

              if (e.Value == "hideSplashscreen")
              {
            Storyboard sb = this.Resources["SplashScreenHideAnim"] as Storyboard;
            sb.Completed += (s, e2) => splash.Visibility = Visibility.Collapsed;
            sb.Begin();
              }

              if (e.Value == "getTombstoneState" && App.Current.TombstoneState != null)
              {
            phoneGapView.Browser.InvokeScript("restoreTombstoneState", new string[] { App.Current.TombstoneState });
              }
        }
 // Step 1: Catch Javascript signal
 private void Catch_Script_Notification(object sender, NotifyEventArgs e)
 {
     if (e.Value.StartsWith("LaunchPhotoChooser"))
     {
         // Step 2: Launch the PhotoChooser
         _photoChooser = new PhotoChooserTask();
         _photoChooser.Completed += _photoChooser_Completed;
         // allow the user to either choose a saved image or take a new one
         _photoChooser.ShowCamera = true;
         _photoChooser.PixelHeight = 260;
         _photoChooser.PixelWidth = 200;
         _photoChooser.Show();
     }
     else
     {
         // used for debuggin
         TextBlock alertBox = new TextBlock();
         alertBox.Text = e.Value;
         notifyAlert.Children.Add(alertBox);
     }
 }
        private void FromJS(object sender, NotifyEventArgs e)
        {
            var opcode = e.Value.Substring(0, 1);

            if (opcode == "s") {
                Debugger.Log(1, "FromJS", "saving\r\n");
                var data = e.Value.Substring(1);
                settings["data"] = data;
            }
            else if (opcode == "l")
            {
                Debugger.Log(1, "FromJS", "loading\r\n");
                string data = settings["data"].ToString();
                Browser.InvokeScript("preload", new string[] { data });
            }
            else
            {
                // Sent for debugging purposes only
                Debugger.Log(1, "FromJS", e.Value + "\r\n");
            }
        }
        private void Browser_ScriptNotify(object sender, NotifyEventArgs e)
        {
            string fileName = "01_Susies_dnc_09-05-12.mp3";
            var resource = Application.GetResourceStream(new Uri(@"media/" + fileName, UriKind.Relative));
            IsolatedStorageFileStream fileStream = IsolatedStorageFile.GetUserStoreForApplication().CreateFile(fileName);
            resource.Stream.CopyTo(fileStream, 4096);
            resource.Stream.Close();
            fileStream.Close();

            Uri fileUri = new Uri(fileName, UriKind.RelativeOrAbsolute);
            var ml = new MediaLibrary();

            try
            {
                MediaLibraryExtensions.SaveSong(ml, fileUri, null, SaveSongOperation.CopyToLibrary);
            }
            catch (Exception ex)
            {
                string errorMessage = ex.Message.ToString();
            }
        }
        void ArticleView_ScriptNotify(object sender, NotifyEventArgs e)
        {
            // split 
            var parts = e.Value.Split('=');
            if (parts.Length != 2)
            {
                return;
            }

            // parse
            int number = 0;
            if (!int.TryParse(parts[1], out number))
            {
                return;
            }

            // decide what to do
            if (parts[0] == "scrollHeight")
            {
                _scrollHeight = number;
                if (_visibleHeight > 0)
                {
                    DisplayScrollBar.Maximum = _scrollHeight - _visibleHeight;
                }
            }
            else if (parts[0] == "clientHeight")
            {
                _visibleHeight = number;
                if (_scrollHeight > 0)
                {
                    DisplayScrollBar.Maximum = _scrollHeight - _visibleHeight;
                }
            }
            else if (parts[0] == "scrollTop")
            {
                DisplayScrollBar.Value = number;
            }
        }
 /// <summary>
 /// Handles calls to window.external.Notify from within the web browser control. We'll hijack this for message passing from browser back into C#.
 /// TODO: Processing the instruction could be blocking....... bleh
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void browser_ScriptNotify(object sender, NotifyEventArgs e)
 {
     // Process instruction into a command + parameters (if specified).
     string command = "";
     string[] commandParams;
     int colPos = e.Value.IndexOf(':');
     if (colPos > 0)
     {
         command = e.Value.Substring(0, colPos);
         commandParams = e.Value.Substring(colPos).Split('/');
     }
     else
     {
         command = e.Value;
         commandParams = new string[0];
     }
     // Send command + params to the command manager and get the return value.
     string returnValue = manager.processInstruction(command, commandParams);
     if (returnValue != null && returnValue.Length > 0)
     {
         browser.InvokeScript("gap.evaluate", returnValue);
     }
 }
        /*
         *  This method does the work of routing commands
         *  NotifyEventArgs.Value contains a string passed from JS
         *  If the command already exists in our map, we will just attempt to call the method(action) specified, and pass the args along
         *  Otherwise, we create a new instance of the command, add it to the map, and call it ...
         *  This method may also receive JS error messages caught by window.onerror, in any case where the commandStr does not appear to be a valid command
         *  it is simply output to the debugger output, and the method returns.
         *
         **/
        void CordovaBrowser_ScriptNotify(object sender, NotifyEventArgs e)
        {
            string commandStr = e.Value;

            string commandName = commandStr.Split('/').FirstOrDefault();

            if (browserDecorators.ContainsKey(commandName))
            {
                browserDecorators[commandName].HandleCommand(commandStr);
                return;
            }

            CordovaCommandCall commandCallParams = CordovaCommandCall.Parse(commandStr);

            if (commandCallParams == null)
            {
                // ERROR
                Debug.WriteLine("ScriptNotify :: " + commandStr);
            }
            else if (commandCallParams.Service == "CoreEvents")
            {
                switch (commandCallParams.Action.ToLower())
                {
                    case "overridebackbutton":
                        string arg0 = JsonHelper.Deserialize<string[]>(commandCallParams.Args)[0];
                        this.OverrideBackButton = (arg0 != null && arg0.Length > 0 && arg0.ToLower() == "true");
                        break;
                    case "__exitapp":
                        Debug.WriteLine("Received exitApp command from javascript, app will now exit.");
                        CordovaBrowser.InvokeScript("eval", new string[] { "cordova.fireDocumentEvent('pause');" });
                        CordovaBrowser.InvokeScript("eval", new string[] { "setTimeout(function(){ cordova.fireDocumentEvent('exit'); cordova.exec(null,null,'CoreEvents','__finalexit',[]); },0);" });
                        break;
                    case "__finalexit":
                        IsExiting = true;
                        // hide the browser to prevent white flashes, since about:blank seems to always be white
                        CordovaBrowser.Opacity = 0d; 
                        CordovaBrowser.Navigate(new Uri("about:blank", UriKind.Absolute));
                        break;
                }
            }
            else
            {
                if (configHandler.IsPluginAllowed(commandCallParams.Service))
                {
                    commandCallParams.Namespace = configHandler.GetNamespaceForCommand(commandCallParams.Service);
                    nativeExecution.ProcessCommand(commandCallParams);
                }
                else
                {
                    Debug.WriteLine("Error::Plugin not allowed in config.xml. " + commandCallParams.Service);
                }
            }
        }
Beispiel #17
0
        /*
         *  This method does the work of routing commands
         *  NotifyEventArgs.Value contains a string passed from JS
         *  If the command already exists in our map, we will just attempt to call the method(action) specified, and pass the args along
         *  Otherwise, we create a new instance of the command, add it to the map, and call it ...
         *  This method may also receive JS error messages caught by window.onerror, in any case where the commandStr does not appear to be a valid command
         *  it is simply output to the debugger output, and the method returns.
         *
         **/
        void GapBrowser_ScriptNotify(object sender, NotifyEventArgs e)
        {
            string commandStr = e.Value;

            if (commandStr.IndexOf("DOMStorage") == 0)
            {
                this.domStorageHelper.HandleStorageCommand(commandStr);
                return;
            }
            else if (commandStr.IndexOf("Orientation") == 0)
            {
                this.orientationHelper.HandleCommand(commandStr);
                return;
            }

            CordovaCommandCall commandCallParams = CordovaCommandCall.Parse(commandStr);

            if (commandCallParams == null)
            {
                // ERROR
                Debug.WriteLine("ScriptNotify :: " + commandStr);
            }
            else if (commandCallParams.Service == "CoreEvents")
            {
                switch (commandCallParams.Action.ToLower())
                {
                    case "overridebackbutton":
                        string arg0 = JsonHelper.Deserialize<string[]>(commandCallParams.Args)[0];
                        this.OverrideBackButton = (arg0 != null && arg0.Length > 0 && arg0.ToLower() == "true");
                        break;
                }
            }
            else
            {
                if (configHandler.IsPluginAllowed(commandCallParams.Service))
                {
                    nativeExecution.ProcessCommand(commandCallParams);
                }
                else
                {
                    Debug.WriteLine("Error::Plugin not allowed in config.xml. " + commandCallParams.Service);
                }
            }
        }
Beispiel #18
0
        /*
         *  This method does the work of routing commands
         *  NotifyEventArgs.Value contains a string passed from JS
         *  If the command already exists in our map, we will just attempt to call the method(action) specified, and pass the args along
         *  Otherwise, we create a new instance of the command, add it to the map, and call it ...
         *  This method may also receive JS error messages caught by window.onerror, in any case where the commandStr does not appear to be a valid command
         *  it is simply output to the debugger output, and the method returns.
         *
         **/
        void GapBrowser_ScriptNotify(object sender, NotifyEventArgs e)
        {
            string commandStr = e.Value;
            string commandName = commandStr.Split('/').FirstOrDefault();

            if (browserDecorators.ContainsKey(commandName))
            {
                browserDecorators[commandName].HandleCommand(commandStr);
                return;
            }

            CordovaCommandCall commandCallParams = CordovaCommandCall.Parse(commandStr);

            if (commandCallParams == null)
            {
                // ERROR
                Debug.WriteLine("ScriptNotify :: " + commandStr);
            }
            else if (commandCallParams.Service == "CoreEvents")
            {
                switch (commandCallParams.Action.ToLower())
                {
                    case "overridebackbutton":
                        string arg0 = JsonHelper.Deserialize<string[]>(commandCallParams.Args)[0];
                        this.OverrideBackButton = (arg0 != null && arg0.Length > 0 && arg0.ToLower() == "true");
                        break;
                }
            }
            else
            {
                if (configHandler.IsPluginAllowed(commandCallParams.Service))
                {
                    nativeExecution.ProcessCommand(commandCallParams);
                }
                else
                {
                    Debug.WriteLine("Error::Plugin not allowed in config.xml. " + commandCallParams.Service);
                }
            }
        }
Beispiel #19
0
        /*
         *  This method does the work of routing commands
         *  NotifyEventArgs.Value contains a string passed from JS
         *  If the command already exists in our map, we will just attempt to call the method(action) specified, and pass the args along
         *  Otherwise, we create a new instance of the command, add it to the map, and call it ...
         *  This method may also receive JS error messages caught by window.onerror, in any case where the commandStr does not appear to be a valid command
         *  it is simply output to the debugger output, and the method returns.
         *
         **/
        void GapBrowser_ScriptNotify(object sender, NotifyEventArgs e)
        {
            string commandStr = e.Value;

            Debug.WriteLine("Command::" + commandStr);

            // DOMStorage/Local OR DOMStorage/Session
            if (commandStr.IndexOf("DOMStorage") == 0)
            {
                this.domStorageHelper.HandleStorageCommand(commandStr);
                return;
            }
            else if (commandStr.IndexOf("Orientation") == 0)
            {
                this.orientationHelper.HandleCommand(commandStr);
                return;
            }

            PhoneGapCommandCall commandCallParams = PhoneGapCommandCall.Parse(commandStr);

            if (commandCallParams == null)
            {
                // ERROR
                Debug.WriteLine("ScriptNotify :: " + commandStr);
                return;
            }
            else if (commandCallParams.Service == "CoreEvents")
            {
                switch (commandCallParams.Action.ToLower())
                {
                    case "overridebackbutton":
                        string[] args = PhoneGap.JSON.JsonHelper.Deserialize<string[]>(commandCallParams.Args);
                        this.OverrideBackButton = (args != null && args.Length > 0 && args[0] == "true");
                        break;
                }
                return;
            }

            this.nativeExecution.ProcessCommand(commandCallParams);
        }
Beispiel #20
0
        // **********************************************************************
        // JavaScript communicating with C#
        // **********************************************************************

        private async void Browser_ScriptNotify(object sender, NotifyEventArgs e)
        {


            // Get a comma delimited string from js and convert to array
            string valueStr = e.Value;
            string[] valueArr = valueStr.Split(',');

            // Trim and convert empty strings to null
            for (int i = 0; i < valueArr.Length; i++)
            {
                valueArr[i] = valueArr[i].Trim();
                if (string.IsNullOrWhiteSpace(valueArr[i]))
                    valueArr[i] = null;
            }

            // Activate trial mode
            if (valueArr[0] == "checkLicense")
            {

                // Check if trial
                if (valueArr[1] == "true")
                {
                    C2SettingIsTrial = true;
                }
                CheckLicense();
            }

            // Game loaded
            if (valueArr[0] == "gameLoaded")
            {
                Browser.Visibility = System.Windows.Visibility.Visible;

                checkMusic();

                if (App.WasTombstoned)
                {
                    Browser.InvokeScript("eval", "window['tombstoned'] = true");
                    App.WasTombstoned = false;
                }
            }

            // Stop music
            if (valueArr[0] == "stopMusic")
            {
                if (MediaPlayer.GameHasControl)
                {
                    FrameworkDispatcher.Update();
                    MediaPlayer.Stop();
                }
            }

            // Play music
            if (valueArr[0] == "playMusic")
            {
                if (MediaPlayer.GameHasControl)
                {
                    var file = valueArr[1];
                    var loop = valueArr[2] == "0" ? false : true;

                    var db = Single.Parse(valueArr[3], CultureInfo.InvariantCulture);
                    var volume = Convert.ToSingle(dbToScale(db));

                    var uri = new Uri(file, UriKind.Relative);
                    var song = Song.FromUri(file, uri);
                    MediaPlayer.IsRepeating = loop;
                    MediaPlayer.Volume = volume;
                    FrameworkDispatcher.Update();
                    MediaPlayer.Stop();
                    MediaPlayer.Play(song);
                }
            }

            // Stop music
            if (valueArr[0] == "stopMusic")
            {
                if (MediaPlayer.GameHasControl)
                {
                    FrameworkDispatcher.Update();
                    MediaPlayer.Stop();
                }
            }

            // Play sound
            if (valueArr[0] == "playSound")
            {

                var file = valueArr[1];
                var loop = valueArr[2] == "0" ? false : true;

                var db = Single.Parse(valueArr[3], CultureInfo.InvariantCulture);
                var volume = Convert.ToSingle(dbToScale(db));

                var tag = valueArr[4];

                Stream stream = TitleContainer.OpenStream(file);
                SoundEffect effect = SoundEffect.FromStream(stream);

                sound = effect.CreateInstance();
                sound.IsLooped = loop;
                sound.Volume = volume;

                if (!string.IsNullOrEmpty(tag))
                {
                    if (SoundList.ContainsKey(tag))
                    {
                        SoundList[tag].Stop();
                    }
                    SoundList[tag] = sound;
                }

                FrameworkDispatcher.Update();
                sound.Play();

            }

            // Stop sound
            if (valueArr[0] == "stopSound")
            {
                var tag = valueArr[1];
                if (SoundList.ContainsKey(tag))
                {
                    FrameworkDispatcher.Update();
                    SoundList[tag].Stop();
                }
            }

            // Vibrate
            if (valueArr[0] == "vibrate")
            {
                float seconds = float.Parse(valueArr[1], CultureInfo.InvariantCulture);
                VibrateController vibrate = VibrateController.Default;
                vibrate.Start(TimeSpan.FromSeconds(seconds));
            }

            // Quit app
            if (valueArr[0] == "quitApp")
            {
                App.Current.Terminate();
            }

            // Live Tiles (http://tinyurl.com/afvhgz8)
            // *******************************************************

            // Flipped Tile
            if (valueArr[0] == "flippedTileUpdate")
            {
                ShellTile myTile = ShellTile.ActiveTiles.First();
                if (myTile != null)
                {
                    var smallBackgroundImage = valueArr[6] == null ? null : new Uri(valueArr[6], UriKind.Relative);
                    var backgroundImage = valueArr[7] == null ? null : new Uri(valueArr[7], UriKind.Relative);
                    var backBackgroundImage = valueArr[8] == null ? null : new Uri(valueArr[8], UriKind.Relative);
                    var wideBackgroundImage = valueArr[9] == null ? null : new Uri(valueArr[9], UriKind.Relative);
                    var wideBackBackgroundImage = valueArr[10] == null ? null : new Uri(valueArr[10], UriKind.Relative);

                    FlipTileData newTileData = new FlipTileData
                    {
                        Title = valueArr[1],
                        BackTitle = valueArr[2],
                        BackContent = valueArr[3],
                        WideBackContent = valueArr[4],
                        Count = Convert.ToInt32(valueArr[5]),
                        SmallBackgroundImage = smallBackgroundImage,
                        BackgroundImage = backgroundImage,
                        BackBackgroundImage = backBackgroundImage,
                        WideBackgroundImage = wideBackgroundImage,
                        WideBackBackgroundImage = wideBackBackgroundImage
                    };
                    myTile.Update(newTileData);
                }
            }

            // Payments

            // Purchase app
            if (valueArr[0] == "purchaseApp")
            {
                MarketplaceDetailTask _marketPlaceDetailTask = new MarketplaceDetailTask();
                _marketPlaceDetailTask.Show();
            }

            // Purchase product
            if (valueArr[0] == "purchaseProduct")
            {
                string productID = valueArr[1];

                if (!CurrentApp.LicenseInformation.ProductLicenses[productID].IsActive)
                {
                    try
                    {
                        var receipt = await CurrentApp.RequestProductPurchaseAsync(productID, true);
                        if (CurrentApp.LicenseInformation.ProductLicenses[productID].IsActive)
                        {
                            Browser.InvokeScript("eval", "window['wp_call_IAPPurchaseSuccess']('" + productID + "');");
                        }
                    }
                    catch
                    {
                        // The in-app purchase was not completed because the
                        // customer canceled it or an error occurred.
                        Browser.InvokeScript("eval", "window['wp_call_IAPPurchaseFail']();");
                    }
                }
                else
                {
                    //Already owns the product
                }
            }

            // Request store listing
            if (valueArr[0] == "requestStoreListing")
            {
                try
                {

                    li = await Store.CurrentApp.LoadListingInformationAsync();

                    foreach (string key in li.ProductListings.Keys)
                    {
                        ProductListing pListing = li.ProductListings[key];

                        productItems[pListing.ProductId] = new ProductItem
                        {
                            Name = pListing.Name,
                            Description = pListing.Description,
                            FormattedPrice = pListing.FormattedPrice,
                            Tag = pListing.Tag,
                            Purchased = CurrentApp.LicenseInformation.ProductLicenses[key].IsActive ? "True" : "False"
                        };
                    }

                    storeListingRecieved();
                }
                catch (Exception)
                {
                    // Failed to load listing information
                }
            }

            // Rate App
            if (valueArr[0] == "rateApp")
            {
                MarketplaceReviewTask marketplaceReviewTask = new MarketplaceReviewTask();
                marketplaceReviewTask.Show();
            }

        }
 private void Logger(object sender, NotifyEventArgs e)
 {
     //Logging statements from javascript
     System.Diagnostics.Debug.WriteLine(e.Value);
 }
Beispiel #22
0
 private void BrowserScriptNotify(object sender, NotifyEventArgs e)
 {
     this.native.ProcessJavascriptCommand(e.Value);
 }
        /*
         *  This method does the work of routing commands
         *  NotifyEventArgs.Value contains a string passed from JS
         *  If the command already exists in our map, we will just attempt to call the method(action) specified, and pass the args along
         *  Otherwise, we create a new instance of the command, add it to the map, and call it ...
         *  This method may also receive JS error messages caught by window.onerror, in any case where the commandStr does not appear to be a valid command
         *  it is simply output to the debugger output, and the method returns.
         *
         **/
        void GapBrowser_ScriptNotify(object sender, NotifyEventArgs e)
        {
            string commandStr = e.Value;

            if (commandStr.IndexOf("DOMStorage") == 0)
            {
                this.domStorageHelper.HandleStorageCommand(commandStr);
                return;
            }
            else if (commandStr.IndexOf("Orientation") == 0)
            {
                this.orientationHelper.HandleCommand(commandStr);
                return;
            }

            CordovaCommandCall commandCallParams = CordovaCommandCall.Parse(commandStr);

            if (commandCallParams == null)
            {
                // ERROR
                Debug.WriteLine("ScriptNotify :: " + commandStr);
            }
            else if (commandCallParams.Service == "CoreEvents")
            {
                switch (commandCallParams.Action.ToLower())
                {
                    case "overridebackbutton":
                        string args = commandCallParams.Args;
                        this.OverrideBackButton = (args != null && args.Length > 0 && args.ToLower() == "true");
                        break;
                }
            }
            else
            {
                this.nativeExecution.ProcessCommand(commandCallParams);
            }
        }
Beispiel #24
0
 void webBrowser1_ScriptNotify(object sender, NotifyEventArgs e)
 {
     if (e.Value.ToLower().StartsWith("hybrid://")) {
         string actionUri = e.Value.Substring(9);
         CallNativeMethod(actionUri);
     }
 }
        private void Browser_ScriptNotify(object sender, NotifyEventArgs e)
        {
            // if a page notifies that it should not be scrollable, disable
            // scrolling.
            string commandStr = e.Value;

            if(commandStr == "noScroll")
            {
                _browserHelper.ScrollDisabled = true;
            }
            else if(commandStr == "phoneTaskEmail")
            {
                EmailComposeTask emailComposeTask = new EmailComposeTask();

                emailComposeTask.Subject = "Regarding sg.promotions";
                emailComposeTask.Body = "";
                emailComposeTask.To = "*****@*****.**";
                emailComposeTask.Cc = "";
                emailComposeTask.Bcc = "";

                emailComposeTask.Show();
            }
            else if (commandStr == "phoneTaskRate")
            {
                MarketplaceReviewTask marketplaceReviewTask = new MarketplaceReviewTask();

                marketplaceReviewTask.Show();
            }
            else if (commandStr.StartsWith(browserTaskCommand))
            {
                string url = commandStr.Substring(browserTaskCommand.Length);

                WebBrowserTask webBrowserTask = new WebBrowserTask();
                webBrowserTask.Uri = new Uri(url, UriKind.Absolute);
                webBrowserTask.Show();
            }
            //else if (commandStr == "phoneTaskWebsite")
            //{
            //    WebBrowserTask webBrowserTask = new WebBrowserTask();

            //    webBrowserTask.Uri = new Uri("http://www.kaosfoundry.com", UriKind.Absolute);

            //    webBrowserTask.Show();
            //}
            //else if(commandStr == "phoneTaskTwitter")
            //{
            //    WebBrowserTask webBrowserTask = new WebBrowserTask();

            //    webBrowserTask.Uri = new Uri("http://twitter.com/kelltainer", UriKind.Absolute);

            //    webBrowserTask.Show();
            //}

            // <button onclick="window.external.Notify('clearTextBox');">clear textbox</button> <- can do real shit here.
            // app bar code
        }
Beispiel #26
0
 private void Browser_ScriptNotify(object sender, NotifyEventArgs e)
 {
     String value = e.Value;
     MessageBox.Show(value);
 }
 private void PageSource_ScriptNotify(object sender, NotifyEventArgs e)
 {
     cct.Show();
 }
        private void SignInWebBrowserControl_ScriptNotify(object sender, NotifyEventArgs e)
        {
            BrowserSigninControl.ScriptNotify -= this.SignInWebBrowserControl_ScriptNotify;

            RequestSecurityTokenResponse rstr = null;
            Exception exception = null;
            try
            {
                ShowProgressBar("Signing In");

                rstr = RequestSecurityTokenResponse.FromJSON(e.Value);

                if (null == rstr)
                {
                    DisplayErrorMessage("Failed reading RSTR");
                    exception = new InvalidOperationException("Failed to get a valid RequestSecurityTokenResponse");
                }

                if (null != _rstrStore)
                {
                    _rstrStore.RequestSecurityTokenResponse = rstr;
                }
            }
            catch (Exception ex)
            {
                DisplayErrorMessageFromException(ex);
                exception = ex;
            }

            if (null != RequestSecurityTokenResponseCompleted)
            {
                RequestSecurityTokenResponseCompleted(this, new RequestSecurityTokenResponseCompletedEventArgs(rstr, exception));
            }
        }
Beispiel #29
0
 //Here, all general messages go
 public virtual void ScriptNotify(object sender, NotifyEventArgs e)
 {
     string msg = e.Value;
     string[] msgParts = msg.Split('|');
     string method = msgParts[0];
     if (JavascriptParser.isMapReady(method))
     {
         handleMapReady();
     }            
 }
        private void SignInWebBrowserControlScriptNotify(object sender, NotifyEventArgs e)
        {
            this.BrowserSigninControl.ScriptNotify -= this.SignInWebBrowserControlScriptNotify;

            RequestSimpleWebTokenResponse rswt = null;
            Exception exception = null;
            try
            {
                this.ShowProgressBar(Resource.SigningInMessage);

                rswt = RequestSimpleWebTokenResponse.FromJson(e.Value);

                if (null == rswt)
                {
                    DisplayErrorMessage(Resource.FailedReadingRSTRMessage);
                    exception = new InvalidOperationException("Failed to get a valid RequestSimpleWebTokenResponse");
                }
                else
                {
                    var simpleWebToken = new SimpleWebToken(rswt.SecurityToken);
                    if (null != this.SimpleWebTokenStore)
                    {
                        this.SimpleWebTokenStore.SimpleWebToken = simpleWebToken;
                    }
                }
            }
            catch (Exception ex)
            {
                DisplayErrorMessageFromException(ex);
                exception = ex;
            }

            if (null != this.RequestSimpleWebTokenResponseCompleted)
            {
                this.RequestSimpleWebTokenResponseCompleted(this, new RequestSimpleWebTokenResponseCompletedEventArgs(rswt, exception));
            }
        }