/// <summary> /// Initializes static members of the <see cref="CategoryAxis"/> class. /// </summary> static CategoryAxis() { PositionProperty.OverrideMetadata(typeof(CategoryAxis), new PropertyMetadata(Axes.AxisPosition.Bottom, DataChanged)); MinimumPaddingProperty.OverrideMetadata(typeof(CategoryAxis), new PropertyMetadata(0.0, DataChanged)); MaximumPaddingProperty.OverrideMetadata(typeof(CategoryAxis), new PropertyMetadata(0.0, DataChanged)); MajorStepProperty.OverrideMetadata(typeof(CategoryAxis), new PropertyMetadata(1.0, DataChanged)); }
/// <summary> /// Initializes static members of the <see cref="DateTimeAxis" /> class. /// </summary> static DateTimeAxis() { PositionProperty.OverrideDefaultValue <DateTimeAxis>(AxisPosition.Bottom); PositionProperty.Changed.AddClassHandler <DateTimeAxis>(AppearanceChanged); CalendarWeekRuleProperty.Changed.AddClassHandler <DateTimeAxis>(DataChanged); FirstDayOfWeekProperty.Changed.AddClassHandler <DateTimeAxis>(DataChanged); MinorIntervalTypeProperty.Changed.AddClassHandler <DateTimeAxis>(DataChanged); }
/// <summary> /// Initializes static members of the <see cref = "MagnitudeAxis" /> class. /// </summary> static MagnitudeAxis() { MajorGridlineStyleProperty.OverrideMetadata(typeof(MagnitudeAxis), new PropertyMetadata(LineStyle.Solid)); MinorGridlineStyleProperty.OverrideMetadata(typeof(MagnitudeAxis), new PropertyMetadata(LineStyle.Solid)); PositionProperty.OverrideMetadata(typeof(MagnitudeAxis), new PropertyMetadata(AxisPosition.None, AppearanceChanged)); IsPanEnabledProperty.OverrideMetadata(typeof(MagnitudeAxis), new PropertyMetadata(false)); IsZoomEnabledProperty.OverrideMetadata(typeof(MagnitudeAxis), new PropertyMetadata(false)); }
/// <summary> /// Initializes static members of the <see cref = "MagnitudeAxis" /> class. /// </summary> static MagnitudeAxis() { MajorGridlineStyleProperty.OverrideDefaultValue <MagnitudeAxis>(LineStyle.Solid); MinorGridlineStyleProperty.OverrideDefaultValue <MagnitudeAxis>(LineStyle.Solid); PositionProperty.OverrideDefaultValue <MagnitudeAxis>(AxisPosition.None); PositionProperty.Changed.AddClassHandler <MagnitudeAxis>(AppearanceChanged); IsPanEnabledProperty.OverrideDefaultValue <MagnitudeAxis>(false); IsZoomEnabledProperty.OverrideDefaultValue <MagnitudeAxis>(false); }
private static bool CheckDetection(string side, Collider2D colliderObject) { _colliderObjectProperty = colliderObject.transform.GetComponent <PositionProperty>(); if (_colliderObjectProperty != null) { return(side == _colliderObjectProperty.tag); } return(side.Equals(colliderObject.name)); }
/// <summary> /// Initializes static members of the <see cref = "AngleAxis" /> class. /// </summary> static AngleAxis() { MajorGridlineStyleProperty.OverrideMetadata(typeof(AngleAxis), new StyledPropertyMetadata <LineStyle>(LineStyle.Solid)); MinorGridlineStyleProperty.OverrideMetadata(typeof(AngleAxis), new StyledPropertyMetadata <LineStyle>(LineStyle.Solid)); PositionProperty.OverrideMetadata(typeof(AngleAxis), new StyledPropertyMetadata <AxisPosition>(AxisPosition.None)); TickStyleProperty.OverrideMetadata(typeof(AngleAxis), new StyledPropertyMetadata <TickStyle>(TickStyle.None)); IsPanEnabledProperty.OverrideMetadata(typeof(AngleAxis), new StyledPropertyMetadata <bool>(false)); IsZoomEnabledProperty.OverrideMetadata(typeof(AngleAxis), new StyledPropertyMetadata <bool>(false)); StartAngleProperty.Changed.AddClassHandler <AngleAxis>(AppearanceChanged); EndAngleProperty.Changed.AddClassHandler <AngleAxis>(AppearanceChanged); PositionProperty.Changed.AddClassHandler <AngleAxis>(AppearanceChanged); TickStyleProperty.Changed.AddClassHandler <AngleAxis>(AppearanceChanged); }
/// <inheritdoc /> protected override Size ArrangeOverride(Size finalSize) { // this is the bounds where items are visisble double startPosition = MinPosition.HasValue && !DisplayAllItems ? MinPosition.Value : Minimum; double endPosition = MaxPosition.HasValue && !DisplayAllItems ? MaxPosition.Value : Maximum; // go through each marker control and layout on the timeline foreach (UIElement childControl in Children) { DependencyObject child; if (childControl is ContentPresenter) { ContentPresenter presenter = childControl as ContentPresenter; child = presenter.Content as DependencyObject; } else { child = childControl; } double childPosition = child != null?GetPosition(child) : (double)PositionProperty.GetMetadata(typeof(PositionedItemsPanel)).DefaultValue; // make sure the child is within the range if (childPosition < startPosition || childPosition > endPosition) { // don't display the marker childControl.Arrange(new Rect(0, 0, 0, 0)); } else { double relativePosition = (childPosition - Minimum) / (Maximum - Minimum); // calculate the top position, center the item vertically double top = (finalSize.Height - childControl.DesiredSize.Height) / 2; // calculate the left position, first get the pixel position double left = relativePosition * finalSize.Width; // next adjust the position so the center of the control // note that the control can overhang the left or right side of the timeline left -= (childControl.DesiredSize.Width / 2); // display the marker childControl.Arrange(new Rect(left, top, childControl.DesiredSize.Width, childControl.DesiredSize.Height)); } } return(base.ArrangeOverride(finalSize)); }
/// <summary> /// Initializes static members of the <see cref="CategoryAxis" /> class. /// </summary> static CategoryAxis() { PositionProperty.OverrideMetadata(typeof(CategoryAxis), new StyledPropertyMetadata <Axes.AxisPosition>(Axes.AxisPosition.Bottom)); MinimumPaddingProperty.OverrideMetadata(typeof(CategoryAxis), new StyledPropertyMetadata <double>(0.0)); MaximumPaddingProperty.OverrideMetadata(typeof(CategoryAxis), new StyledPropertyMetadata <double>(0.0)); MajorStepProperty.OverrideMetadata(typeof(CategoryAxis), new StyledPropertyMetadata <double>(1.0)); IsTickCenteredProperty.Changed.AddClassHandler <CategoryAxis>(DataChanged); ItemsProperty.Changed.AddClassHandler <CategoryAxis>(DataChanged); LabelFieldProperty.Changed.AddClassHandler <CategoryAxis>(DataChanged); LabelsProperty.Changed.AddClassHandler <CategoryAxis>(DataChanged); PositionProperty.Changed.AddClassHandler <CategoryAxis>(DataChanged); MinimumPaddingProperty.Changed.AddClassHandler <CategoryAxis>(DataChanged); MaximumPaddingProperty.Changed.AddClassHandler <CategoryAxis>(DataChanged); MajorStepProperty.Changed.AddClassHandler <CategoryAxis>(DataChanged); }
/// <summary> /// Initializes static members of the <see cref="DateTimeAxis" /> class. /// </summary> static DateTimeAxis() { PositionProperty.OverrideMetadata(typeof(DateTimeAxis), new PropertyMetadata(AxisPosition.Bottom, AppearanceChanged)); }
set => SetValue(PositionProperty, value);
set => this.SetLocalValue(PositionProperty, 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; } }
/// <summary> /// Create range position from a range or cell address. /// </summary> /// <param name="address">Address to locate the range position.</param> /// <exception cref="ArgumentException">Throw when specified address is invalid.</exception> public RangePosition(string address) { this.positionProperties = 0; Match m = RGUtility.RangeReferenceRegex.Match(address); if (!m.Success) { m = RGUtility.SingleAbsoulteRangeRegex.Match(address); } if (!m.Success && CellPosition.IsValidAddress(address)) { var pos = new CellPosition(address); this.row = pos.Row; this.col = pos.Col; this.rows = 1; this.cols = 1; this.StartRowProperty = pos.RowProperty; this.StartColumnProperty = pos.ColumnProperty; this.EndRowProperty = pos.RowProperty; this.EndColumnProperty = pos.ColumnProperty; } else { if (!m.Success //|| (m.Groups["to_col"].Length <= 0 || m.Groups["to_row"].Length <= 0 //|| m.Groups["from_col"].Length <= 0 || m.Groups["from_row"].Length <= 0) ) { throw new ArgumentException("range is invalid: " + address); } int fromCol = 0, fromRow = 0, toCol = 0, toRow = 0; bool fullRows = false, fullCols = false; if (m.Groups["from_row"].Success) { if (!int.TryParse(m.Groups["from_row"].Value, out fromRow)) { throw new ArgumentException("range is invalid: " + address); } fromRow--; } else { fullRows = true; } if (!fullRows && m.Groups["to_row"].Success) { if (!int.TryParse(m.Groups["to_row"].Value, out toRow)) { throw new ArgumentException("range is invalid: " + address); } toRow--; } if (m.Groups["from_col"].Success) { fromCol = RGUtility.GetNumberOfChar(m.Groups["from_col"].Value); } else { fullCols = true; } if (!fullCols && m.Groups["to_col"].Success) { toCol = RGUtility.GetNumberOfChar(m.Groups["to_col"].Value); } if (fullCols) { this.row = Math.Min(fromRow, toRow); this.rows = Math.Max(fromRow, toRow) - this.row + 1; this.col = 0; this.cols = -1; } else if (fullRows) { this.row = 0; this.rows = -1; this.col = Math.Min(fromCol, toCol); this.cols = Math.Max(fromCol, toCol) - this.col + 1; } else { this.row = Math.Min(fromRow, toRow); this.col = Math.Min(fromCol, toCol); this.rows = Math.Max(fromRow, toRow) - this.row + 1; this.cols = Math.Max(fromCol, toCol) - this.col + 1; } if (m.Groups["abs_from_row"].Success) { this.positionProperties |= PositionAbsoluteBits.StartRow; } if (m.Groups["abs_from_col"].Success) { this.positionProperties |= PositionAbsoluteBits.StartCol; } if (m.Groups["abs_to_row"].Success) { this.positionProperties |= PositionAbsoluteBits.EndRow; } if (m.Groups["abs_to_col"].Success) { this.positionProperties |= PositionAbsoluteBits.EndCol; } } }
get => (TimeSpan)GetValue(PositionProperty); set => SetValue(PositionProperty, value);
public void SetUp() { containingObject = new GameObject(); subject = containingObject.AddComponent <PositionProperty>(); }