public void login() { LoggedInStatus_Label.set_Text("trying to login to: {0}".format(MediaWikiUrl_TextBox.get_Text())) .textColor(Color.Black); var username = UserName_TextBox.get_Text(); var password = Password_TextBox.get_Text(); WikiApi.login(username, password).isFalse(); if (WikiApi.loggedIn()) { LoggedInStatus_Label.set_Text("Logged in as user: {0}".format(username)) .textColor(Color.Green); } else { LoggedInStatus_Label.set_Text("Login failed for user {0}".format(username)) .textColor(Color.Red); } SetWikiApi(WikiApi); }
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); } }