/// <summary>
 /// Initializes a new instance of the <see cref="StackedColumnSeries{TModel, TVisual, TLabel, TDrawingContext}"/> class.
 /// </summary>
 public StackedColumnSeries()
     : base(
         SeriesProperties.Bar | SeriesProperties.PrimaryAxisVerticalOrientation | SeriesProperties.Stacked |
         SeriesProperties.Solid | SeriesProperties.PrefersXStrategyTooltips)
 {
     DataPadding = new LvcPoint(0, 1);
 }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LabelGeometry"/> class.
 /// </summary>
 public LabelGeometry()
     : base(true)
 {
     _textSizeProperty   = RegisterMotionProperty(new FloatMotionProperty(nameof(TextSize), 11));
     _backgroundProperty = RegisterMotionProperty(new ColorMotionProperty(nameof(Background), LvcColor.Empty));
     TransformOrigin     = new LvcPoint(0f, 0f);
 }
Beispiel #3
0
    /// <inheritdoc cref="HoverArea.DistanceTo(LvcPoint)"/>
    public override double DistanceTo(LvcPoint point)
    {
        var cx = X + Width * 0.5;
        var cy = Y + Height * 0.5;

        return(Math.Sqrt(Math.Pow(point.X - cx, 2) + Math.Pow(point.Y - cy, 2)));
    }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ColumnSeries{TModel, TVisual, TLabel, TDrawingContext}"/> class.
 /// </summary>
 protected ColumnSeries()
     : base(
         SeriesProperties.Bar | SeriesProperties.PrimaryAxisVerticalOrientation |
         SeriesProperties.Solid | SeriesProperties.PrefersXStrategyTooltips)
 {
     DataPadding = new LvcPoint(0, 1);
     _isRounded  = typeof(IRoundedRectangleChartPoint <TDrawingContext>).IsAssignableFrom(typeof(TVisual));
 }
Beispiel #5
0
    /// <inheritdoc cref="HoverArea.DistanceTo(LvcPoint)"/>
    public override double DistanceTo(LvcPoint point)
    {
        var a = (StartAngle + EndAngle) * 0.5;
        var r = Radius * 0.5f;

        a *= Math.PI / 180d;

        var y = r * Math.Cos(a);
        var x = r * Math.Sin(a);

        return(Math.Sqrt(Math.Pow(point.X - x, 2) + Math.Pow(point.Y - y, 2)));
    }
Beispiel #6
0
    /// <inheritdoc cref="HoverArea.IsPointerOver(LvcPoint, TooltipFindingStrategy)"/>
    public override bool IsPointerOver(LvcPoint pointerLocation, TooltipFindingStrategy strategy)
    {
        var isInX = pointerLocation.X > X && pointerLocation.X < X + Width;
        var isInY = pointerLocation.Y > Y && pointerLocation.Y < Y + Height; // <-- first time the new vs2022 intelisense surprises me 🎉🎉, this line was generated automatically

        return(strategy switch
        {
            TooltipFindingStrategy.CompareOnlyX => isInX,
            TooltipFindingStrategy.CompareOnlyY => isInY,        // this line too!
            TooltipFindingStrategy.CompareAll => isInX && isInY, // but it was not able to complete this one :(
            TooltipFindingStrategy.Automatic => throw new Exception($"The strategy {strategy} is not supported."),
            _ => throw new NotImplementedException()
        });
        /// <inheritdoc cref="GetDistanceToPoint(LvcPoint, TooltipFindingStrategy)"/>
        public override float GetDistanceToPoint(LvcPoint point, TooltipFindingStrategy strategy)
        {
            var dx = point.X - (X + Width * 0.5f);
            var dy = point.Y - (Y + Height * 0.5f);

            // compiler bug?
#pragma warning disable IDE0072 // Add missing cases
            return(strategy switch
#pragma warning restore IDE0072 // Add missing cases
            {
                TooltipFindingStrategy.CompareAll => (float)Math.Sqrt(Math.Pow(dx, 2) + Math.Pow(dy, 2)),
                TooltipFindingStrategy.CompareOnlyX => Math.Abs(dx),
                TooltipFindingStrategy.CompareOnlyY => Math.Abs(dy),
                TooltipFindingStrategy.Automatic or _ => throw new Exception($"The strategy {strategy} is not supported.")
            });
Beispiel #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PolarScaler"/> class.
        /// </summary>
        /// <param name="drawMagrinLocation">The draw margin location.</param>
        /// <param name="drawMarginSize">Size of the draw margin.</param>
        /// <param name="radiusAxis">The radius axis.</param>
        /// <param name="angleAxis">The angle axis.</param>
        /// <param name="innerRadius">The inner radius.</param>
        /// <param name="initialRotation">The initial rotation.</param>
        /// <param name="totalAngle">The total angle.</param>
        /// <param name="usePreviousScale">Indicates if the scaler should be built based on the previous known data.</param>
        /// <exception cref="Exception">The axis is not ready to be scaled.</exception>
        public PolarScaler(
            LvcPoint drawMagrinLocation,
            LvcSize drawMarginSize,
            IPolarAxis angleAxis,
            IPolarAxis radiusAxis,
            float innerRadius,
            float initialRotation,
            float totalAngle,
            bool usePreviousScale = false)
        {
            var actualAngleBounds        = usePreviousScale ? angleAxis.PreviousDataBounds : angleAxis.DataBounds;
            var actualAngleVisibleBounds = usePreviousScale ? angleAxis.PreviousVisibleDataBounds : angleAxis.VisibleDataBounds;

            var actualRadiusBounds        = usePreviousScale ? radiusAxis.PreviousDataBounds : radiusAxis.DataBounds;
            var actualRadiusVisibleBounds = usePreviousScale ? radiusAxis.PreviousVisibleDataBounds : radiusAxis.VisibleDataBounds;

            if (actualAngleBounds is null || actualAngleVisibleBounds is null)
            {
                throw new Exception("angle bounds not found");
            }
            if (actualRadiusBounds is null || actualRadiusVisibleBounds is null)
            {
                throw new Exception("radius bounds not found");
            }

            CenterX = drawMagrinLocation.X + drawMarginSize.Width * 0.5f;
            CenterY = drawMagrinLocation.Y + drawMarginSize.Height * 0.5f;

            MinRadius    = actualRadiusVisibleBounds.Min;
            MaxRadius    = actualRadiusVisibleBounds.Max;
            _deltaRadius = MaxRadius - MinRadius;

            var minDimension = drawMarginSize.Width < drawMarginSize.Height ? drawMarginSize.Width : drawMarginSize.Height;

            _innerRadiusOffset = innerRadius; // innerRadius;
            InnerRadius        = innerRadius;
            _outerRadiusOffset = 0;           //drawMagrinLocation.X; // We should also check for the top, right and bottom bounds.
            _scalableRadius    = minDimension * 0.5 - _innerRadiusOffset - _outerRadiusOffset;

            MinAngle       = actualAngleBounds.Min;
            MaxAngle       = actualAngleBounds.Max;
            _deltaAngleVal = MaxAngle - MinAngle;

            _initialRotation = initialRotation;
            _circumference   = totalAngle;
        }
Beispiel #9
0
    /// <inheritdoc cref="HoverArea.IsPointerOver(LvcPoint, TooltipFindingStrategy)"/>
    public override bool IsPointerOver(LvcPoint pointerLocation, TooltipFindingStrategy strategy)
    {
        var startAngle = StartAngle % 360;
        // -0.01 is a work around to avoid the case where the last slice (360) would be converted to 0 also
        var endAngle = (EndAngle - 0.01) % 360;

        var dx   = CenterX - pointerLocation.X;
        var dy   = CenterY - pointerLocation.Y;
        var beta = Math.Atan(dy / dx) * (180 / Math.PI);

        if ((dx > 0 && dy < 0) || (dx > 0 && dy > 0))
        {
            beta += 180;
        }
        if (dx < 0 && dy > 0)
        {
            beta += 360;
        }

        var r = Math.Sqrt(Math.Pow(dx, 2) + Math.Pow(dy, 2));

        return(startAngle <= beta && endAngle >= beta && r < Radius); // previously -> startAngle <= beta && endAngle >= beta && r < Radius ? 0 : float.MaxValue;
    }
Beispiel #10
0
 /// <inheritdoc cref="IMapFactory{TDrawingContext}.Zoom(LvcPoint, ZoomDirection)"/>
 public void Zoom(LvcPoint pivot, ZoomDirection direction)
 {
     // not implemented yet.
 }
Beispiel #11
0
 /// <inheritdoc cref="IMapFactory{TDrawingContext}.Pan(LvcPoint)"/>
 public void Pan(LvcPoint delta)
 {
     // not implemented yet.
 }
Beispiel #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PanGestureEventArgs"/> class.
 /// </summary>
 public PanGestureEventArgs(LvcPoint delta)
 {
     Delta   = delta;
     Handled = false;
 }
Beispiel #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ZoomOnPointerView"/> command.
 /// </summary>
 /// <param name="pivot">The pivot.</param>
 /// <param name="direction">The direction.</param>
 public ZoomOnPointerView(LvcPoint pivot, ZoomDirection direction)
 {
     Pivot     = pivot;
     Direction = direction;
 }
Beispiel #14
0
 /// <summary>
 /// Determines whether the area is trigger by the specified point in the user interface.
 /// </summary>
 /// <param name="point">The point.</param>
 /// <param name="strategy">The strategy.</param>
 /// <returns>
 ///   <c>true</c> if [is trigger by] [the specified point]; otherwise, <c>false</c>.
 /// </returns>
 public abstract float GetDistanceToPoint(LvcPoint point, TooltipFindingStrategy strategy);
Beispiel #15
0
    /// <summary>
    /// Initializes a new instance of the <see cref="Scaler"/> class.
    /// </summary>
    /// <param name="drawMagrinLocation">The draw margin location.</param>
    /// <param name="drawMarginSize">Size of the draw margin.</param>
    /// <param name="axis">The axis.</param>
    /// <param name="usePreviousScale">Indicates if the scaler should be built based on the previous known data.</param>
    /// <param name="bounds">Indicates the bounds to use.</param>
    /// <exception cref="Exception">The axis is not ready to be scaled.</exception>
    public Scaler(
        LvcPoint drawMagrinLocation, LvcSize drawMarginSize, ICartesianAxis axis, bool usePreviousScale = false, Bounds?bounds = null)
    {
        if (axis.Orientation == AxisOrientation.Unknown)
        {
            throw new Exception("The axis is not ready to be scaled.");
        }

        _orientation = axis.Orientation;

        var actualBounds        = usePreviousScale ? axis.PreviousDataBounds : axis.DataBounds;
        var actualVisibleBounds = usePreviousScale ? axis.PreviousVisibleDataBounds : axis.VisibleDataBounds;
        var maxLimit            = usePreviousScale ? axis.PreviousMaxLimit : axis.MaxLimit;
        var minLimit            = usePreviousScale ? axis.PreviousMinLimit : axis.MinLimit;

        if (bounds != null)
        {
            actualBounds        = bounds;
            actualVisibleBounds = bounds;
        }

        if (actualBounds is null || actualVisibleBounds is null)
        {
            throw new Exception("bounds not found");
        }

        if (double.IsInfinity(actualBounds.Delta) || double.IsInfinity(actualVisibleBounds.Delta))
        {
            _maxVal   = 0;
            _minVal   = 0;
            _deltaVal = 0;

            if (axis.Orientation == AxisOrientation.X)
            {
                _minPx   = drawMagrinLocation.X;
                _maxPx   = drawMagrinLocation.X + drawMarginSize.Width;
                _deltaPx = _maxPx - _minPx;
            }
            else
            {
                _minPx   = drawMagrinLocation.Y;
                _maxPx   = drawMagrinLocation.Y + drawMarginSize.Height;
                _deltaPx = _maxPx - _minPx;
            }

            _m    = 0;
            _mInv = 0;

            return;
        }

        if (axis.Orientation == AxisOrientation.X)
        {
            _minPx   = drawMagrinLocation.X;
            _maxPx   = drawMagrinLocation.X + drawMarginSize.Width;
            _deltaPx = _maxPx - _minPx;

            _maxVal = axis.IsInverted ? actualBounds.Min : actualBounds.Max;
            _minVal = axis.IsInverted ? actualBounds.Max : actualBounds.Min;

            if (maxLimit is not null || minLimit is not null)
            {
                _maxVal = axis.IsInverted ? minLimit ?? _minVal : maxLimit ?? _maxVal;
                _minVal = axis.IsInverted ? maxLimit ?? _maxVal : minLimit ?? _minVal;
            }
            else
            {
                var visibleMax = axis.IsInverted ? actualVisibleBounds.Min : actualVisibleBounds.Max;
                var visibleMin = axis.IsInverted ? actualVisibleBounds.Max : actualVisibleBounds.Min;

                if (visibleMax != _maxVal || visibleMin != _minVal)
                {
                    _maxVal = visibleMax;
                    _minVal = visibleMin;
                }
            }

            _deltaVal = _maxVal - _minVal;
        }
Beispiel #16
0
 public BezierData(LvcPoint point)
 {
     Point1 = point;
     Point2 = point;
     Point3 = point;
 }
Beispiel #17
0
 /// <summary>
 /// Determines whether the pointer is over the area.
 /// </summary>
 /// <param name="pointerLocation">The pointer location.</param>
 /// <param name="strategy">The strategy.</param>
 /// <returns></returns>
 public abstract bool IsPointerOver(LvcPoint pointerLocation, TooltipFindingStrategy strategy);
 /// <summary>
 /// Initializes a new instance of the <see cref="LvcRectangle"/> struct.
 /// </summary>
 /// <param name="location"></param>
 /// <param name="size"></param>
 public LvcRectangle(LvcPoint location, LvcSize size)
 {
     Location = location;
     Size     = size;
     IsEmpty  = false;
 }
 /// <summary>
 /// Gets the distance to a given point.
 /// </summary>
 /// <param name="point">The point to calculate the distance to.</param>
 /// <returns>The distance in pixels.</returns>
 public double DistanceTo(LvcPoint point)
 {
     return(Context.HoverArea?.DistanceTo(point) ?? double.NaN);
 }
Beispiel #20
0
 public BezierData(LvcPoint point)
 {
     Point1 = point;
     Point2 = point;
     Point3 = point;
 }
 private LvcRectangle(bool empty)
 {
     Location = new LvcPoint();
     Size     = new LvcSize();
     IsEmpty  = empty;
 }
Beispiel #22
0
 /// <summary>
 /// Gets the distance to a given point.
 /// </summary>
 /// <param name="point">The point to calculate the distance to.</param>
 /// <returns>The distance in pixels.</returns>
 public abstract double DistanceTo(LvcPoint point);