Beispiel #1
0
        public ascx_MediaWiki_ConfigAndLogin buildGui(O2MediaWikiAPI wikiApi, Action <O2MediaWikiAPI> setWikiApi)
        {
            WikiApi    = wikiApi;
            SetWikiApi = setWikiApi;
            var controls           = this.add_1x1("Config", "Login Details", false);
            var config_Panel       = controls[0];
            var loginDetails_Panel = controls[1];

            //config_Panel
            TargetMediaWiki_ComboBox = config_Panel.add_Label("Target MediaWiki website", 12, 10)
                                       .append_Control <ComboBox>()
                                       .dropDownList()
                                       .onSelection <string>(loadMediaWikiDetails);

            MediaWikiUrl_TextBox = config_Panel.add_Label("MediaWiki Url:            ", 40, 10)
                                   .append_TextBox("");

            MediaWiki_API_php_TextBox = config_Panel.add_Label("MediaWiki api.php:     ", 60, 10)
                                        .append_TextBox("");
            MediaWiki_Index_php_TextBox = config_Panel.add_Label("MediaWiki index.php: ", 80, 10)
                                          .append_TextBox("");

            MediaWikiUrlCheck_Label = config_Panel.add_Link("Check MediaWiki Urls", 110, 128, checkMediaWikiUrls)
                                      .append_Label("")
                                      .autoSize();

            MediaWikiUrl_TextBox.align_Right(config_Panel).leftAdd(2).widthAdd(-7);
            MediaWiki_API_php_TextBox.align_Right(config_Panel).widthAdd(-5);
            MediaWiki_Index_php_TextBox.align_Right(config_Panel).widthAdd(-5);

            //loginDetails_Panel
            loginDetails_Panel.add_Label("A) Login using local config file:", 20, 10);
            SecretsFile_TextBox = loginDetails_Panel.add_TextBox(40, 102, false)
                                  .set_Text(defaultSecretsFolder.pathCombine(defaultSecretsFile))
                                  .onEnter(loadCredentials);


            Credential_ComboBox = loginDetails_Panel.add_ComboBox(60, 102).width(220).sorted();

            Credential_ComboBox.onSelection <ICredential>(loadCredentialDetails);
            loginDetails_Panel.add_Label("B) Login using username & password: "******"Username:"******"");
            Password_TextBox = loginDetails_Panel.add_Label("Password: "******"")
                               .isPasswordField();

            SecretsFile_TextBox.align_Right(loginDetails_Panel).widthAdd(-40);

            SecretsFile_TextBox.append_Control <Button>()
            .set_Text("...")
            .width(30)
            .heightAdd(-2)
            .anchor_TopRight()
            .onClick(() => {
                var file = this.askUserForFileToOpen(defaultSecretsFolder, "Xml Files | *.xml");
                if (file.valid())
                {
                    SecretsFile_TextBox.set_Text(file);
                    loadCredentials(file);
                }
            });;

            UserName_TextBox.width(200);
            Password_TextBox.width(200);

            LoggedInStatus_Label = Password_TextBox.append_Link("Login", login)
                                   .topAdd(5)
                                   .append_Label("")
                                   .autoSize();

            loadCredentials(SecretsFile_TextBox.get_Text());

            loadDefaultMediaWikiEngines();

            return(this);
        }