static public void SetRadegastLoginForm(RadegastInstance instance, LoginConsole console, LoginOptions options) { // var instance = TheRadegastInstance; if (console.IsDisposed) { return; } console.cbxUsername.Text = (String.Format("{0} {1}", options.FirstName, options.LastName)).Trim(); switch (options.StartLocation) { case StartLocationType.Last: //console.cbxLocation.Text = options.StartLocationCustom = "last"; console.cbxLocation.SelectedIndex = 1; break; case StartLocationType.Home: //console.cbxLocation.Text = options.StartLocationCustom = "home"; console.cbxLocation.SelectedIndex = 0; break; default: console.cbxLocation.SelectedIndex = -1; console.cbxLocation.Text = options.StartLocationCustom; break; } console.cbTOS.Checked = true; var G = options.Grid; string gridName = options.GridCustomLoginUri; int gridIx = -1; String LoginURI = null; G = GetGridIndex(instance, gridName, out gridIx) ?? G; if (gridIx == -1) { if (G != null && !String.IsNullOrEmpty(G.ID)) { LoginURI = G.LoginURI; if (LoginURI != null) { console.txtCustomLoginUri.Text = LoginURI; } console.cbxGrid.Text = G.Name ?? G.ID; instance.Netcom.LoginOptions.Grid = G; } else { console.cbxGrid.Text = "Custom"; } if (LoginURI == null) { console.txtCustomLoginUri.Text = options.GridCustomLoginUri; } } else { console.txtCustomLoginUri.Text = G.LoginURI; console.cbxGrid.SelectedIndex = gridIx; } }
static public void SetRadegastLoginOptionsFromCogbot(RadegastInstance instance, BotClient TheBot) { if (instance == null) { return; } var BotLoginParams = TheBot.BotLoginParams; EnsureRadegastForm(TheBot, instance, "EnsureRadegastForm from SetRadegastLoginOptions " + TheBot.GetName()); var to = instance.Netcom.LoginOptions; to.FirstName = BotLoginParams.FirstName; to.LastName = BotLoginParams.LastName; to.Password = BotLoginParams.Password; string loginURI = BotLoginParams.URI; MainProgram.CommandLine.LoginUri = loginURI; MainProgram.CommandLine.Location = BotLoginParams.Start; int gidx; Grid G = GetGridIndex(instance, loginURI, out gidx); if (G == null) { G = new Grid(BotLoginParams.URI, BotLoginParams.URI, loginURI); to.GridCustomLoginUri = loginURI; } else { BotLoginParams.URI = G.LoginURI; } instance.Netcom.LoginOptions.Grid = G; to.Grid = G; string botStartAt = BotLoginParams.Start; if (botStartAt == "home") { to.StartLocation = StartLocationType.Home; } else if (botStartAt == "last") { to.StartLocation = StartLocationType.Last; } else { to.StartLocation = StartLocationType.Custom; to.StartLocationCustom = botStartAt; } to.Version = BotLoginParams.Version; to.Channel = BotLoginParams.Channel; RadegastTab tab; if (instance.TabConsole.Tabs.TryGetValue("login", out tab)) { tab.AllowDetach = true; tab.AllowClose = false; tab.AllowMerge = false; tab.AllowHide = false; LoginConsole form = (LoginConsole)tab.Control; try { if (form.IsDisposed) { return; } DLRConsole.InvokeControl((Control)instance.MainForm, (MethodInvoker)(() => SetRadegastLoginForm(instance, form, to))); } catch (Exception e) { TheBot.LogException("Set Radegast Login Form", e); } } }