public LuaForm()
        {
            LuaEngine luaEngine = LuaEngine.Instance;

            if (FirstInit)
            {
                mainPage   = true;
                luaContext = LuaContext.CreateLuaContext(this);
                luaEngine.Startup();
                luaId = luaEngine.GetMainForm();
                String initUI = luaEngine.GetMainUI();
                if (initUI != "")
                {
                    LuaViewInflator inflater = new LuaViewInflator(luaContext);
                    this.view = inflater.ParseFile(initUI, null);
                    Content   = view.GetView();
                }
                else
                {
                    luaEngine.OnGuiEvent(this, LuaEngine.GuiEvents.GUI_EVENT_CREATE, luaContext);
                }
            }
            else
            {
                luaContext = ContextQueue.Dequeue();
            }
        }
        public void SetViewXML(String xml)
        {
            LuaViewInflator inflater = new LuaViewInflator(luaContext);

            view    = inflater.ParseFile(xml, null);
            Content = view.GetView();
        }
        public FormPivotItem(LuaForm form, String ui)
        {
            this.form = form;
            LuaViewInflator lvi = new LuaViewInflator(form.GetContext());

            view = lvi.ParseFile(ui, null);
            this.form.Content = view.GetView();
        }
        /// <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);
        }
 public FormPivotItem(LuaForm form, LGView ui)
 {
     this.form         = form;
     this.view         = ui;
     this.form.Content = ui.GetView();
 }