Beispiel #1
0
 private void ResetChildrensState()
 {
     modelState = new ModelState(this, options);
     modelState.ClearOptions(options);
     modelState    = null;
     glossaryState = new GlossaryState(this, options);
     glossaryState.ClearOptions(options);
     glossaryState = null;
 }
Beispiel #2
0
 public static string Draw(IntentoTranslationProviderOptionsForm form, GlossaryState state)
 {
     if (state == null)
     {
         Glossary_GroupBox_Disable(form.formMT);
         return(null);
     }
     return(state.Draw());
 }
Beispiel #3
0
 public void glossaryControls_ValueChanged()
 {
     formMT.groupBoxOptional.Enabled = options.UseCustomModel || currentGlossary != null;
     if (!internalControlChange)
     {
         GlossaryState.FillOptions(this, options);
     }
     EnableDisable();
 }
Beispiel #4
0
        public static string Draw(IntentoTranslationProviderOptionsForm form, AuthState state)
        {
            if (state == null)
            {
                Auth_GroupBox_Enabled(form.formMT, false);
                Auth_Control_BackColor_State(form.formMT, false);

                ModelState.Draw(form, null);
                GlossaryState.Draw(form, null);

                return(null);
            }
            return(state.Draw());
        }
Beispiel #5
0
 public GlossaryState GetGlossaryState()
 {
     if (IsOK)
     {
         if (glossaryState == null)
         {
             glossaryState = new GlossaryState(this, options);
         }
     }
     else
     {
         glossaryState = null;
     }
     return(glossaryState);
 }
Beispiel #6
0
 public static void FillOptions(GlossaryState state, IntentoMTFormOptions options)
 {
     if (state == null)
     {
         options.Glossary = null;
     }
     else
     {
         options.Glossary     = state.Glossary;
         options.GlossaryMode = state.mode;
         dynamic mData = null;
         if (state.glossaries != null)
         {
             mData = state.glossaries.Select(x => (dynamic)x.Value).Where(y => (string)y.id == state.Glossary).FirstOrDefault();
         }
         options.GlossaryName = mData != null ? mData.name : state.Glossary;
     }
 }
Beispiel #7
0
        public static void FillOptions(AuthState state, IntentoMTFormOptions options)
        {
            if (state == null)
            {
                options.UseCustomAuth = false;
                options.CustomAuth    = null;
                ModelState.FillOptions(null, options);
                GlossaryState.FillOptions(null, options);
            }
            else
            {
                options.IsAuthDelegated = state.IsDelegatedCredentials;
                options.AuthMode        = state.mode;

                string id;
                if (state.IsDelegatedCredentials && state.providerDataAuthDict.TryGetValue("credential_id", out id))
                {
                    options.AuthDelegatedCredentialId = id;
                }
                else
                {
                    options.AuthDelegatedCredentialId = null;
                }

                options.UseCustomAuth = state.UseCustomAuth;
                if (options.UseCustomAuth)
                {
                    options.SetAuthDict(state.providerDataAuthDict);
                }
                else
                {
                    options.CustomAuth = null;
                }

                ModelState.FillOptions(state.GetModelState(), options);
                GlossaryState.FillOptions(state.GetGlossaryState(), options);
            }
        }
Beispiel #8
0
        public string Draw()
        {
            if (firstTimeDraw && formMT.comboBoxCredentialId.SelectedIndex < 0)
            {   // Need to fill all items - first tiem drawing after making AuthState
                FillCredentials();
                firstTimeDraw = false;
            }

            error_message = null;

            if (formMT.groupBoxBillingAccount.Enabled)
            {
                formMT.comboBoxCredentialId.Visible = true;
                if (mode == StateModeEnum.required)
                {
                    formMT.comboBoxCredentialId.Items.Remove(defaultAccountName);
                }
                else if (formMT.comboBoxCredentialId.SelectedIndex < 0)
                {
                    formMT.comboBoxCredentialId.SelectedIndexChanged -= providerState.form.comboBoxCredentialId_SelectedIndexChanged;
                    formMT.comboBoxCredentialId.SelectedItem          = defaultAccountName;
                    formMT.comboBoxCredentialId.SelectedIndexChanged += providerState.form.comboBoxCredentialId_SelectedIndexChanged;
                }
                if (mode == StateModeEnum.required && formMT.comboBoxCredentialId.SelectedIndex == -1)
                {                // Credentials required but not filled in full
                    Auth_Control_BackColor_State(formMT, true);
                    error_message = Resource.OwnCredentialsNeededErrorMessage;
                    // temporary! formMT.groupBoxOptional.Enabled = false;
                }
                else
                {                // All fields in credentals are filled
                    Auth_Control_BackColor_State(formMT, false);
                }
            }
            else
            {
                formMT.comboBoxCredentialId.Visible = false;
            }
            if (!string.IsNullOrEmpty(error_message))
            {
                ModelState.Draw(form, null);
                GlossaryState.Draw(form, null);
                return(error_message);
            }

            var modelSt = GetModelState();

            error_message = ModelState.Draw(form, modelSt);
            var    glossarySt     = GetGlossaryState();
            string error_message2 = GlossaryState.Draw(form, glossarySt);

            if (string.IsNullOrEmpty(error_message))
            {
                error_message = error_message2;
            }

            if (modelSt != null && modelSt.UseModel)
            {
                formMT.groupBoxOptional.Enabled = true;
                providerState.SetLanguageComboBoxes(modelSt.SelectedModelFrom, modelSt.SelectedModelTo);
            }
            else if (glossarySt != null && glossarySt.currentGlossary != null)
            {
                formMT.groupBoxOptional.Enabled = true;
                providerState.SetLanguageComboBoxes(glossarySt.SelectedGlossaryFrom, glossarySt.SelectedGlossaryTo);
            }
            else
            {               // No model or glossaqry, we do not need to show language selection
                // temporary! formMT.groupBoxOptional.Enabled = false;
                providerState.SetLanguageComboBoxes(null, null);
            }
            return(error_message);
        }