コード例 #1
0
ファイル: FormHelpers.cs プロジェクト: lukeskinner/OctoForms
 private static void UpdateFrom(this VariableSettings newVariableSettings, VariableSettings variableSettings)
 {
     newVariableSettings.DisplayName = variableSettings.DisplayName;
     newVariableSettings.IsReadonly = variableSettings.IsReadonly;
     newVariableSettings.VariableName = variableSettings.VariableName;
     newVariableSettings.VariableSetId = variableSettings.VariableSetId;
     newVariableSettings.VariableSets = variableSettings.VariableSets;
 }
コード例 #2
0
ファイル: FieldModel.cs プロジェクト: lukeskinner/OctoForms
 public FieldModel(FormField field, Resource resource, VariableSettings variableSettings, FormResources formResources)
 {
     Settings = variableSettings;
     FormResources = formResources;
     Resource = resource;
     VariableSetId = field.VariableSetId;
     VariableName = field.VariableName;
     LabelContent = field.DisplayName;
     Variables = new ObservableCollection<FieldVariable>();
 }
コード例 #3
0
ファイル: FormHelpers.cs プロジェクト: lukeskinner/OctoForms
        public static void UpdateFrom(this FormField formField, VariableSettings variableSettings)
        {
            formField.DisplayName = variableSettings.DisplayName;
            formField.IsReadonly = variableSettings.IsReadonly;
            formField.VariableName = variableSettings.VariableName;
            formField.VariableSetId = variableSettings.VariableSetId;

            Type formFieldType = ObjectContext.GetObjectType(formField.GetType());

            if (formFieldType == typeof (FormField_YesNo))
            {
                FormField_YesNo yesNoField = (FormField_YesNo) formField;
                BooleanSettings booleanSettings = (BooleanSettings) variableSettings;
                yesNoField.UseTrueOrFalse = booleanSettings.UseTrueOrFalse;
                yesNoField.DefaultValue = booleanSettings.DefaultValue;
            }
            else if (formFieldType == typeof(FormField_Dropdown))
            {
                FormField_Dropdown dropdownField = (FormField_Dropdown)formField;
                DropdownSettings dropdownSettings = (DropdownSettings)variableSettings;

                foreach (DropdownItemModel dropdownItemModel in dropdownSettings.Items)
                {
                    FormField_DropdownItems fieldItem = dropdownField.FormField_DropdownItems
                        .FirstOrDefault(di => di.Value == dropdownItemModel.Value);

                    if (fieldItem == null)
                    {
                        fieldItem = new FormField_DropdownItems();
                        dropdownField.FormField_DropdownItems.Add(fieldItem);
                    }

                    if (dropdownItemModel.IsDefault)
                    {
                        dropdownField.DefaultValue = dropdownItemModel.Value;
                    }

                    fieldItem.DisplayName = dropdownItemModel.DisplayName;
                    fieldItem.Value = dropdownItemModel.Value;
                }
            }
            else if (formFieldType == typeof(FormField_Textbox))
            {
                FormField_Textbox textBoxField = (FormField_Textbox)formField;
                TextboxSettings textboxSettings = (TextboxSettings)variableSettings;

                textBoxField.DefaultValue = textboxSettings.DefaultValue;
            }
            else if (formFieldType == typeof(FormField_Numeric))
            {
                FormField_Numeric numericField = (FormField_Numeric)formField;
                NumericSettings numericSettings = (NumericSettings)variableSettings;

                numericField.AllowDecimal = numericSettings.AllowDecimal;
                numericField.AllowNegativeValue = numericSettings.AllowNegativeValue;
                numericField.DefaultValue = numericSettings.DefaultValue;
                numericField.MaxValue = numericSettings.MaxValue;
                numericField.MinValue = numericSettings.MinValue;
            }
        }