Esempio n. 1
0
        public ProviderState(SmartRoutingState smartRoutingState, IntentoMTFormOptions options) : base(smartRoutingState, options)
        {
            this.smartRoutingState = smartRoutingState;

            Init();

            languagePairs       = form.LanguagePairs;
            currentProviderId   = options.ProviderId;
            currentProviderName = options.ProviderName;

            providersRaw = FilterByLanguagePairs(smartRoutingState.apiKeyState.Providers);

            providersData  = providersRaw.ToDictionary(s => (string)s.id, q => q);
            providersNames = providersRaw.ToDictionary(s => (string)s.name, q => (string)q.id);

            formMT.comboBoxProviders.Items.Clear();
            formMT.comboBoxProviders.Items.AddRange(providersNames.Select(x => (string)x.Key).OrderBy(x => x).ToArray());

            dynamic providerDataFromList = null;

            if (!string.IsNullOrEmpty(currentProviderId) && providersData.TryGetValue(currentProviderId, out providerDataFromList))
            {   // Set current provider in combo box
                formMT.comboBoxProviders.SelectedItem = (string)providerDataFromList.name;
                currentProviderName = (string)providerDataFromList.name;
            }
            else
            {
                currentProviderId   = null;
                currentProviderName = null;
            }

            ExtractProviderData();
            isInitialized = true;
        }
Esempio n. 2
0
 private void CreateChildStates()
 {
     if (IsOK)
     {
         smartRoutingState = new SmartRoutingState(this, options);
     }
     else
     {
         smartRoutingState = null;
     }
 }
Esempio n. 3
0
        public static string Draw(IntentoTranslationProviderOptionsForm form, SmartRoutingState state)
        {
            if (state == null)
            {
                form.formMT.RoutingTable = new Dictionary <string, string>(defaultRoutingTable);
                form.formMT.comboBoxRouting.SelectedIndex = 0;
                ProviderState.Draw(form, null);
                return(null);
            }

            return(state.Draw());
        }
Esempio n. 4
0
 public static void FillOptions(SmartRoutingState state, IntentoMTFormOptions options)
 {
     if (state == null)
     {
         options.Routing            = "best";
         options.RoutingDisplayName = Resource.BestSmartRouteDescription;
         options.SmartRouting       = true;
         ProviderState.FillOptions(null, options);
     }
     else
     {
         options.SmartRouting       = state.SmartRouting;
         options.Routing            = state.Routing;
         options.RoutingDisplayName = state.RoutingDescription;
         ProviderState.FillOptions(state.providerState, options);
     }
     if (options.SmartRouting)
     {
         options.Format = "[\"text\",\"html\",\"xml\"]";
     }
 }
Esempio n. 5
0
        public string Draw()
        {
            form.formApi.apiKey_tb.Text     = apiKey;
            form.formApi.buttonSave.Enabled = CheckPossible;

            switch (apiKeyStatus)
            {
            case EApiKeyStatus.start:
                if (string.IsNullOrEmpty(apiKey))
                {
                    form.formApi.apiKey_tb.Enabled   = true;
                    form.formApi.apiKey_tb.BackColor = Color.LightPink;
                    // "Enter your API key and press \"Check\" button."
                    error_reason = Resource.ApiKeyNeededErrorMessage;
                }
                else
                {
                    form.formApi.apiKey_tb.Enabled   = false;
                    form.formApi.apiKey_tb.BackColor = SystemColors.Window;
                    // "API key verification in progress ...."
                    error_reason = Resource.ApiKeyVerificationInProgressMessage;
                }
                break;

            case EApiKeyStatus.download:
                form.formApi.apiKey_tb.Enabled   = false;
                form.formApi.apiKey_tb.BackColor = SystemColors.Window;
                // "API key verification in progress ...."
                error_reason = Resource.ApiKeyVerificationInProgressMessage;
                break;

            case EApiKeyStatus.ok:
                form.formApi.apiKey_tb.Enabled   = true;
                form.formApi.apiKey_tb.BackColor = SystemColors.Window;
                error_reason = null;
                break;

            case EApiKeyStatus.error:
                form.formApi.apiKey_tb.Enabled   = true;
                form.formApi.apiKey_tb.BackColor = Color.LightPink;
                break;

            case EApiKeyStatus.changed:
                form.formApi.apiKey_tb.Enabled   = true;
                form.formApi.apiKey_tb.BackColor = Color.LightPink;
                if (string.IsNullOrEmpty(apiKey))
                {
                    // Enter your API key and press \"Check\" button.
                    error_reason = Resource.ApiKeyNeededErrorMessage;
                }
                else
                {
                    // "API key verification in progress ...."
                    error_reason = Resource.ApiKeyVerificationInProgressMessage;
                }
                break;
            }
            ApiKey_Set_Panel(IsOK);
            if (!IsOK)
            {
                SmartRoutingState.Draw(form, null);
                return(error_reason);
            }
            return(SmartRoutingState.Draw(form, smartRoutingState));
        }
Esempio n. 6
0
 public void FillOptions(IntentoMTFormOptions options)
 {
     options.ApiKey = apiKey;
     SmartRoutingState.FillOptions(smartRoutingState, options);
 }