Ejemplo n.º 1
0
        public static VariableSettings CreateVariableModel(this VariableSettings variableSettings)
        {
            VariableSettings newVariableSettings = null;

            var @switch = new Dictionary<string, Action>
            {
                {VariableSettings.Textbox, () => newVariableSettings = new TextboxSettings()},
                {VariableSettings.Dropdown, () => newVariableSettings = new DropdownSettings()},
                {VariableSettings.Numeric, () => newVariableSettings = new NumericSettings()},
                {VariableSettings.YesNo, () => newVariableSettings = new BooleanSettings()}
            };

            @switch[variableSettings.SelectedEditor]();

            newVariableSettings.UpdateFrom(variableSettings);

            return newVariableSettings;
        }
Ejemplo n.º 2
0
        public YesNoFieldVariable(VariableInstance variableInstance, FormControlScopeViewModel controlScopeViewModel, ScopeResources scopeResources, BooleanSettings settings)
            : base(variableInstance, controlScopeViewModel, scopeResources)
        {
            NoText = settings.UseTrueOrFalse ? "False" : "No";
            YesText = settings.UseTrueOrFalse ? "True" : "Yes";
            DefaultValue = settings.DefaultValue;

            if (variableInstance.Variable.Value == null)
            {
                Value = settings.DefaultValue.ToString().ToLower();
                IsYesChecked = settings.DefaultValue;
                IsNoChecked = settings.DefaultValue == false;
            }
            else
            {
                Value = variableInstance.Variable.Value.ToLower();
            }
        }
Ejemplo n.º 3
0
        public static VariableSettings CreateVariableModel(this FormField formField, Dictionary<string, Resource> variableSets)
        {
            VariableSettings variableSettings = null;

            var @switch = new Dictionary<Type, Action>
                {
                    {typeof (FormField_Textbox), () => variableSettings = new TextboxSettings()},
                    {typeof (FormField_Dropdown), () => variableSettings = new DropdownSettings()},
                    {typeof (FormField_Numeric), () => variableSettings = new NumericSettings()},
                    {typeof (FormField_YesNo), () => variableSettings = new BooleanSettings()}
                };

            @switch[formField.GetType().BaseType]();

            variableSettings.DisplayName = formField.DisplayName;
            variableSettings.IsReadonly = formField.IsReadonly;
            variableSettings.VariableName = formField.VariableName;

            variableSettings.UpdateFrom(formField, variableSets);

            return variableSettings;
        }