public override void Render(IRenderContext rc)
    {
        base.Render(rc);
        var sY          = StartPoint.Y * (AssociatedSeries.Inverted ? -1 : 1);
        var eY          = EndPoint.Y * (AssociatedSeries.Inverted ? -1 : 1);
        var actualStart = new DataPoint(StartPoint.X, sY);
        var actualEnd   = new DataPoint(EndPoint.X, eY);

        _screenEndPoint   = Transform(actualEnd);
        _screenStartPoint = Transform(actualStart);
        var d = _screenEndPoint - _screenStartPoint;

        d.Normalize();
        var n = new ScreenVector(d.Y, -d.X);

        const double minimumSegmentLength = 4;

        var dashArray = LineStyle.GetDashArray();

        if (!(StrokeThickness > 0) || LineStyle == LineStyle.None)
        {
            return;
        }
        rc.DrawReducedLine(
            new[] { _screenStartPoint, _screenEndPoint },
            minimumSegmentLength * minimumSegmentLength,
            GetSelectableColor(ActualColor),
            StrokeThickness,
            EdgeRenderingMode,
            dashArray,
            LineJoin);
    }
示例#2
0
 /// <summary>
 /// Transposes the ScreenVector if the series is transposed. Reverses the respective direction if X or Y axis are reversed.
 /// </summary>
 /// <param name="element">The <see cref="ITransposablePlotElement" />.</param>
 /// <param name="vector">The <see cref="ScreenVector" /> to orientate.</param>
 /// <returns>The oriented vector.</returns>
 public static ScreenVector Orientate(this ITransposablePlotElement element, ScreenVector vector)
 {
     vector = new ScreenVector(
         element.XAxis.IsReversed ? -vector.X : vector.X,
         element.YAxis.IsReversed ? -vector.Y : vector.Y);
     return(element.IsTransposed() ? new ScreenVector(-vector.Y, -vector.X) : vector);
 }
示例#3
0
        /// <summary>
        /// Gets the coordinates of the (rotated) background rectangle.
        /// </summary>
        /// <param name="position">The position.</param>
        /// <param name="size">The size.</param>
        /// <param name="padding">The padding.</param>
        /// <param name="rotation">The rotation.</param>
        /// <param name="horizontalAlignment">The horizontal alignment.</param>
        /// <param name="verticalAlignment">The vertical alignment.</param>
        /// <returns>The background rectangle coordinates.</returns>
        private static IList <ScreenPoint> GetTextBounds(
            ScreenPoint position,
            OxySize size,
            OxyThickness padding,
            double rotation,
            HorizontalAlignment horizontalAlignment,
            VerticalAlignment verticalAlignment)
        {
            double left, right, top, bottom;

            switch (horizontalAlignment)
            {
            case HorizontalAlignment.Center:
                left  = -size.Width * 0.5;
                right = -left;
                break;

            case HorizontalAlignment.Right:
                left  = -size.Width;
                right = 0;
                break;

            default:
                left  = 0;
                right = size.Width;
                break;
            }

            switch (verticalAlignment)
            {
            case VerticalAlignment.Middle:
                top    = -size.Height * 0.5;
                bottom = -top;
                break;

            case VerticalAlignment.Bottom:
                top    = -size.Height;
                bottom = 0;
                break;

            default:
                top    = 0;
                bottom = size.Height;
                break;
            }

            double cost    = Math.Cos(rotation / 180 * Math.PI);
            double sint    = Math.Sin(rotation / 180 * Math.PI);
            var    u       = new ScreenVector(cost, sint);
            var    v       = new ScreenVector(-sint, cost);
            var    polygon = new ScreenPoint[4];

            polygon[0] = position + (u * (left - padding.Left)) + (v * (top - padding.Top));
            polygon[1] = position + (u * (right + padding.Right)) + (v * (top - padding.Top));
            polygon[2] = position + (u * (right + padding.Right)) + (v * (bottom + padding.Bottom));
            polygon[3] = position + (u * (left - padding.Left)) + (v * (bottom + padding.Bottom));
            return(polygon);
        }
        /// <summary>
        /// Calculates the starting distance.
        /// </summary>
        private void CalculateStartingDistance()
        {
            if (this.activeTouches.Count < 2)
            {
                this.startingDistance = default(ScreenVector);
                return;
            }

            var loc1 = this.activeTouches.ElementAt(0).LocationInView(this.View).ToScreenPoint();
            var loc2 = this.activeTouches.ElementAt(1).LocationInView(this.View).ToScreenPoint();

            this.startingDistance = loc1 - loc2;
        }
        /// <summary>
        /// Called when a touch gesture is moving.
        /// </summary>
        /// <param name="touches">The touches.</param>
        /// <param name="evt">The event arguments.</param>
        public override void TouchesMoved(NSSet touches, UIEvent evt)
        {
            base.TouchesMoved(touches, evt);

            if (this.activeTouches.Any(touch => touch.Phase == UITouchPhase.Moved))
            {
                // get current and previous location of the first touch point
                var t1  = this.activeTouches.First();
                var l1  = t1.LocationInView(this.View).ToScreenPoint();
                var pl1 = t1.Phase == UITouchPhase.Moved ? t1.PreviousLocationInView(this.View).ToScreenPoint() : l1;

                var l = l1;
                var t = l1 - pl1;
                var s = new ScreenVector(1, 1);

                if (this.activeTouches.Count > 1)
                {
                    // get current and previous location of the second touch point
                    var t2  = this.activeTouches.ElementAt(1);
                    var l2  = t2.LocationInView(this.View).ToScreenPoint();
                    var pl2 = t2.Phase == UITouchPhase.Moved ? t2.PreviousLocationInView(this.View).ToScreenPoint() : l2;

                    var d  = l1 - l2;
                    var pd = pl1 - pl2;

                    if (!this.KeepAspectRatioWhenPinching)
                    {
                        if (!this.AllowPinchPastZero)
                        {
                            // Don't allow fingers crossing in a zoom-out gesture to turn it back into a zoom-in gesture
                            d = this.PreventCross(d);
                        }

                        var scalex = this.CalculateScaleFactor(d.X, pd.X);
                        var scaley = this.CalculateScaleFactor(d.Y, pd.Y);
                        s = new ScreenVector(scalex, scaley);
                    }
                    else
                    {
                        var scale = pd.Length > 0 ? d.Length / pd.Length : 1;
                        s = new ScreenVector(scale, scale);
                    }
                }

                var e = new OxyTouchEventArgs {
                    Position = l, DeltaTranslation = t, DeltaScale = s
                };
                this.TouchEventArgs = e;
                this.State          = UIGestureRecognizerState.Changed;
            }
        }
示例#6
0
            public override void Render(IRenderContext rc)
            {
                // transform to screen coordinates
                var p0 = this.Transform(this.StartPoint);
                var p1 = this.Transform(this.EndPoint);

                var direction = p1 - p0;
                var normal    = new ScreenVector(direction.Y, -direction.X);

                // the end points of the arrow head, scaled by length of arrow
                var p2 = p1 - (direction * 0.2) + (normal * 0.1);
                var p3 = p1 - (direction * 0.2) - (normal * 0.1);

                // draw the line segments
                rc.DrawLineSegments(new[] { p0, p1, p1, p2, p1, p3 }, this.ActualColor, this.StrokeThickness);
            }
        /// <summary>
        /// Applies the "prevent fingers crossing" to the specified vector.
        /// </summary>
        /// <param name="currentDistance">The current distance.</param>
        /// <returns>A vector where the "prevent fingers crossing" is applied.</returns>
        private ScreenVector PreventCross(ScreenVector currentDistance)
        {
            var x = currentDistance.X;
            var y = currentDistance.Y;

            if (DidDirectionChange(x, this.startingDistance.X))
            {
                x = 0;
            }

            if (DidDirectionChange(y, this.startingDistance.Y))
            {
                y = 0;
            }

            return(new ScreenVector(x, y));
        }
示例#8
0
        /// <summary>
        /// Called when a touch gesture is moving.
        /// </summary>
        /// <param name="touches">The touches.</param>
        /// <param name="evt">The event arguments.</param>
        public override void TouchesMoved(NSSet touches, UIEvent evt)
        {
            // it seems to be easier to handle touch events here than using UIPanGesturRecognizer and UIPinchGestureRecognizer
            base.TouchesMoved(touches, evt);

            // convert the touch points to an array
            var ta = touches.ToArray <UITouch>();

            if (ta.Length > 0)
            {
                // get current and previous location of the first touch point
                var t1  = ta[0];
                var l1  = t1.LocationInView(this).ToScreenPoint();
                var pl1 = t1.PreviousLocationInView(this).ToScreenPoint();
                var l   = l1;
                var t   = l1 - pl1;
                var s   = new ScreenVector(1, 1);
                if (ta.Length > 1)
                {
                    // get current and previous location of the second touch point
                    var t2  = ta[1];
                    var l2  = t2.LocationInView(this).ToScreenPoint();
                    var pl2 = t2.PreviousLocationInView(this).ToScreenPoint();
                    var d   = l1 - l2;
                    var pd  = pl1 - pl2;
                    if (!this.KeepAspectRatioWhenPinching)
                    {
                        var scalex = System.Math.Abs(pd.X) > 0 ? System.Math.Abs(d.X / pd.X) : 1;
                        var scaley = System.Math.Abs(pd.Y) > 0 ? System.Math.Abs(d.Y / pd.Y) : 1;
                        s = new ScreenVector(scalex, scaley);
                    }
                    else
                    {
                        var scale = pd.Length > 0 ? d.Length / pd.Length : 1;
                        s = new ScreenVector(scale, scale);
                    }
                }

                var e = new OxyTouchEventArgs {
                    Position = l, DeltaTranslation = t, DeltaScale = s
                };
                this.ActualController.HandleTouchDelta(this, e);
            }
        }
        /// <summary>
        /// Draws the text.
        /// </summary>
        /// <param name="p">The p.</param>
        /// <param name="text">The text.</param>
        /// <param name="c">The c.</param>
        /// <param name="fontFamily">The font family.</param>
        /// <param name="fontSize">Size of the font.</param>
        /// <param name="fontWeight">The font weight.</param>
        /// <param name="rotate">The rotate.</param>
        /// <param name="halign">The horizontal alignment.</param>
        /// <param name="valign">The vertical alignment.</param>
        /// <param name="maxSize">Size of the max.</param>
        public override void DrawText(ScreenPoint p, string text, OxyColor c, string fontFamily, double fontSize, double fontWeight, double rotate, OxyPlot.HorizontalAlignment halign, OxyPlot.VerticalAlignment valign, OxySize?maxSize)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }
            string[] array = Regex.Split(text, "\r\n");
            if (valign == OxyPlot.VerticalAlignment.Bottom)
            {
                for (int i = array.Length - 1; i >= 0; i--)
                {
                    string  text2   = array[i];
                    OxySize oxySize = this.MeasureText(text2, fontFamily, fontSize, fontWeight);
                    this.w.WriteText(p, text2, c, fontFamily, fontSize, fontWeight, rotate, halign, valign);
                    p += new ScreenVector(Math.Sin(rotate / 180.0 * 3.1415926535897931) * oxySize.Height, Math.Cos(rotate / 180.0 * 3.1415926535897931) * oxySize.Height);
                }
                return;
            }
            string[] array2 = array;

            if (text.Contains("."))
            {
                p += new ScreenVector(0.0, 8.0);
            }
            else
            {
                p += new ScreenVector(0.0, 14.0);
            }

            for (int j = 0; j < array2.Length; j++)
            {
                string  text3    = array2[j];
                OxySize oxySize2 = this.MeasureText(text3, fontFamily, fontSize, fontWeight);
                this.w.WriteText(p, text3, c, fontFamily, fontSize, fontWeight, rotate, halign, valign);
                p += new ScreenVector(-Math.Sin(rotate / 180.0 * 3.1415926535897931) * oxySize2.Height, Math.Cos(rotate / 180.0 * 3.1415926535897931) * oxySize2.Height);
            }
        }
示例#10
0
        /// <summary>
        /// Renders the annotation on the specified context.
        /// </summary>
        /// <param name="rc">The render context.</param>
        public override void Render(IRenderContext rc)
        {
            base.Render(rc);

            this.CalculateActualMinimumsMaximums();

            this.screenPoints = this.GetScreenPoints();

            var clippingRectangle = this.GetClippingRect();

            const double MinimumSegmentLength = 4;

            var clippedPoints = new List <ScreenPoint>();
            var dashArray     = this.LineStyle.GetDashArray();

            if (this.StrokeThickness > 0 && this.LineStyle != LineStyle.None)
            {
                rc.DrawClippedLine(
                    clippingRectangle,
                    this.screenPoints,
                    MinimumSegmentLength * MinimumSegmentLength,
                    this.GetSelectableColor(this.Color),
                    this.StrokeThickness,
                    dashArray,
                    this.LineJoin,
                    this.Aliased,
                    null,
                    clippedPoints.AddRange);
            }

            var margin = this.TextMargin;

            this.GetActualTextAlignment(out var ha, out var va);

            if (ha == HorizontalAlignment.Center)
            {
                margin = 0;
            }
            else
            {
                margin *= this.TextLinePosition < 0.5 ? 1 : -1;
            }

            if (GetPointAtRelativeDistance(clippedPoints, this.TextLinePosition, margin, out var position, out var angle))
            {
                if (angle < -90)
                {
                    angle += 180;
                }

                if (angle > 90)
                {
                    angle -= 180;
                }

                switch (this.TextOrientation)
                {
                case AnnotationTextOrientation.Horizontal:
                    angle = 0;
                    break;

                case AnnotationTextOrientation.Vertical:
                    angle = -90;
                    break;
                }

                // Apply 'padding' to the position
                var angleInRadians = angle / 180 * Math.PI;
                var f = 1;

                if (ha == HorizontalAlignment.Right)
                {
                    f = -1;
                }

                if (ha == HorizontalAlignment.Center)
                {
                    f = 0;
                }

                position += new ScreenVector(f * this.TextPadding * Math.Cos(angleInRadians), f * this.TextPadding * Math.Sin(angleInRadians));

                if (!string.IsNullOrEmpty(this.Text))
                {
                    var textPosition = this.GetActualTextPosition(() => position);

                    if (this.TextPosition.IsDefined())
                    {
                        angle = this.TextRotation;
                    }

                    if (this.ClipText)
                    {
                        var cs = new CohenSutherlandClipping(clippingRectangle);
                        if (cs.IsInside(position))
                        {
                            rc.DrawClippedText(
                                clippingRectangle,
                                textPosition,
                                this.Text,
                                this.ActualTextColor,
                                this.ActualFont,
                                this.ActualFontSize,
                                this.ActualFontWeight,
                                angle,
                                this.TextHorizontalAlignment,
                                this.TextVerticalAlignment);
                        }
                    }
                    else
                    {
                        rc.DrawText(
                            textPosition,
                            this.Text,
                            this.ActualTextColor,
                            this.ActualFont,
                            this.ActualFontSize,
                            this.ActualFontWeight,
                            angle,
                            ha,
                            va);
                    }
                }
            }
        }
示例#11
0
        /// <summary>
        /// Renders the arrow annotation.
        /// </summary>
        /// <param name="rc">The render context.</param>
        /// <param name="model">The plot model.</param>
        public override void Render(IRenderContext rc, PlotModel model)
        {
            base.Render(rc, model);

            this.screenEndPoint = this.Transform(this.EndPoint);

            if (this.ArrowDirection.LengthSquared > 0)
            {
                this.screenStartPoint = this.screenEndPoint - this.ArrowDirection;
            }
            else
            {
                this.screenStartPoint = this.Transform(this.StartPoint);
            }

            var d = this.screenEndPoint - this.screenStartPoint;
            d.Normalize();
            var n = new ScreenVector(d.Y, -d.X);

            var p1 = this.screenEndPoint - (d * this.HeadLength * this.StrokeThickness);
            var p2 = p1 + (n * this.HeadWidth * this.StrokeThickness);
            var p3 = p1 - (n * this.HeadWidth * this.StrokeThickness);
            var p4 = p1 + (d * this.Veeness * this.StrokeThickness);

            var clippingRectangle = this.GetClippingRect();
            const double MinimumSegmentLength = 4;

            var dashArray = this.LineStyle.GetDashArray();

            rc.DrawClippedLine(
                clippingRectangle,
                new[] { this.screenStartPoint, p4 },
                MinimumSegmentLength * MinimumSegmentLength,
                this.GetSelectableColor(this.Color),
                this.StrokeThickness,
                dashArray,
                this.LineJoin,
                false);

            rc.DrawClippedPolygon(
                clippingRectangle,
                new[] { p3, this.screenEndPoint, p2, p4 },
                MinimumSegmentLength * MinimumSegmentLength,
                this.GetSelectableColor(this.Color),
                OxyColors.Undefined);

            if (!string.IsNullOrEmpty(this.Text))
            {
                var ha = this.TextHorizontalAlignment;
                var va = this.TextVerticalAlignment;
                if (!this.TextPosition.IsDefined())
                {
                    // automatic position => use automatic alignment
                    ha = d.X < 0 ? HorizontalAlignment.Left : HorizontalAlignment.Right;
                    va = d.Y < 0 ? VerticalAlignment.Top : VerticalAlignment.Bottom;
                }

                var textPoint = this.GetActualTextPosition(() => this.screenStartPoint);
                rc.DrawClippedText(
                    clippingRectangle,
                    textPoint,
                    this.Text,
                    this.ActualTextColor,
                    this.ActualFont,
                    this.ActualFontSize,
                    this.ActualFontWeight,
                    this.TextRotation,
                    ha,
                    va);
            }
        }
        /// <summary>
        /// Gets the coordinates of the (rotated) background rectangle.
        /// </summary>
        /// <param name="position">
        /// The position.
        /// </param>
        /// <param name="size">
        /// The size.
        /// </param>
        /// <param name="padding">
        /// The padding.
        /// </param>
        /// <param name="rotation">
        /// The rotation.
        /// </param>
        /// <param name="horizontalAlignment">
        /// The horizontal alignment.
        /// </param>
        /// <param name="verticalAlignment">
        /// The vertical alignment.
        /// </param>
        /// <returns>
        /// The background rectangle coordinates.
        /// </returns>
        private static IList<ScreenPoint> GetTextBounds(
            ScreenPoint position,
            OxySize size,
            OxyThickness padding,
            double rotation,
            HorizontalAlignment horizontalAlignment,
            VerticalAlignment verticalAlignment)
        {
            double left, right, top, bottom;
            switch (horizontalAlignment)
            {
                case HorizontalAlignment.Center:
                    left = -size.Width * 0.5;
                    right = -left;
                    break;
                case HorizontalAlignment.Right:
                    left = -size.Width;
                    right = 0;
                    break;
                default:
                    left = 0;
                    right = size.Width;
                    break;
            }

            switch (verticalAlignment)
            {
                case VerticalAlignment.Middle:
                    top = -size.Height * 0.5;
                    bottom = -top;
                    break;
                case VerticalAlignment.Bottom:
                    top = -size.Height;
                    bottom = 0;
                    break;
                default:
                    top = 0;
                    bottom = size.Height;
                    break;
            }

            double cost = Math.Cos(rotation / 180 * Math.PI);
            double sint = Math.Sin(rotation / 180 * Math.PI);
            var u = new ScreenVector(cost, sint);
            var v = new ScreenVector(-sint, cost);
            var polygon = new ScreenPoint[4];
            polygon[0] = position + (u * (left - padding.Left)) + (v * (top - padding.Top));
            polygon[1] = position + (u * (right + padding.Right)) + (v * (top - padding.Top));
            polygon[2] = position + (u * (right + padding.Right)) + (v * (bottom + padding.Bottom));
            polygon[3] = position + (u * (left - padding.Left)) + (v * (bottom + padding.Bottom));
            return polygon;
        }
示例#13
0
        /// <summary>
        /// Renders the arrow annotation.
        /// </summary>
        /// <param name="rc">The render context.</param>
        public override void Render(IRenderContext rc)
        {
            base.Render(rc);

            this.screenEndPoint = this.Transform(this.EndPoint);

            if (this.ArrowDirection.LengthSquared > 0)
            {
                this.screenStartPoint = this.screenEndPoint - this.ArrowDirection;
            }
            else
            {
                this.screenStartPoint = this.Transform(this.StartPoint);
            }

            var d = this.screenEndPoint - this.screenStartPoint;

            d.Normalize();
            var n = new ScreenVector(d.Y, -d.X);

            var p1 = this.screenEndPoint - (d * this.HeadLength * this.StrokeThickness);
            var p2 = p1 + (n * this.HeadWidth * this.StrokeThickness);
            var p3 = p1 - (n * this.HeadWidth * this.StrokeThickness);
            var p4 = p1 + (d * this.Veeness * this.StrokeThickness);

            var          clippingRectangle    = this.GetClippingRect();
            const double MinimumSegmentLength = 4;

            var dashArray = this.LineStyle.GetDashArray();

            rc.DrawClippedLine(
                clippingRectangle,
                new[] { this.screenStartPoint, p4 },
                MinimumSegmentLength * MinimumSegmentLength,
                this.GetSelectableColor(this.Color),
                this.StrokeThickness,
                dashArray,
                this.LineJoin,
                false);

            rc.DrawClippedPolygon(
                clippingRectangle,
                new[] { p3, this.screenEndPoint, p2, p4 },
                MinimumSegmentLength * MinimumSegmentLength,
                this.GetSelectableColor(this.Color),
                OxyColors.Undefined);

            if (!string.IsNullOrEmpty(this.Text))
            {
                var ha = this.TextHorizontalAlignment;
                var va = this.TextVerticalAlignment;
                if (!this.TextPosition.IsDefined())
                {
                    // automatic position => use automatic alignment
                    ha = d.X < 0 ? HorizontalAlignment.Left : HorizontalAlignment.Right;
                    va = d.Y < 0 ? VerticalAlignment.Top : VerticalAlignment.Bottom;
                }

                var textPoint = this.GetActualTextPosition(() => this.screenStartPoint);
                rc.DrawClippedText(
                    clippingRectangle,
                    textPoint,
                    this.Text,
                    this.ActualTextColor,
                    this.ActualFont,
                    this.ActualFontSize,
                    this.ActualFontWeight,
                    this.TextRotation,
                    ha,
                    va);
            }
        }
        /// <summary>
        /// Renders the arrow annotation.
        /// </summary>
        /// <param name="rc">
        /// The render context.
        /// </param>
        /// <param name="model">
        /// The plot model.
        /// </param>
        public override void Render(IRenderContext rc, PlotModel model)
        {
            base.Render(rc, model);

            this.screenEndPoint = this.Transform(this.EndPoint);

            if (!this.ArrowDirection.x.IsZero() || !this.ArrowDirection.y.IsZero())
            {
                this.screenStartPoint = this.screenEndPoint - this.ArrowDirection;
            }
            else
            {
                this.screenStartPoint = this.Transform(this.StartPoint);
            }

            var d = this.screenEndPoint - this.screenStartPoint;
            d.Normalize();
            var n = new ScreenVector(d.Y, -d.X);

            var p1 = this.screenEndPoint - (d * this.HeadLength * this.StrokeThickness);
            var p2 = p1 + (n * this.HeadWidth * this.StrokeThickness);
            var p3 = p1 - (n * this.HeadWidth * this.StrokeThickness);
            var p4 = p1 + (d * this.Veeness * this.StrokeThickness);

            OxyRect clippingRect = this.GetClippingRect();
            const double MinimumSegmentLength = 4;

            rc.DrawClippedLine(
                new[] { this.screenStartPoint, p4 },
                clippingRect,
                MinimumSegmentLength * MinimumSegmentLength,
                this.GetSelectableColor(this.Color),
                this.StrokeThickness,
                this.LineStyle,
                this.LineJoin,
                false);

            rc.DrawClippedPolygon(
                new[] { p3, this.screenEndPoint, p2, p4 },
                clippingRect,
                MinimumSegmentLength * MinimumSegmentLength,
                this.GetSelectableColor(this.Color),
                null);

            if (!string.IsNullOrEmpty(this.Text))
            {
                var ha = d.X < 0 ? HorizontalAlignment.Left : HorizontalAlignment.Right;
                var va = d.Y < 0 ? VerticalAlignment.Top : VerticalAlignment.Bottom;

                var textPoint = this.screenStartPoint;
                rc.DrawClippedText(
                    clippingRect,
                    textPoint,
                    this.Text,
                    this.ActualTextColor,
                    this.ActualFont,
                    this.ActualFontSize,
                    this.ActualFontWeight,
                    0,
                    ha,
                    va);
            }
        }
示例#15
0
        /// <summary>
        /// Renders the item label.
        /// </summary>
        /// <param name="rc">The render context</param>
        /// <param name="clippingRect">The clipping rectangle</param>
        /// <param name="item">The item.</param>
        /// <param name="baseValue">The bar item base value.</param>
        /// <param name="topValue">The bar item top value.</param>
        /// <param name="categoryValue">The bar item category value.</param>
        /// <param name="categoryEndValue">The bar item category end value.</param>
        protected void RenderLabel(
            IRenderContext rc,
            OxyRect clippingRect,
            BarItem item,
            double baseValue,
            double topValue,
            double categoryValue,
            double categoryEndValue)
        {
            var s = StringHelper.Format(this.ActualCulture, this.LabelFormatString, item, item.Value);
            HorizontalAlignment ha;
            ScreenPoint         pt;
            var y            = (categoryEndValue + categoryValue) / 2;
            var sign         = Math.Sign(item.Value);
            var marginVector = new ScreenVector(this.LabelMargin, 0) * sign;

            switch (this.LabelPlacement)
            {
            case LabelPlacement.Inside:
                pt           = this.Transform(topValue, y);
                marginVector = -marginVector;
                ha           = (HorizontalAlignment)sign;
                break;

            case LabelPlacement.Outside:
                pt = this.Transform(topValue, y);
                ha = (HorizontalAlignment)(-sign);
                break;

            case LabelPlacement.Middle:
                pt           = this.Transform((topValue + baseValue) / 2, y);
                marginVector = new ScreenVector(0, 0);
                ha           = HorizontalAlignment.Center;
                break;

            case LabelPlacement.Base:
                pt = this.Transform(baseValue, y);
                ha = (HorizontalAlignment)(-sign);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            var va = VerticalAlignment.Middle;

            this.Orientate(ref ha, ref va);

            pt += this.Orientate(marginVector);

            rc.DrawClippedText(
                clippingRect,
                pt,
                s,
                this.ActualTextColor,
                this.ActualFont,
                this.ActualFontSize,
                this.ActualFontWeight,
                0,
                ha,
                va);
        }
示例#16
0
        public static void RenderBoxText(IRenderContext rc, eThemeMode themeMode, OxyRect clippingRect, string text, int textPadding, ScreenPoint sp, ScreenPoint offset, OxyColor color, BoxPosition position = BoxPosition.Left, string font = "Arial")
        {
            OxySize text_size = rc.MeasureText(text, font);

            ScreenPoint down_line_sp = new ScreenPoint(sp.X + offset.X, sp.Y + offset.Y);
            ScreenPoint text_sp      = new ScreenPoint(sp.X + offset.X + TextPadding, sp.Y - text_size.Height - TextPadding + offset.Y);

            IList <ScreenPoint> line = new List <ScreenPoint>();

            line.Add(sp);


            double  box_width  = text_size.Width + 2 * TextPadding;
            double  box_height = text_size.Height + 2 * TextPadding;
            OxyRect rect;

            switch (position)
            {
            case BoxPosition.Left:
                rect = new OxyRect(down_line_sp.X, down_line_sp.Y - box_height, box_width, box_height);
                break;

            case BoxPosition.Middle:
                down_line_sp = new ScreenPoint(down_line_sp.X - offset.X, down_line_sp.Y);
                rect         = new OxyRect(down_line_sp.X - box_width / 2, down_line_sp.Y - box_height, box_width, box_height);

                text_sp = new ScreenPoint(down_line_sp.X - text_size.Width / 2, text_sp.Y);
                break;

            case BoxPosition.Right:
                rect    = new OxyRect(down_line_sp.X - box_width, down_line_sp.Y - box_height, box_width, box_height);
                text_sp = new ScreenPoint(down_line_sp.X - text_size.Width, text_sp.Y);
                break;

            default:
                rect = new OxyRect(0, 0, 0, 0);
                break;
            }

            //ajust
            if (!Pan.ContainsRect(clippingRect, rect))
            {
                ScreenVector vector = Pan.AjustBound(rect, clippingRect);
                rect         = Pan.PanRect(rect, vector);
                down_line_sp = Pan.PanPoint(down_line_sp, vector);
                text_sp      = Pan.PanPoint(text_sp, vector);
            }

            line.Add(down_line_sp);
            rc.DrawLine(line, color);
            if (rect.Width > 0 && rect.Height > 0)
            {
                OxyColor back_color = Convertor.ConvertColorToOxyColor(Helper.DarkBackColor);
                OxyColor fore_color = Convertor.ConvertColorToOxyColor(Helper.LightBackColor);
                switch (themeMode)
                {
                case eThemeMode.Dark:
                    back_color = Convertor.ConvertColorToOxyColor(Helper.DarkBackColor);
                    fore_color = OxyColors.White;
                    break;

                case eThemeMode.Light:
                    back_color = Convertor.ConvertColorToOxyColor(Helper.LightBackColor);
                    fore_color = OxyColors.Black;
                    break;
                }
                rc.DrawRectangle(rect, back_color, fore_color);
                rc.DrawText(text_sp, text, fore_color, font);
            }
        }
示例#17
0
        /// <summary>
        /// Renders the annotation on the specified context.
        /// </summary>
        /// <param name="rc">The render context.</param>
        /// <param name="model">The model.</param>
        public override void Render(IRenderContext rc, PlotModel model)
        {
            base.Render(rc, model);

            this.CalculateActualMinimumsMaximums();

            this.screenPoints = this.GetScreenPoints();

            // clip to the area defined by the axes
            var clippingRectangle = OxyRect.Create(
                this.ClipByXAxis ? this.XAxis.ScreenMin.X : PlotModel.PlotArea.Left,
                this.ClipByYAxis ? this.YAxis.ScreenMin.Y : PlotModel.PlotArea.Top,
                this.ClipByXAxis ? this.XAxis.ScreenMax.X : PlotModel.PlotArea.Right,
                this.ClipByYAxis ? this.YAxis.ScreenMax.Y : PlotModel.PlotArea.Bottom);

            const double MinimumSegmentLength = 4;

            var clippedPoints = new List<ScreenPoint>();
            var dashArray = this.LineStyle.GetDashArray();

            rc.DrawClippedLine(
               clippingRectangle,
               this.screenPoints,
               MinimumSegmentLength * MinimumSegmentLength,
               this.GetSelectableColor(this.Color),
               this.StrokeThickness,
               dashArray,
               this.LineJoin,
               this.aliased,
               null,
               clippedPoints.AddRange);

            ScreenPoint position;
            double angle;
            double margin = this.TextMargin;

            if (this.TextHorizontalAlignment == HorizontalAlignment.Center)
            {
                margin = 0;
            }
            else
            {
                margin *= this.TextLinePosition < 0.5 ? 1 : -1;
            }

            if (GetPointAtRelativeDistance(clippedPoints, this.TextLinePosition, margin, out position, out angle))
            {
                if (angle < -90)
                {
                    angle += 180;
                }

                if (angle > 90)
                {
                    angle -= 180;
                }

                switch (this.TextOrientation)
                {
                    case AnnotationTextOrientation.Horizontal:
                        angle = 0;
                        break;
                    case AnnotationTextOrientation.Vertical:
                        angle = -90;
                        break;
                }

                // Apply 'padding' to the position
                var angleInRadians = angle / 180 * Math.PI;
                var f = 1;

                if (this.TextHorizontalAlignment == HorizontalAlignment.Right)
                {
                    f = -1;
                }

                if (this.TextHorizontalAlignment == HorizontalAlignment.Center)
                {
                    f = 0;
                }

                position += new ScreenVector(f * this.TextPadding * Math.Cos(angleInRadians), f * this.TextPadding * Math.Sin(angleInRadians));

                if (!string.IsNullOrEmpty(this.Text))
                {
                    var textPosition = this.GetActualTextPosition(() => position);
                    
                    if (this.TextPosition.IsDefined())
                    {
                        angle = this.TextRotation;
                    }

                    if (this.ClipText)
                    {
                        var cs = new CohenSutherlandClipping(clippingRectangle);
                        if (cs.IsInside(position))
                        {
                            rc.DrawClippedText(
                                clippingRectangle,
                                textPosition,
                                this.Text,
                                this.ActualTextColor,
                                this.ActualFont,
                                this.ActualFontSize,
                                this.ActualFontWeight,
                                angle,
                                this.TextHorizontalAlignment,
                                this.TextVerticalAlignment);
                        }
                    }
                    else
                    {
                        rc.DrawText(
                           textPosition,
                           this.Text,
                           this.ActualTextColor,
                           this.ActualFont,
                           this.ActualFontSize,
                           this.ActualFontWeight,
                           angle,
                           this.TextHorizontalAlignment,
                           this.TextVerticalAlignment);
                    }
                }
            }
        }
示例#18
0
 /// <summary>
 /// Transposes the ScreenVector if the series is transposed. Reverses the respective direction if X or Y axis are reversed.
 /// </summary>
 /// <param name="vector">The <see cref="ScreenVector" /> to orientate.</param>
 /// <returns>The oriented vector.</returns>
 protected ScreenVector Orientate(ScreenVector vector)
 {
     vector = new ScreenVector(this.XAxis.IsReversed ? -vector.X : vector.X, this.YAxis.IsReversed ? -vector.Y : vector.Y);
     return(this.IsTransposed() ? new ScreenVector(-vector.Y, -vector.X) : vector);
 }
 /// <summary>
 /// Converts a ScreenVector to a Vector.
 /// </summary>
 /// <param name="c">The c.</param>
 /// <returns>A <see cref="Vector" /> instance.</returns>
 public static Vector ToVector(this ScreenVector c)
 {
     return(new Vector(c.X, c.Y));
 }
示例#20
0
 public static ScreenPoint PanPoint(ScreenPoint source, ScreenVector vector)
 {
     return(new ScreenPoint(source.X + vector.X, source.Y + vector.Y));
 }
        /// <summary>
        /// Renders the arrow annotation.
        /// </summary>
        /// <param name="rc">
        /// The render context.
        /// </param>
        /// <param name="model">
        /// The plot model.
        /// </param>
        public override void Render(IRenderContext rc, PlotModel model)
        {
            base.Render(rc, model);

            this.screenEndPoint = this.Transform(this.EndPoint);

            if (!this.ArrowDirection.x.IsZero() || !this.ArrowDirection.y.IsZero())
            {
                this.screenStartPoint = this.screenEndPoint - this.ArrowDirection;
            }
            else
            {
                this.screenStartPoint = this.Transform(this.StartPoint);
            }

            var d = this.screenEndPoint - this.screenStartPoint;

            d.Normalize();
            var n = new ScreenVector(d.Y, -d.X);

            var p1 = this.screenEndPoint - (d * this.HeadLength * this.StrokeThickness);
            var p2 = p1 + (n * this.HeadWidth * this.StrokeThickness);
            var p3 = p1 - (n * this.HeadWidth * this.StrokeThickness);
            var p4 = p1 + (d * this.Veeness * this.StrokeThickness);

            OxyRect      clippingRect         = this.GetClippingRect();
            const double MinimumSegmentLength = 4;

            rc.DrawClippedLine(
                new[] { this.screenStartPoint, p4 },
                clippingRect,
                MinimumSegmentLength * MinimumSegmentLength,
                this.GetSelectableColor(this.Color),
                this.StrokeThickness,
                this.LineStyle,
                this.LineJoin,
                false);

            rc.DrawClippedPolygon(
                new[] { p3, this.screenEndPoint, p2, p4 },
                clippingRect,
                MinimumSegmentLength * MinimumSegmentLength,
                this.GetSelectableColor(this.Color),
                null);

            var ha = d.X < 0 ? HorizontalTextAlign.Left : HorizontalTextAlign.Right;
            var va = d.Y < 0 ? VerticalTextAlign.Top : VerticalTextAlign.Bottom;

            var textPoint = this.screenStartPoint;

            rc.DrawClippedText(
                clippingRect,
                textPoint,
                this.Text,
                this.ActualTextColor,
                this.ActualFont,
                this.ActualFontSize,
                this.ActualFontWeight,
                0,
                ha,
                va);
        }
示例#22
0
        /// <summary>
        /// Renders the annotation on the specified context.
        /// </summary>
        /// <param name="rc">The render context.</param>
        /// <param name="model">The model.</param>
        public override void Render(IRenderContext rc, PlotModel model)
        {
            base.Render(rc, model);

            this.CalculateActualMinimumsMaximums();

            this.screenPoints = this.GetScreenPoints();

            // clip to the area defined by the axes
            var clippingRectangle = OxyRect.Create(
                this.ClipByXAxis ? this.XAxis.ScreenMin.X : PlotModel.PlotArea.Left,
                this.ClipByYAxis ? this.YAxis.ScreenMin.Y : PlotModel.PlotArea.Top,
                this.ClipByXAxis ? this.XAxis.ScreenMax.X : PlotModel.PlotArea.Right,
                this.ClipByYAxis ? this.YAxis.ScreenMax.Y : PlotModel.PlotArea.Bottom);

            const double MinimumSegmentLength = 4;

            var clippedPoints = new List <ScreenPoint>();
            var dashArray     = this.LineStyle.GetDashArray();

            rc.DrawClippedLine(
                clippingRectangle,
                this.screenPoints,
                MinimumSegmentLength * MinimumSegmentLength,
                this.GetSelectableColor(this.Color),
                this.StrokeThickness,
                dashArray,
                this.LineJoin,
                this.aliased,
                null,
                clippedPoints.AddRange);

            ScreenPoint position;
            double      angle;
            double      margin = this.TextMargin;

            if (this.TextHorizontalAlignment == HorizontalAlignment.Center)
            {
                margin = 0;
            }
            else
            {
                margin *= this.TextLinePosition < 0.5 ? 1 : -1;
            }

            if (GetPointAtRelativeDistance(clippedPoints, this.TextLinePosition, margin, out position, out angle))
            {
                if (angle < -90)
                {
                    angle += 180;
                }

                if (angle > 90)
                {
                    angle -= 180;
                }

                switch (this.TextOrientation)
                {
                case AnnotationTextOrientation.Horizontal:
                    angle = 0;
                    break;

                case AnnotationTextOrientation.Vertical:
                    angle = -90;
                    break;
                }

                // Apply 'padding' to the position
                var angleInRadians = angle / 180 * Math.PI;
                var f = 1;

                if (this.TextHorizontalAlignment == HorizontalAlignment.Right)
                {
                    f = -1;
                }

                if (this.TextHorizontalAlignment == HorizontalAlignment.Center)
                {
                    f = 0;
                }

                position += new ScreenVector(f * this.TextPadding * Math.Cos(angleInRadians), f * this.TextPadding * Math.Sin(angleInRadians));

                if (!string.IsNullOrEmpty(this.Text))
                {
                    var textPosition = this.GetActualTextPosition(() => position);

                    if (this.TextPosition.IsDefined())
                    {
                        angle = this.TextRotation;
                    }

                    if (this.ClipText)
                    {
                        var cs = new CohenSutherlandClipping(clippingRectangle);
                        if (cs.IsInside(position))
                        {
                            rc.DrawClippedText(
                                clippingRectangle,
                                textPosition,
                                this.Text,
                                this.ActualTextColor,
                                this.ActualFont,
                                this.ActualFontSize,
                                this.ActualFontWeight,
                                angle,
                                this.TextHorizontalAlignment,
                                this.TextVerticalAlignment);
                        }
                    }
                    else
                    {
                        rc.DrawText(
                            textPosition,
                            this.Text,
                            this.ActualTextColor,
                            this.ActualFont,
                            this.ActualFontSize,
                            this.ActualFontWeight,
                            angle,
                            this.TextHorizontalAlignment,
                            this.TextVerticalAlignment);
                    }
                }
            }
        }
示例#23
0
        /// <summary>
        /// Renders the arrow annotation.
        /// </summary>
        /// <param name="rc">The render context.</param>
        public override void Render(IRenderContext rc)
        {
            base.Render(rc);

            this.screenEndPoint = this.Transform(this.EndPoint);

            if (this.ArrowDirection.LengthSquared > 0)
            {
                this.screenStartPoint = this.screenEndPoint - this.Orientate(this.ArrowDirection);
            }
            else
            {
                this.screenStartPoint = this.Transform(this.StartPoint);
            }

            var d = this.screenEndPoint - this.screenStartPoint;

            d.Normalize();
            var n = new ScreenVector(d.Y, -d.X);

            var p1 = this.screenEndPoint - (d * this.HeadLength * this.StrokeThickness);
            var p2 = p1 + (n * this.HeadWidth * this.StrokeThickness);
            var p3 = p1 - (n * this.HeadWidth * this.StrokeThickness);
            var p4 = p1 + (d * this.Veeness * this.StrokeThickness);

            var          clippingRectangle    = this.GetClippingRect();
            const double MinimumSegmentLength = 4;

            var dashArray = this.LineStyle.GetDashArray();

            if (this.StrokeThickness > 0 && this.LineStyle != LineStyle.None)
            {
                rc.DrawClippedLine(
                    clippingRectangle,
                    new[] { this.screenStartPoint, p4 },
                    MinimumSegmentLength * MinimumSegmentLength,
                    this.GetSelectableColor(this.Color),
                    this.StrokeThickness,
                    dashArray,
                    this.LineJoin,
                    false);

                rc.DrawClippedPolygon(
                    clippingRectangle,
                    new[] { p3, this.screenEndPoint, p2, p4 },
                    MinimumSegmentLength * MinimumSegmentLength,
                    this.GetSelectableColor(this.Color),
                    OxyColors.Undefined);
            }

            if (string.IsNullOrEmpty(this.Text))
            {
                return;
            }

            HorizontalAlignment ha;
            VerticalAlignment   va;

            if (this.TextPosition.IsDefined())
            {
                this.GetActualTextAlignment(out ha, out va);
            }
            else
            {
                var angle   = Math.Atan2(d.Y, d.X);
                var piOver8 = Math.PI / 8;
                if (angle < 3 * piOver8 && angle > -3 * piOver8)
                {
                    ha = HorizontalAlignment.Right;
                }
                else if (angle > 5 * piOver8 || angle < -5 * piOver8)
                {
                    ha = HorizontalAlignment.Left;
                }
                else
                {
                    ha = HorizontalAlignment.Center;
                }

                if (angle > piOver8 && angle < 7 * piOver8)
                {
                    va = VerticalAlignment.Bottom;
                }
                else if (angle < -piOver8 && angle > -7 * piOver8)
                {
                    va = VerticalAlignment.Top;
                }
                else
                {
                    va = VerticalAlignment.Middle;
                }
            }

            var textPoint = this.GetActualTextPosition(() => this.screenStartPoint);

            rc.DrawClippedText(
                clippingRectangle,
                textPoint,
                this.Text,
                this.ActualTextColor,
                this.ActualFont,
                this.ActualFontSize,
                this.ActualFontWeight,
                this.TextRotation,
                ha,
                va);
        }
示例#24
0
 public static OxyRect PanRect(OxyRect rect, ScreenVector vector)
 {
     return(new OxyRect(rect.Left + vector.X, rect.Top + vector.Y, rect.Width, rect.Height));
 }
示例#25
0
        /// <summary>
        /// Draws the text.
        /// </summary>
        /// <param name="p">The p.</param>
        /// <param name="text">The text.</param>
        /// <param name="c">The c.</param>
        /// <param name="fontFamily">The font family.</param>
        /// <param name="fontSize">Size of the font.</param>
        /// <param name="fontWeight">The font weight.</param>
        /// <param name="rotate">The rotate.</param>
        /// <param name="halign">The horizontal alignment.</param>
        /// <param name="valign">The vertical alignment.</param>
        /// <param name="maxSize">Size of the max.</param>
        public override void DrawText(
            ScreenPoint p,
            string text,
            OxyColor c,
            string fontFamily,
            double fontSize,
            double fontWeight,
            double rotate,
            HorizontalAlignment halign,
            VerticalAlignment valign,
            OxySize?maxSize)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            var lines = Regex.Split(text, "\r\n");

            var textSize   = this.MeasureText(text, fontFamily, fontSize, fontWeight);
            var lineHeight = textSize.Height / lines.Length;
            var lineOffset = new ScreenVector(-Math.Sin(rotate / 180.0 * Math.PI) * lineHeight, +Math.Cos(rotate / 180.0 * Math.PI) * lineHeight);

            if (this.UseVerticalTextAlignmentWorkaround)
            {
                // offset the position, and set the valign to neutral value of `Bottom`
                double offsetRatio = valign == VerticalAlignment.Bottom ? (1.0 - lines.Length) : valign == VerticalAlignment.Top ? 1.0 : (1.0 - (lines.Length / 2.0));
                valign = VerticalAlignment.Bottom;

                p += lineOffset * offsetRatio;

                foreach (var line in lines)
                {
                    var size = this.MeasureText(line, fontFamily, fontSize, fontWeight);
                    this.WriteText(p, line, c, fontFamily, fontSize, fontWeight, rotate, halign, valign);

                    p += lineOffset;
                }
            }
            else
            {
                if (valign == VerticalAlignment.Bottom)
                {
                    for (var i = lines.Length - 1; i >= 0; i--)
                    {
                        var line = lines[i];
                        _ = this.MeasureText(line, fontFamily, fontSize, fontWeight);
                        this.WriteText(p, line, c, fontFamily, fontSize, fontWeight, rotate, halign, valign);

                        p -= lineOffset;
                    }
                }
                else
                {
                    foreach (var line in lines)
                    {
                        var size = this.MeasureText(line, fontFamily, fontSize, fontWeight);
                        this.WriteText(p, line, c, fontFamily, fontSize, fontWeight, rotate, halign, valign);

                        p += lineOffset;
                    }
                }
            }
        }
示例#26
0
        private void Loop()
        {
            while (true)
            {
                // GC.Collect();
                gfx.BeginScene();

                gfx.ClearScene();

                if (CheatData.panorama)
                {
                    for (int i = 0; i < 100; i++)
                    {
                        MyBaseAdr = mem.Read <int>(CheatData.bClient + Offsets.New.dwLocalPlayer);
                        mteam     = mem.Read <int>(MyBaseAdr + Offsets.New.m_iTeamNum);
                        mycoords  = mem.Read <Vector3>(MyBaseAdr + Offsets.New.m_vecOrigin);
                        eBaseAdr  = mem.Read <int>(CheatData.bClient + Offsets.New.dwEntityList + (i * Offsets.New.Loop_offset));
                        eteam     = mem.Read <int>(eBaseAdr + Offsets.New.m_iTeamNum);
                        dormant   = mem.Read <bool>(eBaseAdr + Offsets.New.m_bDormant);
                        // glowind = mem.Read<int>(eBaseAdr + Offsets.m_iGlowIndex);
                        hp     = mem.Read <int>(eBaseAdr + Offsets.New.m_iHealth);
                        coords = mem.Read <Vector3>(eBaseAdr + Offsets.New.m_vecOrigin);
                        head   = CalcEnemyHead(eBaseAdr, 8);
                        Gres   = mem.Read <int>(CheatData.bClient + Offsets.New.dwPlayerResource);
                        rank   = mem.Read <int>(Gres + Offsets.New.m_iCompetitiveRanking + i * 4);
                        int radar = mem.Read <int>(CheatData.bClient + Offsets.New.dwRadarBase);
                        name = mem.Read <char>(radar + (i * 50) + 0x204, 50);
                        string n = string.Empty;
                        for (int j = 0; j < 49; j++)
                        {
                            n += name[j];
                        }
                        //
                        //    angles = mem.Read<Vector2>(eBaseAdr + Offsets.m_angEyeAngles);

                        mt = mteam;
                        et = eteam;

                        if (MyBaseAdr == 0x0)
                        {
                            continue;
                        }


                        VMatrix = mem.Read <Matrix4x4>(CheatData.bClient + Offsets.New.dwViewMatrix);
                        ScreenVector sv  = WorldToScreen(coords.X, coords.Y, coords.Z);
                        ScreenVector svh = WorldToScreen(head.X, head.Y, head.Z);
                        if (dormant)
                        {
                            continue;
                        }
                        if (hp == 0)
                        {
                            continue;
                        }

                        if (!sv.Result)
                        {
                            continue;
                        }
                        int ex = (int)sv.X;
                        int ey = (int)sv.Y;
                        int sx = WHwindow.Width / 2;
                        int sy = WHwindow.Height;

                        float h = (svh.Y - sv.Y);
                        float w = 18500 / (float)Vector3.Distance(mycoords, coords);
                        float x = (int)(sv.X - w / 2);
                        float y = (sv.Y);

                        if ((eteam != mteam) && mteam != 1)

                        {
                            if (CheatData.lines_wh)
                            {
                                gfx.DrawLine(sx, sy, ex, ey, 2, new Direct2DColor(pen[0], pen[1], pen[2]));
                            }
                            if (CheatData.hp_wh)
                            {
                                gfx.DrawHorizontalBar(hp, x, y, 2, h, 1, new Direct2DColor(255, 0, 0), new Direct2DColor(0, 0, 0));
                            }

                            if (CheatData.box)
                            {
                                double d = Vector3.Distance(mycoords, coords);
                                if (d < 1f)
                                {
                                    continue;
                                }
                                Drawbox(sv.X, sv.Y, (int)d);
                            }
                            if (CheatData.ranks)
                            {
                                gfx.DrawText(n, svh.X, svh.Y, new Direct2DFont(factory, "Arial", 12), new Direct2DColor(255, 0, 0));


                                gfx.DrawText(Ranks[rank], ex, ey, new Direct2DFont(factory, "Arial", 12), new Direct2DColor(255, 0, 0));
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < 100; i++)
                    {
                        MyBaseAdr = mem.Read <int>(CheatData.bClient + Offsets.Old.dwLocalPlayer);
                        mteam     = mem.Read <int>(MyBaseAdr + Offsets.Old.m_iTeamNum);
                        mycoords  = mem.Read <Vector3>(MyBaseAdr + Offsets.Old.m_vecOrigin);
                        eBaseAdr  = mem.Read <int>(CheatData.bClient + Offsets.Old.dwEntityList + (i * Offsets.New.Loop_offset));
                        eteam     = mem.Read <int>(eBaseAdr + Offsets.Old.m_iTeamNum);
                        dormant   = mem.Read <bool>(eBaseAdr + Offsets.New.m_bDormant);
                        // glowind = mem.Read<int>(eBaseAdr + Offsets.m_iGlowIndex);
                        hp     = mem.Read <int>(eBaseAdr + Offsets.Old.m_iHealth);
                        coords = mem.Read <Vector3>(eBaseAdr + Offsets.Old.m_vecOrigin);
                        head   = CalcEnemyHead(eBaseAdr, 8);
                        Gres   = mem.Read <int>(CheatData.bClient + Offsets.Old.dwPlayerResource);
                        rank   = mem.Read <int>(Gres + Offsets.Old.m_iCompetitiveRanking + i * 4);
                        int radar = mem.Read <int>(CheatData.bClient + Offsets.Old.dwRadarBase);
                        name = mem.Read <char>(radar + (i * 50) + 0x204, 50);
                        string n = string.Empty;
                        for (int j = 0; j < 49; j++)
                        {
                            n += name[j];
                        }
                        //
                        //    angles = mem.Read<Vector2>(eBaseAdr + Offsets.m_angEyeAngles);

                        mt = mteam;
                        et = eteam;

                        if (MyBaseAdr == 0x0)
                        {
                            continue;
                        }


                        VMatrix = mem.Read <Matrix4x4>(CheatData.bClient + Offsets.Old.dwViewMatrix);
                        ScreenVector sv  = WorldToScreen(coords.X, coords.Y, coords.Z);
                        ScreenVector svh = WorldToScreen(head.X, head.Y, head.Z);
                        if (dormant)
                        {
                            continue;
                        }
                        if (hp == 0)
                        {
                            continue;
                        }

                        if (!sv.Result)
                        {
                            continue;
                        }
                        int ex = (int)sv.X;
                        int ey = (int)sv.Y;
                        int sx = WHwindow.Width / 2;
                        int sy = WHwindow.Height;

                        float h = (svh.Y - sv.Y);
                        float w = 18500 / (float)Vector3.Distance(mycoords, coords);
                        float x = (int)(sv.X - w / 2);
                        float y = (sv.Y);

                        if ((eteam != mteam) && mteam != 1)

                        {
                            if (CheatData.lines_wh)
                            {
                                gfx.DrawLine(sx, sy, ex, ey, 2, new Direct2DColor(pen[0], pen[1], pen[2]));
                            }
                            if (CheatData.hp_wh)
                            {
                                gfx.DrawHorizontalBar(hp, x, y, 2, h, 1, new Direct2DColor(255, 0, 0), new Direct2DColor(0, 0, 0));
                            }

                            if (CheatData.box)
                            {
                                double d = Vector3.Distance(mycoords, coords);
                                if (d < 1f)
                                {
                                    continue;
                                }
                                Drawbox(sv.X, sv.Y, (int)d);
                            }
                            if (CheatData.ranks)
                            {
                                gfx.DrawText(n, svh.X, svh.Y, new Direct2DFont(factory, "Arial", 12), new Direct2DColor(255, 0, 0));


                                gfx.DrawText(Ranks[rank], ex, ey, new Direct2DFont(factory, "Arial", 12), new Direct2DColor(255, 0, 0));
                            }
                        }
                    }
                }


                gfx.EndScene();

                //Thread.Sleep(5);
            }
        }