/// <summary> /// Sets default values of the view. /// </summary> public override void SetDefaultValues() { base.SetDefaultValues(); Alignment.DirectValue = MarkLight.ElementAlignment.Center; Width.DirectValue = new ElementSize(1.0f, ElementSizeUnit.Percents); Height.DirectValue = new ElementSize(1.0f, ElementSizeUnit.Percents); OverrideWidth.DirectValue = ElementSize.FromPixels(0); OverrideHeight.DirectValue = ElementSize.FromPixels(0); Margin.DirectValue = new ElementMargin(); Offset.DirectValue = new ElementMargin(); Alpha.DirectValue = 1; IsVisible.DirectValue = true; if (ImageComponent != null) { ImageComponent.color = Color.clear; ImageComponent.type = UnityEngine.UI.Image.Type.Simple; } IsActive.DirectValue = true; OffsetFromParent.DirectValue = new ElementMargin(); SortIndex.DirectValue = 0; UpdateRectTransform.DirectValue = true; UpdateBackground.DirectValue = true; }
public static void AssertSize <T>(ElementSize elementSize) { if (TypeHelpers.ToElementSize <T>() != elementSize) { throw new InvalidOperationException($"Element size mismatch, T is {Unsafe.SizeOf<T>()}, pointer is {elementSize}"); } }
/// <summary> /// Value converter for ElementSize type. /// </summary> public override ConversionResult Convert(object value, ValueConverterContext context) { if (value == null) { return(base.Convert(value, context)); } Type valueType = value.GetType(); if (valueType == _type) { return(base.Convert(value, context)); } else if (valueType == _stringType) { var stringValue = (string)value; try { var convertedValue = ElementSize.Parse(stringValue, context.UnitSize); return(new ConversionResult(convertedValue)); } catch (Exception e) { return(ConversionFailed(value, e)); } } return(ConversionFailed(value)); }
public static StructAccessor <T> Create(ElementSize elementSize, short dataWords, short pointers) { try { #if FULLCLR var methods = typeof(T).GetMethods(BindingFlags.Public | BindingFlags.Static); #else var methods = typeof(T).GetRuntimeMethods(); #endif var op_toT = FindMethod(methods, typeof(Pointer), typeof(T), "op_implicit") ?? FindMethod(methods, typeof(Pointer), typeof(T), "op_explicit"); var op_fromT = FindMethod(methods, typeof(T), typeof(Pointer), "op_implicit") ?? FindMethod(methods, typeof(T), typeof(Pointer), "op_explicit"); if (op_toT != null && op_fromT != null) { #if FULLCLR Func <Pointer, T> toT = (Func <Pointer, T>)Delegate.CreateDelegate(typeof(Func <Pointer, T>), null, op_toT); Func <T, Pointer> fromT = (Func <T, Pointer>)Delegate.CreateDelegate(typeof(Func <T, Pointer>), null, op_fromT); #else ParameterExpression p; Func <Pointer, T> toT = Expression.Lambda <Func <Pointer, T> >( Expression.Convert(p = Expression.Parameter(typeof(T)), typeof(T), op_toT), p).Compile(); Func <T, Pointer> fromT = Expression.Lambda <Func <T, Pointer> >( Expression.Convert(p = Expression.Parameter(typeof(T)), typeof(Pointer), op_fromT), p).Compile(); #endif return(new OperatorBasedStructTypeAccessor(elementSize, dataWords, pointers, toT, fromT)); } } catch { } return(new DynamicStructTypeAccessor(elementSize, dataWords, pointers)); }
public OperatorBasedStructTypeAccessor(ElementSize elementSize, short dataWords, short pointers, Func <Pointer, T> toT, Func <T, Pointer> fromT) : base(elementSize, dataWords, pointers) { this.toT = toT; this.fromT = fromT; }
/// <summary> /// Sets default values of the view. /// </summary> public override void SetDefaultValues() { base.SetDefaultValues(); Width.DirectValue = ElementSize.FromPixels(160); Height.DirectValue = ElementSize.FromPixels(40); }
/// <summary> /// Interpolates between two element sizes based on a weight. /// </summary> public override object Interpolate(object from, object to, float weight) { ElementSize a = from as ElementSize; ElementSize b = to as ElementSize; if (a == null || b == null) { return(base.Interpolate(from, to, weight)); } if (a.Unit == ElementSizeUnit.Percents || b.Unit == ElementSizeUnit.Percents) { if (a.Unit != b.Unit) { // can't interpolate between percent and another unit type return(from); } else { return(new ElementSize(Lerp(a.Percent, b.Percent, weight), ElementSizeUnit.Percents)); } } return(new ElementSize(Lerp(a.Pixels, b.Pixels, weight), ElementSizeUnit.Pixels)); }
// TODO is there a way to run a callback when a field changes? public void SetItems(ObservableList <ItemInstance> items) { SetValue("Items", items); int NumInColumn = (int)Math.Ceiling((float)items.Count() / NumInRow); Height.Value = ElementSize.FromPixels(NumInColumn * Template.Height.Value.Pixels + ContainerNameLabel.Height.Value.Pixels); }
public void MarginRight(bool toggle) { LayoutRegion.Margin.Value = new ElementMargin( LayoutRegion.Margin.Value.Left, LayoutRegion.Margin.Value.Top, toggle ? ElementSize.FromPixels(100) : new ElementSize(), LayoutRegion.Margin.Value.Bottom ); }
public void OffsetBottom(bool toggle) { LayoutRegion.Offset.Value = new ElementMargin( LayoutRegion.Offset.Value.Left, LayoutRegion.Offset.Value.Top, LayoutRegion.Offset.Value.Right, toggle ? ElementSize.FromPixels(100) : new ElementSize() ); }
public override void Initialize() { base.Initialize(); float rowSpacing = Container.Spacing.Value.Pixels; float rowWidth = NumInRow * Template.Width.Value.Pixels + (NumInRow + 1) * rowSpacing; Container.Width.Value = ElementSize.FromPixels(rowWidth); }
public static string ToClassString(this ElementSize t, string prefix) { if (t == ElementSize.None) { return(""); } return(prefix + ToClassString(t)); }
private int ConvertRealSize( ElementSize elementSize ) { switch ( elementSize ) { case ElementSize.Float1: return 4; case ElementSize.Float2: return 8; case ElementSize.Float3: return 12; case ElementSize.Float4: return 16; default: throw new ArgumentException (); } }
private SharpDX.Direct3D9.DeclarationType ConvertType( ElementSize elementSize ) { switch ( elementSize ) { case ElementSize.Float1: return SharpDX.Direct3D9.DeclarationType.Float1; case ElementSize.Float2: return SharpDX.Direct3D9.DeclarationType.Float2; case ElementSize.Float3: return SharpDX.Direct3D9.DeclarationType.Float3; case ElementSize.Float4: return SharpDX.Direct3D9.DeclarationType.Float4; default: throw new ArgumentException (); } }
/// <summary> /// Overloaded constructor used create an instance of the OptionsModel class during serialization. /// The public properties of this class are set by this contructor as they are obtained from the /// IChart interface object passed as the parameter. /// </summary> /// <param name="chart">Specifies the IChart interface object of the parent IChart object being serialized.</param> public OptionsModel(IChart chart) { BubbleMinSize = (double)chart.GetOption("BubbleMinSize"); BubbleMaxSize = (double)chart.GetOption("BubbleMaxSize"); ElementSize es = chart.GetOption("ClusterSize") as ElementSize; ClusterSizeType = es.Equals(null) ? ElementSizeType.Percentage : es.SizeType; ClusterSizeValue = es.Equals(null) ? 70.0 : es.Value; InterpolateNulls = (bool)chart.GetOption("InterpolateNulls"); }
private VertexAttribPointerType ElementSizeToRealType( ElementSize elementSize ) { switch ( elementSize ) { case ElementSize.Float1: case ElementSize.Float2: case ElementSize.Float3: case ElementSize.Float4: return VertexAttribPointerType.Float; default: throw new ArgumentException (); } }
public override void Initialize() { base.Initialize(); OptionsWidth = new ElementSize(400, ElementSizeUnit.Pixels); OptionsHeight = new ElementSize(350, ElementSizeUnit.Pixels); SoundTabHeader.Scale.Value = new Vector3(0.0f, 0.0f, 0.0f); DisplayTabHeader.Scale.Value = new Vector3(0.0f, 0.0f, 0.0f); SunRaysMaterialTypeA = Resources.Load("Particles/Materials/Light_02", typeof(Material)) as Material; SunRaysMaterialTypeA.SetColor("_TintColor", Color.magenta); }
public void ReactToElement(SystemicElement type, ElementSize size) { for (int i = 0; i < reactions.Length; i++) { if (reactions[i].theElement == type && ((reactions[i].theSize != ElementSize.NONE && (int)size >= (int)reactions[i].theSize) || reactions[i].theSize == ElementSize.NONE) ) { reactions[i].actions.Invoke(); } } }
public static IDisposable BeginModal(this HtmlHelper helper, string id, ElementSize size = ElementSize.Normal) { var modalSize = String.Empty; if (size == ElementSize.ExtraSmall || size == ElementSize.Small) modalSize = " modal-sm"; if (size == ElementSize.Large) modalSize = " modal-lg"; helper.ViewContext.Writer.WriteLine("<div class=\"modal fade\" id=\"{0}\" tabindex=\"-1\" role=\"dialog\">", id); helper.ViewContext.Writer.WriteLine("<div class=\"modal-dialog{0}\">", modalSize); helper.ViewContext.Writer.WriteLine("<div class=\"modal-content\">"); return new Modal(helper); }
/// <summary> /// Sets default values of the view. /// </summary> public override void SetDefaultValues() { base.SetDefaultValues(); Breadth.DirectValue = new ElementSize(40); Length.DirectValue = new ElementSize(120); TextPadding.DirectValue = new ElementMargin(); // list item label if (ItemLabel != null) { ItemLabel.TextAlignment.DirectValue = ElementAlignment.Center; ItemLabel.Width.DirectValue = ElementSize.FromPercents(1); ItemLabel.Height.DirectValue = ElementSize.FromPercents(1); } }
/// <summary> /// Sets default values of the view. /// </summary> public override void SetDefaultValues() { base.SetDefaultValues(); Length.DirectValue = new ElementSize(160); Breadth.DirectValue = new ElementSize(40); Orientation.DirectValue = ElementOrientation.Horizontal; Min.DirectValue = 0; Max.DirectValue = 100; CanSlide.DirectValue = true; SetValueOnDragEnded.DirectValue = false; SliderFillImageView.Alignment.DirectValue = ElementAlignment.Left; SliderHandleImageView.Alignment.DirectValue = ElementAlignment.Left; SliderHandleImageView.Width.DirectValue = new ElementSize(20); SliderHandleImageView.Height.DirectValue = ElementSize.FromPercents(1); }
public static string ToClassString(this ElementSize t) { switch (t) { case ElementSize.ExtraSmall: return("xs"); case ElementSize.Small: return("sm"); case ElementSize.Medium: return("md"); case ElementSize.Large: return("lg"); case ElementSize.ExtraLarge: return("xl"); } return("sm"); }
/// <summary> /// Updates the layout of the view. /// </summary> public override void LayoutChanged() { // set content margins based on tab list size and its orientation var contentMargin = new ElementMargin(); var tabAlignment = ElementAlignment.Center; if (TabHeaderList.Orientation == ElementOrientation.Horizontal) { if (TabHeaderList.Alignment.Value.HasFlag(ElementAlignment.Bottom)) { contentMargin.Bottom = ElementSize.FromPixels(TabHeaderList.Height.Value.Pixels); tabAlignment = ElementAlignment.Top; } else { contentMargin.Top = ElementSize.FromPixels(TabHeaderList.Height.Value.Pixels); tabAlignment = ElementAlignment.Bottom; } } else { if (TabHeaderList.Alignment.Value.HasFlag(ElementAlignment.Right)) { contentMargin.Right = ElementSize.FromPixels(TabHeaderList.Width.Value.Pixels); tabAlignment = ElementAlignment.Left; } else { contentMargin.Left = ElementSize.FromPixels(TabHeaderList.Width.Value.Pixels); tabAlignment = ElementAlignment.Right; } } if (AutoAdjustContentMargin) { TabContent.Margin.Value = contentMargin; } if (AutoAdjustTabListContentAlignment) { TabHeaderList.ContentAlignment.Value = tabAlignment; } base.LayoutChanged(); }
public static StructAccessor <T> Create(ElementSize elementSize, short dataWords, short pointers) { try { var methods = typeof(T).GetMethods(BindingFlags.Public | BindingFlags.Static); var op_toT = FindMethod(methods, typeof(Pointer), typeof(T), "op_implicit") ?? FindMethod(methods, typeof(Pointer), typeof(T), "op_explicit"); var op_fromT = FindMethod(methods, typeof(T), typeof(Pointer), "op_implicit") ?? FindMethod(methods, typeof(T), typeof(Pointer), "op_explicit"); if (op_toT != null && op_fromT != null) { Func <Pointer, T> toT = (Func <Pointer, T>)Delegate.CreateDelegate(typeof(Func <Pointer, T>), null, op_toT); Func <T, Pointer> fromT = (Func <T, Pointer>)Delegate.CreateDelegate(typeof(Func <T, Pointer>), null, op_fromT); return(new OperatorBasedStructTypeAccessor(elementSize, dataWords, pointers, toT, fromT)); } } catch { } return(new DynamicStructTypeAccessor(elementSize, dataWords, pointers)); }
/// <summary> /// Sets default values of the view. /// </summary> public override void SetDefaultValues() { base.SetDefaultValues(); Width.DirectValue = new ElementSize(200); Height.DirectValue = new ElementSize(40); // input text InputText.Margin.DirectValue = new ElementMargin(9); InputText.TextAlignment.DirectValue = ElementAlignment.TopLeft; InputText.Width.DirectValue = ElementSize.FromPercents(1); InputText.Height.DirectValue = ElementSize.FromPercents(1); // inputfield component InputFieldComponent.textComponent = InputText.TextComponent; InputFieldComponent.placeholder = InputFieldPlaceholder.ImageComponent; InputFieldComponent.transition = Selectable.Transition.None; }
public static string TranslateLabel(ElementSize size, float proportion) { float proportionInverse = 1 / proportion; int sm = Convert.ToInt32(4 * proportionInverse); int md = 6; int lg = Convert.ToInt32(3 * proportion); int xl = Convert.ToInt32(2 * proportion); switch (size) { case ElementSize.ExtraLarge: return("col-sm-4 col-lg-3 col-xl-2"); default: return("col-sm-4 col-lg-3 col-xl-2"); } }
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { ElementSize es = value as ElementSize; if (object.ReferenceEquals(es, null)) { return(string.Empty); } switch (es.SizeType) { case ElementSizeType.Absolute: return(es.Value.ToString(culture) + "tw"); case ElementSizeType.Percentage: return(es.Value.ToString(culture) + "%"); } return(base.ConvertTo(context, culture, value, destinationType)); }
private string GetAttributeString() { var attributes = new Dictionary <string, string>(); attributes.Add("protocol", this.Protocol.ToString()); attributes.Add("gateway", this.Gateway); attributes.Add("path", Path); attributes.Add("plc", PlcType.ToString().ToLower()); attributes.Add("elem_size", ElementSize?.ToString()); attributes.Add("elem_count", ElementCount?.ToString()); attributes.Add("name", Name); attributes.Add("read_cache_ms", ReadCacheMillisecondDuration?.ToString()); if (UseConnectedMessaging.HasValue) { attributes.Add("use_connected_msg", UseConnectedMessaging.Value ? "1" : "0"); } string separator = "&"; return(string.Join(separator, attributes.Where(attr => attr.Value != null).Select(attr => $"{attr.Key}={attr.Value}"))); }
public override void Initialize() { base.Initialize(); this.ForEachChild <View>(x => x.Deactivate(), false); if (!Application.isPlaying) { return; } // TODO: Hardcoded values Height.DirectValue = ElementSize.FromPixels(480f); Width.DirectValue = ElementSize.FromPixels(800f); LayoutChanged(); var height = (int)ActualHeight; var width = (int)ActualWidth; var plane = GameObject.CreatePrimitive(PrimitiveType.Plane); //plane.transform.position = new Vector3(0f, -0.005f, -0.01f); plane.transform.rotation = Quaternion.Euler(90, 180, 0); plane.transform.localScale = new Vector3(width * 0.0001f, 1f, height * 0.0001f); plane.transform.parent = transform; plane.transform.localPosition = new Vector3(0f, 0f, -0.01f); //plane.GetComponent<MeshCollider>().convex = true; var planeRigidbody = plane.AddComponent <Rigidbody>(); planeRigidbody.useGravity = false; planeRigidbody.isKinematic = true; // VRActor needed for mouse / flystick interactions plane.AddComponent <VRActor>().Grabable = false; _vrWebView = plane.AddComponent <VRWebView>(); _vrWebView.Width = (int)(width * 1.5); _vrWebView.Height = (int)(height * 1.5); _vrWebView.MouseInteractionsIn3D = true; }
public static int SizeOf(this ElementSize size) { switch (size) { case ElementSize.Zero: return(0); case ElementSize.OneBit: throw new ArgumentException("size is OneBit", nameof(size)); case ElementSize.OneByte: return(1); case ElementSize.TwoBytes: return(2); case ElementSize.FourBytes: return(4); case ElementSize.EightBytesNonPointer: case ElementSize.EightBytesPointer: return(8); case ElementSize.Composite: throw new ArgumentException("size is Composite", nameof(size)); default: throw new ArgumentException($"Invalid ElementSize: {size}"); } }
public DynamicStructTypeAccessor(ElementSize elementSize, short dataWords, short pointers) : base(elementSize, dataWords, pointers) { }
public VertexElement( ElementType t, int i, ElementSize s ) { Type = t; UsageIndex = i; Size = s; }
private StructAccessor(ElementSize elementSize, short dataWords, short pointers) { this.elementSize = elementSize; this.dataWords = dataWords; this.pointers = pointers; }
private SharpDX.DXGI.Format ConvertType( ElementSize elementSize ) { switch ( elementSize ) { case ElementSize.Float1: return SharpDX.DXGI.Format.R32_Float; case ElementSize.Float2: return SharpDX.DXGI.Format.R32G32_Float; case ElementSize.Float3: return SharpDX.DXGI.Format.R32G32B32_Float; case ElementSize.Float4: return SharpDX.DXGI.Format.R32G32B32A32_Float; default: throw new ArgumentException (); } }
public override FixedSizeList <FixedSizeList <TInner> > CreateList(Pointer pointer, int count, ElementSize elementSize) { if (elementSize != ElementSize.EightBytesPointer) { throw new ArgumentException("Must be created as a list of size " + ElementSize.EightBytesPointer, "elementSize"); } return(CreateList(pointer, count)); }
public virtual FixedSizeList <T> CreateList(Pointer pointer, int count, ElementSize elementSize) { throw new NotImplementedException(); }
public StructAttribute(ElementSize preferredSize, int dataWords = 0, int pointers = 0) { this.PreferredSize = preferredSize; this.DataWords = dataWords; this.Pointers = pointers; }