public static FloatRectangle AdjustForMargin(this FloatRectangle inputRectangle, DataboundAsset.DataboundValue <Thickness> margin) { if (inputRectangle.Height == 0 || !margin.HasValue()) { return(inputRectangle); } else { return(new FloatRectangle(inputRectangle.X + margin.Value.Left, inputRectangle.Y + margin.Value.Top, inputRectangle.Width - margin.Value.HorizontalMargin, inputRectangle.Height - margin.Value.VerticalMargin)); } }
public T GetValue <T>(DataboundAsset.DataboundValue <T> dbValue) { bool invert = false; if (dbValue == null) { return(default(T)); } if (!string.IsNullOrWhiteSpace(dbValue.BoundTo)) { string boundTo = dbValue.BoundTo; if (dbValue.Invert) { invert = true; } if (!Store.ContainsKey(boundTo)) { return(default(T)); } object val = Store[boundTo]; if (invert) { Type typeParameterType = val.GetType(); if (typeParameterType == typeof(bool)) { val = !(bool)val; } } if (typeof(T) == typeof(string)) { return((T)((object)(val.ToString()))); } return((T)val); } else { return(dbValue.Value); } }
public static Vector2 ToVector2(this DataboundAsset.DataboundValue <FloatRectangle> rect) { return(rect.Value.ToVector2); }
public static Vector2 PadForMargin(this Vector2 inputVector2, DataboundAsset.DataboundValue <Thickness> margin) => inputVector2.Y == 0 || !margin.HasValue() ? inputVector2 : new Vector2(inputVector2.X + margin.Value.HorizontalMargin, inputVector2.Y + margin.Value.VerticalMargin);