public Variant(float f) { _format = AttributeFormat.Float1; _b1 = _b2 = _b3 = _b4 = 0; _f1 = f; _f2 = _f3 = _f4 = 0.0f; }
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(); } }
/// <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); }
public Atrribute(AttributeFormat[] characterFormat, LengthType lengthType, AttributeMask[] attributeMask, short maxLength) { AttributeFormat = characterFormat; LengthType = lengthType; AttributeMask = attributeMask; MaxLength = maxLength; Length = MaxLength; }
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() }); }
public Variant(float f1, float f2) { _format = AttributeFormat.Float2; _b1 = _b2 = _b3 = _b4 = 0; _f1 = f1; _f2 = f2; _f3 = _f4 = 0.0f; }
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; }
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; }
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; }
/// <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")); } }
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; }
/// <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); }
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); }
/// <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); }
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 ?? "")) { }
public static VertexAttribute Create(AttributeType attribute, AttributeFormat format) => format switch {
public BoolAttribute(string groupName, Entity parentEntity, AttributeFormat format) : this(groupName, parentEntity, format, format.DefaultValue == "true") { }
public BoolAttribute(string groupName, Entity parentEntity, AttributeFormat format, bool value) : base(groupName, parentEntity, format) { Value = value; }
public Attribute(string groupName, Entity parentEntity, AttributeFormat format) { GroupName = groupName ?? throw new ArgumentNullException(); ParentEntity = parentEntity ?? throw new ArgumentNullException(); ChangeFormat(format); }
public ImageAttribute(string groupName, Entity parentEntity, AttributeFormat format, Image image) : base(groupName, parentEntity, format) { Image = image; }
public StringAttribute(string groupName, Entity parentEntity, AttributeFormat format, RTFString value) : base(groupName, parentEntity, format) { Value = value ?? new RTFString(""); }
public StringAttribute(string groupName, Entity parentEntity, AttributeFormat format, string value) : this(groupName, parentEntity, format, new RTFString(value)) { }
public StringAttribute(string groupName, Entity parentEntity, AttributeFormat format) : this(groupName, parentEntity, format, format.DefaultValue ?? "") { }
public NumericAttribute(string groupName, Entity parentEntity, AttributeFormat format, decimal number) : base(groupName, parentEntity, format) { Number = number; }
public NumericAttribute(string groupName, Entity parentEntity, AttributeFormat format) : base(groupName, parentEntity, format) { decimal.TryParse(format.DefaultValue, out decimal i); Number = i; }