コード例 #1
0
        public void loadPage()
        {
            var pageToLoad = WikiPage_TextBox.get_Text();

            WikiTextEditor.backColor(Color.LightPink);
            StatusLabel.set_Text("Opening page: {0}".format(pageToLoad)).textColor(Color.Black);
            CurrentPageUrl.insert_Item("{0}/{1}".format(WikiApi.IndexPhp, pageToLoad));
            O2Thread.mtaThread(() =>
            {
                var wikiText = WikiApi.wikiText(pageToLoad);
                WikiTextEditor.set_Text(wikiText);
                if (wikiText.valid().isFalse())
                {
                    StatusLabel.set_Text("This is a new Page (there was no content retrived from the server").textColor(Color.DarkBlue);
                }
                BrowserPreview.open("about:blank");
                BrowserCurrent.open("about:blank");
                WikiTextEditor.backColor(Color.White);
                //BrowserPreview.set_Text(WikiApi.parseText(wikiText,true));
                //BrowserCurrent.set_Text(WikiApi.html(pageToLoad));
            });
        }
コード例 #2
0
        public void saveCurrentPage()
        {
            var currentPage = WikiPage_TextBox.get_Text();

            if (WikiApi.loggedIn().isFalse())
            {
                StatusLabel.set_Text("You need to be logged in to save pages").textColor(Color.Red);
                var credential = ascx_AskUserForLoginDetails.ask();
                if (credential.notNull())
                {
                    WikiApi.login(credential.UserName, credential.Password);
                    if (WikiApi.loggedIn())
                    {
                        StatusLabel.set_Text("You are now logged in as user: {0}".format(credential.UserName)).textColor(Color.DarkGreen);
                    }
                    else
                    {
                        StatusLabel.set_Text("Login failed for user: {0}".format(credential.UserName)).textColor(Color.Red);
                    }
                }
            }
            else
            {
                StatusLabel.set_Text("saving page {0} ".format(currentPage)).textColor(Color.Black);

                // save content
                WikiApi.save(currentPage, WikiTextEditor.get_Text());

                // reload content and show it
                var wikiText = WikiApi.wikiText(currentPage);
                BrowserPreview.open("about:blank");
                //BrowserPreview.set_Text(WikiApi.parseText(wikiText,true));
                BrowserCurrent.set_Text(WikiApi.html(currentPage));
                StatusLabel.set_Text("Page {0} saved".format(currentPage)).textColor(Color.DarkGreen);
            }
        }