static LinearDimension() { FlowDirectionProperty.AddOwner( typeof(LinearDimension), new FrameworkPropertyMetadata( default(FlowDirection), FrameworkPropertyMetadataOptions.AffectsMeasure, OnFlowDirectionChanged)); P1Property.AddOwner( typeof(LinearDimension), new FrameworkPropertyMetadata( new Point(double.NaN, double.NaN), FrameworkPropertyMetadataOptions.AffectsMeasure, OnP1Changed)); P2Property.AddOwner( typeof(LinearDimension), new FrameworkPropertyMetadata( new Point(double.NaN, double.NaN), FrameworkPropertyMetadataOptions.AffectsMeasure, OnP2Changed)); OffsetPointProperty.AddOwner( typeof(LinearDimension), new FrameworkPropertyMetadata( new Point(double.NaN, double.NaN), FrameworkPropertyMetadataOptions.AffectsMeasure, OnOffsetPointChanged)); OffsetProperty.AddOwner( typeof(LinearDimension), new FrameworkPropertyMetadata( 12.0, FrameworkPropertyMetadataOptions.AffectsMeasure, OnOffsetChanged)); OffsetDirectionProperty.AddOwner( typeof(LinearDimension), new FrameworkPropertyMetadata( new Vector(double.NaN, double.NaN), FrameworkPropertyMetadataOptions.AffectsMeasure, OnOffsetDirectionChanged)); ScaleProperty.AddOwner( typeof(LinearDimension), new FrameworkPropertyMetadata( 1.0, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender, OnScaleChanged)); DefaultStyleKeyProperty.OverrideMetadata( typeof(LinearDimension), new FrameworkPropertyMetadata(typeof(LinearDimension))); }
public LineModel DeepCopy() { LineModel lineModel = new LineModel { Guid = Guid, DisplayName = DisplayName, LineGameObject = LineGameObject, Layer = Layer, Shape = Shape, Gradient = Gradient, WidthCurve = WidthCurve, IsEmissionEnabled = IsEmissionEnabled, EmissionIntensity = EmissionIntensity, EmissionColor = EmissionColor, EmissionProperty = EmissionProperty.DeepCopy(), ScaleProperty = ScaleProperty.DeepCopy(), KochLineProperty = KochLineProperty.DeepCopy(), KochTrailProperty = KochTrailProperty.DeepCopy(), PhyllotaxisProperty = PhyllotaxisProperty.DeepCopy() }; return(lineModel); }
get => (double)GetValue(ScaleProperty); set => SetValue(ScaleProperty, value);
set => SetValue(ScaleProperty, value);
set => this.SetValue(ScaleProperty, value);
/// <summary> /// Updates rect transform. /// </summary> private void UpdateRectTransform() { if (GameObject == null) { return; } if (!PivotProperty.IsUndefined(this)) { RectTransform.pivot = Pivot; } if (!RotationProperty.IsUndefined(this)) { RectTransform.localRotation = Rotation; } // update rectTransform // horizontal alignment and positioning var width = OverrideWidth ?? (Width ?? ElementSize.DefaultLayout); var height = OverrideHeight ?? (Height ?? ElementSize.DefaultLayout); float xMin = 0f; float xMax = 0f; float offsetMinX = 0f; float offsetMaxX = 0f; if (Alignment.HasFlag(ElementAlignment.Left)) { xMin = 0f; xMax = width.Percent; offsetMinX = 0f; offsetMaxX = width.Pixels; } else if (Alignment.HasFlag(ElementAlignment.Right)) { xMin = 1f - width.Percent; xMax = 1f; offsetMinX = -width.Pixels; offsetMaxX = 0f; } else { xMin = 0.5f - width.Percent / 2f; xMax = 0.5f + width.Percent / 2f; offsetMinX = -width.Pixels / 2f; offsetMaxX = width.Pixels / 2f; } // vertical alignment float yMin = 0f; float yMax = 0f; float offsetMinY = 0f; float offsetMaxY = 0f; if (Alignment.HasFlag(ElementAlignment.Top)) { yMin = 1f - height.Percent; yMax = 1f; offsetMinY = -height.Pixels; offsetMaxY = 0f; } else if (Alignment.HasFlag(ElementAlignment.Bottom)) { yMin = 0f; yMax = height.Percent; offsetMinY = 0f; offsetMaxY = height.Pixels; } else { yMin = 0.5f - height.Percent / 2f; yMax = 0.5f + height.Percent / 2f; offsetMinY = -height.Pixels / 2f; offsetMaxY = height.Pixels / 2f; } var margin = Margin ?? ElementMargin.Default; RectTransform.anchorMin = new Vector2(xMin + margin.Left.Percent, yMin + margin.Bottom.Percent); RectTransform.anchorMax = new Vector2(xMax - margin.Right.Percent, yMax - margin.Top.Percent); // positioning and margins var offset = Offset?.GetActualOffset(ActualWidth, ActualHeight) ?? ElementMargin.Default; var offsetFromParent = OffsetFromParent?.GetActualOffset(ActualWidth, ActualHeight) ?? ElementMargin.Default; RectTransform.offsetMin = new Vector2( offsetMinX + margin.Left.Pixels + offset.Left.Pixels - offset.Right.Pixels + offsetFromParent.Left.Pixels - offsetFromParent.Right.Pixels, offsetMinY + margin.Bottom.Pixels - offset.Top.Pixels + offset.Bottom.Pixels - offsetFromParent.Top.Pixels + offsetFromParent.Bottom.Pixels); RectTransform.offsetMax = new Vector2( offsetMaxX - margin.Right.Pixels + offset.Left.Pixels - offset.Right.Pixels + offsetFromParent.Left.Pixels - offsetFromParent.Right.Pixels, offsetMaxY - margin.Top.Pixels - offset.Top.Pixels + offset.Bottom.Pixels - offsetFromParent.Top.Pixels + offsetFromParent.Bottom.Pixels); RectTransform.anchoredPosition = new Vector2( RectTransform.offsetMin.x / 2.0f + RectTransform.offsetMax.x / 2.0f, RectTransform.offsetMin.y / 2.0f + RectTransform.offsetMax.y / 2.0f); if (!PositionProperty.IsUndefined(this)) { RectTransform.localPosition = Position; } if (!ScaleProperty.IsUndefined(this)) { RectTransform.localScale = Scale; } }