public static void CreateWithUI(LuaContext lc, String luaId, String ui)
 {
     LuaForm.ContextQueue.Enqueue(lc);
     System.Windows.Dispatcher.BeginInvoke(() =>
     {
         LuaInternalParameter lip = new LuaInternalParameter();
         lip["luaid"]             = luaId;
         lip["ui"] = ui;
         LuaForm.navService.Frame.Navigate(typeof(LuaForm), lip);
     });
 }
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            LuaForm.navService = this;
            LuaForm.activeForm = this;
            if (FirstInit)
            {
                FirstInit = false;
            }
            else if (!mainPage)
            {
                LuaInternalParameter lip = (LuaInternalParameter)e.Parameter;
                luaId = lip["luaId"];
                String initUI = lip["ui"];
                if (initUI != "")
                {
                    LuaViewInflator inflater = new LuaViewInflator(luaContext);
                    this.view = inflater.ParseFile(initUI, null);
                    Content   = view.GetView();
                }
                else
                {
                    LuaEngine.Instance.OnGuiEvent(this, LuaEngine.GuiEvents.GUI_EVENT_CREATE, luaContext);
                }
            }
#if WP8
            proximityDevice = ProximityDevice.GetDefault();
            if (proximityDevice != null)
            {
                nfcSubsId = proximityDevice.SubscribeForMessage("NDEF", (device, message) =>
                {
                    Logger.Log(LogType.CONSOLE, LogLevel.ERROR, "**** Subs Ndef ****");
                    // Parse raw byte array to NDEF message
                    byte[] rawMsg           = message.Data.ToArray();
                    NdefMessage ndefMessage = NdefMessage.FromByteArray(rawMsg);

                    Dictionary <Int32, Dictionary <String, String> > nfcData = new Dictionary <Int32, Dictionary <String, String> >();
                    int count = 0;
                    foreach (NdefRecord record in ndefMessage)
                    {
                        Dictionary <String, String> recordDict = new Dictionary <String, String>();
                        Type recordType = record.CheckSpecializedType(false);
                        if (recordType == typeof(NdefUriRecord))
                        {
                            NdefUriRecord uriRecord = new NdefUriRecord(record);
                            recordDict.Add("type", "uri");
                            recordDict.Add("uri", uriRecord.Uri);
                            nfcData.Add(count++, recordDict);
                        }
                        else if (recordType == typeof(NdefSmartUriRecord))
                        {
                            NdefSmartUriRecord sUriRecord = new NdefSmartUriRecord(record);
                            recordDict.Add("type", "spr");
                            recordDict.Add("title", sUriRecord.Titles[0].Text);
                            recordDict.Add("uri", sUriRecord.Uri);
                        }
                    }
                    LuaEngine.Instance.OnGuiEvent(this, LuaEngine.GuiEvents.GUI_EVENT_NFC, luaContext, nfcData);
                });
            }
#endif
            LuaEngine.Instance.OnGuiEvent(this, LuaEngine.GuiEvents.GUI_EVENT_RESUME, luaContext);
        }