Exemplo n.º 1
0
        public ManualsTab(IXappFormsTabHandler aHandler, IManualsManager aManager, AdvancedModule aAdvancedModule)
        {
            iHandler = aHandler;
            iManager = aManager;
            iAdvancedModule = aAdvancedModule;

            iMain = iHandler.CreateContainer();
            //var home = "<span id=\"xx\">Hello World!</span>";
            iMain.Add(iAdvancedModule.CreateBrowser(iHandler, iManager.GetPage, "/index.md").WithClass("md"));
            iHandler.SetRoot(iMain);
        }
Exemplo n.º 2
0
        internal AdvancedBrowser(IModuleControl aModuleControl, IXappFormsTabHandler aTabHandler, Func<string, string> aHtmlProvider, string aPath)
            : base(aModuleControl, "<div id='{0}' class='browser' />", aModuleControl.Id)
        {
            iTabHandler = aTabHandler;
            iHtmlProvider = aHtmlProvider;
            iHomePath = aPath;

            iPath = aPath;

            iHistory = new Stack<string>();
            iFuture = new Stack<string>();

            iToolbar = iTabHandler.CreateContainer().WithClass("browser-toolbar");
            iWindow = iTabHandler.CreateContainer().WithClass("browser-window");

            iBack = iTabHandler.CreateButton("Back").WithClass("browser-back");
            iForward = iTabHandler.CreateButton("Forward").WithClass("browser-forward");
            iRefresh = iTabHandler.CreateButton("Refresh").WithClass("browser-refresh");
            iHome = iTabHandler.CreateButton("Home").WithClass("browser-home");
            iSearch = iTabHandler.CreateTextbox().WithClass("browser-search");
            iGo = iTabHandler.CreateButton("Go").WithClass("browser-go");

            iBack.Disabled = true;
            iForward.Disabled = true;
            iGo.Disabled = true;

            iBack.Click += (obj, args) =>
            {
                if (iHistory.Count > 0)
                {
                    iFuture.Push(iPath);
                    iForward.Disabled = false;
                    iPath = iHistory.Pop();

                    if (iHistory.Count == 0)
                    {
                        iBack.Disabled = true;
                    }

                    Refresh();
                }
            };

            iForward.Click += (obj, args) =>
            {
                if (iFuture.Count > 0)
                {
                    iHistory.Push(iPath);
                    iBack.Disabled = false;
                    iPath = iFuture.Pop();

                    if (iFuture.Count == 0)
                    {
                        iForward.Disabled = true;
                    }

                    Refresh();
                }
            };

            iRefresh.Click += (obj, args) =>
            {
                Refresh();
            };

            iHome.Click += (obj, args) =>
            {
                if (iPath != iHomePath)
                {
                    iPath = iHomePath;
                    iHistory.Clear();
                    iFuture.Clear();
                    iBack.Disabled = true;
                    iForward.Disabled = true;
                    Refresh();
                }
            };

            iSearch.Change += (obj, args) =>
            {
                iGo.Disabled = iSearch.Text.Length == 0;
            };

            iSearch.Enter += (obj, args) =>
            {
                Search();
            };

            iGo.Click += (obj, args) =>
            {
                Search();
            };

            iToolbar.Add(iBack);
            iToolbar.Add(iForward);
            iToolbar.Add(iRefresh);
            iToolbar.Add(iHome);
            iToolbar.Add(iSearch);
            iToolbar.Add(iGo);

            ControlEval(string.Format("{0}.append({1})", iSelector, iToolbar.Id.JquerySelector()));
            ControlEval(string.Format("{0}.append({1})", iSelector, iWindow.Id.JquerySelector()));

            ControlRegisterEventHandler("link", OnLink);

            Refresh();
        }