Esempio n. 1
0
 public Variant(float f)
 {
     _format = AttributeFormat.Float1;
     _b1     = _b2 = _b3 = _b4 = 0;
     _f1     = f;
     _f2     = _f3 = _f4 = 0.0f;
 }
Esempio n. 2
0
 public void ChangeFormat(AttributeFormat format)
 {
     if (Format is null || (format.DeleteLocked == Format.DeleteLocked && format.NameLocked == Format.NameLocked)) // Absolutely disallow this from changing
     {
         Format = format ?? throw new ArgumentNullException();
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Parse an attr format value into an enum value.
        /// </summary>
        private static AttributeFormat ParseFormat(string format)
        {
            AttributeFormat result = 0;

            if (string.IsNullOrEmpty(format))
            {
                return(result);
            }
            foreach (var part in format.Split('|'))
            {
                switch (part)
                {
                case "reference":
                    result |= AttributeFormat.Reference;
                    break;

                case "string":
                    result |= AttributeFormat.String;
                    break;

                case "color":
                    result |= AttributeFormat.Color;
                    break;

                case "dimension":
                    result |= AttributeFormat.Dimension;
                    break;

                case "boolean":
                    result |= AttributeFormat.Boolean;
                    break;

                case "integer":
                    result |= AttributeFormat.Integer;
                    break;

                case "float":
                    result |= AttributeFormat.Float;
                    break;

                case "fraction":
                    result |= AttributeFormat.Fraction;
                    break;

                case "enum":
                    result |= AttributeFormat.Enum;
                    break;

                case "flag":
                    result |= AttributeFormat.Flag;
                    break;

                default:
                    result |= AttributeFormat.Unknown;
                    break;
                }
            }
            return(result);
        }
Esempio n. 4
0
 public Atrribute(AttributeFormat[] characterFormat, LengthType lengthType, AttributeMask[] attributeMask, short maxLength)
 {
     AttributeFormat = characterFormat;
     LengthType = lengthType;
     AttributeMask = attributeMask;
     MaxLength = maxLength; 
     Length = MaxLength;
 }
Esempio n. 5
0
 public AttributeFormat(AttributeFormat format, string columnName = null, int?style = null, bool?deleteIfEmpty = null, string defaultValue = null)
 {
     Style         = style ?? format.Style;
     DeleteIfEmpty = deleteIfEmpty ?? format.DeleteIfEmpty;
     DeleteLocked  = format.DeleteLocked;
     NameLocked    = format.NameLocked;
     DefaultValue  = defaultValue ?? format.DefaultValue;
 }
 public static Attribute Load(XElement e)
 {
     return(new Attribute {
         Name = e.Attribute("name")?.Value,
         Formats = AttributeFormat.Get(e.Attribute("format")?.Value).ToList(),
         Enumerations = e.Elements("flag").Concat(e.Elements("enum")).Select(c => AttributeValueEnumeration.Load(c)).ToList()
     });
 }
Esempio n. 7
0
 public Variant(float f1, float f2)
 {
     _format = AttributeFormat.Float2;
     _b1     = _b2 = _b3 = _b4 = 0;
     _f1     = f1;
     _f2     = f2;
     _f3     = _f4 = 0.0f;
 }
Esempio n. 8
0
 public Atrribute(AttributeFormat[] attributeFormat, LengthType lengthType, AttributeMask[] attributeMask, short maxLength, short length)
 {
     AttributeFormat = attributeFormat;
     AttributeMask = attributeMask;
     LengthType = lengthType;
     MaxLength = maxLength;
     Length = lengthType != LengthType.FIXED ? length : maxLength;
 }
Esempio n. 9
0
 public Variant(byte b1, byte b2, byte b3, byte b4)
 {
     _format = AttributeFormat.UByte4;
     _f1     = _f2 = _f3 = _f4 = 0.0f;
     _b1     = b1;
     _b2     = b2;
     _b3     = b3;
     _b4     = b4;
 }
Esempio n. 10
0
 public Variant(float f1, float f2, float f3, float f4)
 {
     _format = AttributeFormat.Float4;
     _b1     = _b2 = _b3 = _b4 = 0;
     _f1     = f1;
     _f2     = f2;
     _f3     = f3;
     _f4     = f4;
 }
Esempio n. 11
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public AttributeDescriptor(string name, AttributeFormat format)
 {
     this.name = name;
     this.format = format;
     if ((format & AttributeFormat.Boolean) == AttributeFormat.Boolean)
     {
         Add(new AttributeValueDescriptor("true"));
         Add(new AttributeValueDescriptor("false"));
     }
 }
Esempio n. 12
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public AttributeDescriptor(string name, AttributeFormat format)
 {
     this.name   = name;
     this.format = format;
     if ((format & AttributeFormat.Boolean) == AttributeFormat.Boolean)
     {
         Add(new AttributeValueDescriptor("true"));
         Add(new AttributeValueDescriptor("false"));
     }
 }
Esempio n. 13
0
            public FormulaAttribute(string groupName, Entity parentEntity, AttributeFormat format, Expression formla)
                : base(groupName, parentEntity, format)
            {
                Formula = formla ?? throw new ArgumentNullException();

                // Bind events
                parentEntity.AttributeAdded        += ParentEntity_AttributeAdded;
                parentEntity.AttributeRemoved      += ParentEntity_AttributeRemoved;
                parentEntity.AttributeValueChanged += ParentEntity_AttributeValueChanged;
            }
Esempio n. 14
0
        /// <summary>
        /// Convert a resources.arsc AttributeTypes to an AttributeFormat.
        /// </summary>
        private static AttributeFormat AttributeTypeToFormat(AttributeTypes attributeTypes)
        {
            AttributeFormat result = 0;

            if ((attributeTypes & AttributeTypes.TYPE_REFERENCE) != 0)
            {
                result |= AttributeFormat.Reference;
            }
            if ((attributeTypes & AttributeTypes.TYPE_STRING) != 0)
            {
                result |= AttributeFormat.String;
            }
            if ((attributeTypes & AttributeTypes.TYPE_INTEGER) != 0)
            {
                result |= AttributeFormat.Integer;
            }
            if ((attributeTypes & AttributeTypes.TYPE_BOOLEAN) != 0)
            {
                result |= AttributeFormat.Boolean;
            }
            if ((attributeTypes & AttributeTypes.TYPE_COLOR) != 0)
            {
                result |= AttributeFormat.Color;
            }
            if ((attributeTypes & AttributeTypes.TYPE_FLOAT) != 0)
            {
                result |= AttributeFormat.Float;
            }
            if ((attributeTypes & AttributeTypes.TYPE_DIMENSION) != 0)
            {
                result |= AttributeFormat.Dimension;
            }
            if ((attributeTypes & AttributeTypes.TYPE_FRACTION) != 0)
            {
                result |= AttributeFormat.Fraction;
            }
            if ((attributeTypes & AttributeTypes.TYPE_ENUM) != 0)
            {
                result |= AttributeFormat.Enum;
            }
            if ((attributeTypes & AttributeTypes.TYPE_FLAGS) != 0)
            {
                result |= AttributeFormat.Flag;
            }
            return(result);
        }
Esempio n. 15
0
 public ImageAttribute(string groupName, Entity parentEntity, AttributeFormat format)
     : base(groupName, parentEntity, format)
 {
     if (string.IsNullOrEmpty(format.DefaultValue))
     {
         Image = nullImage;
     }
     else
     {
         try
         {
             Image = Image.FromFile(format.DefaultValue);
         }
         catch (FileNotFoundException)
         {
             Image = nullImage;
         }
     }
 }
 /// <summary>
 /// Parses the provided xml/html document into discrete components and provides the
 /// information to the provided reader, see XmlLightDocument
 /// </summary>
 public static void Parse(string content, AttributeFormat format, IXmlLightReader reader)
 {
     Parse(content, format == AttributeFormat.Html ? HtmlElementParsing : XmlElementParsing, reader);
 }
Esempio n. 17
0
        /// <summary>
        /// Makes a new attribute from an AttributeType
        /// </summary>
        /// <param name="type">The type of the attribute</param>
        /// <param name="groupName">The name of the group</param>
        /// <param name="entity">The entity that this attribute belongs to</param>
        /// <param name="format">The format to take</param>
        /// <returns>A new attribute</returns>
        public static Attribute MakeNewAttribute(AttributeType type, string groupName, Entity entity, AttributeFormat format)
        {
            switch (type)
            {
            case AttributeType.Numeric:
                return(new NumericAttribute(groupName, entity, format));

            case AttributeType.String:
                return(new StringAttribute(groupName, entity, format));

            case AttributeType.Image:
                return(new ImageAttribute(groupName, entity, format));

            case AttributeType.Bool:
                return(new BoolAttribute(groupName, entity, format));

            case AttributeType.Formula:
                return(new FormulaAttribute(groupName, entity, format));
            }
            return(null);
        }
Esempio n. 18
0
 /// <summary>
 /// Parses the provided xml/html document into discrete components and provides the
 /// information to the provided reader, see XmlLightDocument
 /// </summary>
 public static void Parse(string content, AttributeFormat format, IXmlLightReader reader)
 {
     Parse(content, format == AttributeFormat.Html ? HtmlElementParsing : XmlElementParsing, reader);
 }
Esempio n. 19
0
            private string _result; // The result of the last time the formula was executed

            public FormulaAttribute(string groupName, Entity parentEntity, AttributeFormat format)
                : this(groupName, parentEntity, format, new Expression(format.DefaultValue ?? ""))
            {
            }
Esempio n. 20
0
 public static VertexAttribute Create(AttributeType attribute, AttributeFormat format) => format switch
 {
Esempio n. 21
0
 public BoolAttribute(string groupName, Entity parentEntity, AttributeFormat format)
     : this(groupName, parentEntity, format, format.DefaultValue == "true")
 {
 }
Esempio n. 22
0
 public BoolAttribute(string groupName, Entity parentEntity, AttributeFormat format, bool value)
     : base(groupName, parentEntity, format)
 {
     Value = value;
 }
Esempio n. 23
0
 public Attribute(string groupName, Entity parentEntity, AttributeFormat format)
 {
     GroupName    = groupName ?? throw new ArgumentNullException();
     ParentEntity = parentEntity ?? throw new ArgumentNullException();
     ChangeFormat(format);
 }
Esempio n. 24
0
 public ImageAttribute(string groupName, Entity parentEntity, AttributeFormat format, Image image)
     : base(groupName, parentEntity, format)
 {
     Image = image;
 }
Esempio n. 25
0
 public StringAttribute(string groupName, Entity parentEntity, AttributeFormat format, RTFString value)
     : base(groupName, parentEntity, format)
 {
     Value = value ?? new RTFString("");
 }
Esempio n. 26
0
 public StringAttribute(string groupName, Entity parentEntity, AttributeFormat format, string value)
     : this(groupName, parentEntity, format, new RTFString(value))
 {
 }
Esempio n. 27
0
 public StringAttribute(string groupName, Entity parentEntity, AttributeFormat format)
     : this(groupName, parentEntity, format, format.DefaultValue ?? "")
 {
 }
Esempio n. 28
0
 public NumericAttribute(string groupName, Entity parentEntity, AttributeFormat format, decimal number)
     : base(groupName, parentEntity, format)
 {
     Number = number;
 }
Esempio n. 29
0
 public NumericAttribute(string groupName, Entity parentEntity, AttributeFormat format)
     : base(groupName, parentEntity, format)
 {
     decimal.TryParse(format.DefaultValue, out decimal i);
     Number = i;
 }