예제 #1
0
        public override IDictionary <string, FieldMetadata> GetFieldMetadata()
        {
            var fmd = base.GetFieldMetadata();

            fmd[AllowExtraValueName].FieldSetting.Visible = false;
            fmd[AllowMultipleName].FieldSetting.Visible   = false;
            fmd[OptionsName].FieldSetting.Visible         = false;
            fmd[DisplayChoicesName].FieldSetting.Visible  = false;
            fmd[CompulsoryName].FieldSetting.Visible      = false;

            var fs = new ChoiceFieldSetting
            {
                Name            = DefaultValueName,
                DisplayName     = GetTitleString(DefaultValueName),
                Description     = GetDescString(DefaultValueName),
                FieldClassName  = typeof(ChoiceField).FullName,
                AllowMultiple   = false,
                AllowExtraValue = false,
                Options         = new List <ChoiceOption>(_options),
                DisplayChoice   = Fields.DisplayChoice.DropDown,
                Visible         = true
            };

            fmd[DefaultValueName].FieldSetting = fs;

            return(fmd);
        }
예제 #2
0
        public override IDictionary <string, FieldMetadata> GetFieldMetadata()
        {
            var fmd = base.GetFieldMetadata();

            fmd[ShowAsPercentageName].FieldSetting.Visible = false;
            fmd[DigitsName].FieldSetting.DefaultValue      = "0";

            var minvalFs = (NumberFieldSetting)fmd[MinValueName].FieldSetting;

            //minvalFs.MinValue = 0;
            //minvalFs.Compulsory = true;
            minvalFs.DefaultValue = "0";

            var fs = new ChoiceFieldSetting
            {
                Name            = FormatName,
                DisplayName     = GetTitleString(FormatName),
                Description     = GetDescString(FormatName),
                FieldClassName  = typeof(ChoiceField).FullName,
                AllowMultiple   = false,
                AllowExtraValue = false,
                Options         = GetCurrencyOptions(),
                DisplayChoice   = DisplayChoice.DropDown,
                DefaultValue    = @"[Script:jScript] System.Globalization.CultureInfo.CurrentUICulture.IsNeutralCulture ? System.Globalization.CultureInfo.CreateSpecificCulture(System.Globalization.CultureInfo.CurrentUICulture.Name).Name : System.Globalization.CultureInfo.CurrentUICulture.Name; [/Script]"
            };

            fmd.Add(FormatName, new FieldMetadata
            {
                FieldName    = FormatName,
                CanRead      = true,
                CanWrite     = true,
                FieldSetting = fs
            });

            return(fmd);
        }
예제 #3
0
        public static void ParseOptions(XPathNavigator node, List <ChoiceOption> options, ChoiceFieldSetting fieldSetting, out string enumTypeName)
        {
            options.Clear();
            enumTypeName = string.Empty;

            foreach (XPathNavigator optionElement in node.SelectChildren(XPathNodeType.Element))
            {
                if (optionElement.Name == "Enum")
                {
                    enumTypeName = optionElement.GetAttribute("type", "");
                    var enumType = TypeHandler.GetType(enumTypeName);
                    if (enumType == null)
                    {
                        throw new ContentRegistrationException("Enum");
                    }

                    var resClassName = optionElement.GetAttribute("resourceClass", "");
                    if (string.IsNullOrEmpty(resClassName))
                    {
                        resClassName = CtdResourceClassName;
                    }

                    var names  = Enum.GetNames(enumType);
                    var values = Enum.GetValues(enumType).Cast <int>().ToArray();
                    for (var i = 0; i < names.Length; i++)
                    {
                        var resKey = fieldSetting == null ? string.Empty : fieldSetting.GetResourceKey(names[i]);
                        var text   = string.IsNullOrEmpty(resKey) ? names[i] : ResourceManager.GetResourceKey(resClassName, resKey);
                        var c      = new ChoiceOption(values[i].ToString(), text);
                        options.Add(c);
                    }
                }
                else
                {
                    var text = optionElement.InnerXml;
                    var key  = optionElement.GetAttribute("value", "");

                    if (text.Length == 0 && key.Length == 0)
                    {
                        key = options.Count.ToString();
                    }
                    if (text.Length == 0)
                    {
                        text = key;
                    }
                    if (key.Length == 0)
                    {
                        key = text;
                    }

                    bool enabled;
                    if (!Boolean.TryParse(optionElement.GetAttribute("enabled", ""), out enabled))
                    {
                        enabled = true;
                    }

                    var selected = false;
                    Boolean.TryParse(optionElement.GetAttribute("selected", ""), out selected);

                    options.Add(new ChoiceOption(key, text, enabled, selected));
                }
            }
        }