private void buttonSave_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; var testOptions = new IntentoMTFormOptions(); testOptions.Hidden = true; var _apiKeyState = new ApiKeyState(new IntentoTranslationProviderOptionsForm(testOptions, parent.LanguagePairs, parent.fabric), _options); _apiKeyState.SetValue(apiKey_tb.Text.Trim()); _apiKeyState.ReadProvidersAndRouting(); string err = _apiKeyState.Error(); IEnumerable <string> errDetail = _apiKeyState.ErrorDetail(); this.Cursor = Cursors.Default; var nl = Environment.NewLine; if (!string.IsNullOrWhiteSpace(err)) { string errorMsg = err == Resource.InvalidApiKeyMessage ? err : Resource.APIFlabelErrorSeePopup; labelError.Text = string.Format("ERROR: {0}", errorMsg); labelError.Visible = true; if (errDetail != null) { errorInfo = ( string.Format("{0}{1}---------------------------{1}{2}", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"), nl, string.Join(nl, errDetail.ToArray()) )); toolTip1.SetToolTip(labelError, Resource.APIToolTipMessage); } } else { this.Cursor = Cursors.WaitCursor; parent.apiKeyState.SetValue(apiKey_tb.Text.Trim()); parent.apiKeyState.ReadProvidersAndRouting(); parent.apiKeyState.EnableDisable(); this.Cursor = Cursors.Default; this.DialogResult = DialogResult.OK; } }
public SmartRoutingState(ApiKeyState apiKeyState, IntentoMTFormOptions _options) : base(apiKeyState, _options) { this.apiKeyState = apiKeyState; routingTable = new Dictionary <string, string>(defaultRoutingTable); routing = _options.Routing; List <dynamic> routingList = FilterByLanguagePairs(apiKeyState.routings, form.LanguagePairs); foreach (dynamic p in routingList) { string name = (string)p.name; if (routingTable.ContainsKey(name)) { routingTable[name] = (string)p.description; } else { routingTable.Add(name, (string)p.description); } } CreateChildStates(); }