/// <summary> /// Initializes a new instance of the class. /// </summary> public ElementMargin(ElementSize left, ElementSize top) { _left = left; _top = top; _right = new ElementSize(); _bottom = new ElementSize(); }
/// <summary> /// Initializes a new instance of the class. /// </summary> public ElementMargin(float margin) { _left = new ElementSize(margin, ElementSizeUnit.Pixels); _top = new ElementSize(margin, ElementSizeUnit.Pixels); _right = new ElementSize(margin, ElementSizeUnit.Pixels); _bottom = new ElementSize(margin, ElementSizeUnit.Pixels); }
/// <summary> /// Initializes a new instance of the class. /// </summary> public ElementMargin(ElementSize margin) { _left = margin; _top = margin; _right = margin; _bottom = margin; }
/// <summary> /// Initializes a new instance of the class. /// </summary> public ElementMargin() { _left = new ElementSize(); _top = new ElementSize(); _right = new ElementSize(); _bottom = new ElementSize(); }
/// <summary> /// Initializes a new instance of the class. /// </summary> public ElementMargin(float left, float top, float right = 0, float bottom = 0) { _left = new ElementSize(left, ElementSizeUnit.Pixels); _top = new ElementSize(top, ElementSizeUnit.Pixels); _right = new ElementSize(right, ElementSizeUnit.Pixels); _bottom = new ElementSize(bottom, ElementSizeUnit.Pixels); }
/// <summary> /// Initializes a new instance of the class. /// </summary> public ElementMargin(ElementSize left, ElementSize top, ElementSize right, ElementSize bottom) { _left = left; _top = top; _right = right; _bottom = bottom; }
/// <summary> /// Initializes a new instance of the class. /// </summary> public ElementMargin(ElementSize left, ElementSize top, ElementSize right) : this() { _left = left; _top = top; _right = right; _bottom = new ElementSize(); }
/// <summary> /// Parses string into element size. /// </summary> public static ElementSize Parse(string value, Vector3 unitSize) { ElementSize elementSize = new ElementSize(); string trimmedValue = value.Trim(); if (trimmedValue == "*") { elementSize.Value = 1; elementSize.Unit = ElementSizeUnit.Percents; elementSize.Fill = true; } else if (trimmedValue.EndsWith("%")) { int lastIndex = trimmedValue.LastIndexOf("%", StringComparison.OrdinalIgnoreCase); elementSize.Value = System.Convert.ToSingle(trimmedValue.Substring(0, lastIndex), CultureInfo.InvariantCulture) / 100.0f; elementSize.Unit = ElementSizeUnit.Percents; } else if (trimmedValue.EndsWith("px")) { int lastIndex = trimmedValue.LastIndexOf("px", StringComparison.OrdinalIgnoreCase); elementSize.Value = System.Convert.ToSingle(trimmedValue.Substring(0, lastIndex), CultureInfo.InvariantCulture); elementSize.Unit = ElementSizeUnit.Pixels; } else if (trimmedValue.EndsWith("ux")) { int lastIndex = trimmedValue.LastIndexOf("ux", StringComparison.OrdinalIgnoreCase); elementSize.Value = System.Convert.ToSingle(trimmedValue.Substring(0, lastIndex), CultureInfo.InvariantCulture) * unitSize.x; elementSize.Unit = ElementSizeUnit.Pixels; } else if (trimmedValue.EndsWith("uy")) { int lastIndex = trimmedValue.LastIndexOf("uy", StringComparison.OrdinalIgnoreCase); elementSize.Value = System.Convert.ToSingle(trimmedValue.Substring(0, lastIndex), CultureInfo.InvariantCulture) * unitSize.y; elementSize.Unit = ElementSizeUnit.Pixels; } else if (trimmedValue.EndsWith("uz")) { int lastIndex = trimmedValue.LastIndexOf("uz", StringComparison.OrdinalIgnoreCase); elementSize.Value = System.Convert.ToSingle(trimmedValue.Substring(0, lastIndex), CultureInfo.InvariantCulture) * unitSize.z; elementSize.Unit = ElementSizeUnit.Pixels; } else { elementSize.Value = System.Convert.ToSingle(trimmedValue, CultureInfo.InvariantCulture); elementSize.Unit = ElementSizeUnit.Pixels; } return(elementSize); }
/// <summary> /// Initializes a new instance of the class. /// </summary> public ElementSize(ElementSize elementSize) { _value = elementSize.Value; _unit = elementSize.Unit; _fill = elementSize.Fill; }
/// <summary> /// Gets bottom margin from bottom size. /// </summary> public static ElementMargin FromBottom(ElementSize bottom) { return(new ElementMargin(new ElementSize(), new ElementSize(), new ElementSize(), bottom)); }
/// <summary> /// Gets right margin from right size. /// </summary> public static ElementMargin FromRight(ElementSize right) { return(new ElementMargin(new ElementSize(), new ElementSize(), right, new ElementSize())); }
/// <summary> /// Gets top margin from top size. /// </summary> public static ElementMargin FromTop(ElementSize top) { return(new ElementMargin(new ElementSize(), top, new ElementSize(), new ElementSize())); }
/// <summary> /// Gets left margin from left size. /// </summary> public static ElementMargin FromLeft(ElementSize left) { return(new ElementMargin(left, new ElementSize(), new ElementSize(), new ElementSize())); }