Exemplo n.º 1
0
        private void ArrangeRadially(double angle, Point center, double radius)
        {
            Point location = RadialGaugePanel.CreateRotatedPoint(angle, radius, center, RadRadialGauge.GetIndicatorRadiusScale(this));

            Canvas.SetLeft(this.visualElement, location.X);
            Canvas.SetTop(this.visualElement, location.Y);
        }
Exemplo n.º 2
0
        private void UpdateCore()
        {
            var    startAngle = RadialGaugePanel.ConvertDegreesToRadians(this.MinAngle);
            double angle      = RadialGaugePanel.CalculateAngle(this.CreateCalculateAngleContext(this.ActualValue));

            if (startAngle > angle)
            {
                var tmp = startAngle;
                startAngle = angle;
                angle      = tmp;
            }

            this.figure.StartPoint = RadialGaugePanel.CreateRotatedPoint(startAngle, this.Radius, this.Center, this.RadiusScale);
            RadialBarGaugeIndicator.UpdateArc(this.CreateUpdateArcContext(angle, startAngle / Math.PI * 180));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Updates an arc segment with the provided data.
        /// </summary>
        /// <param name="context">A context for the arc to be updated. the arc to update is a part of the context.</param>
        internal static void UpdateArc(UpdateArcContext context)
        {
            context.angle = context.arc.SweepDirection == SweepDirection.Clockwise ? context.angle : -context.angle;

            var arcWidth = Math.Abs(context.angle - RadialGaugePanel.ConvertDegreesToRadians(context.minAngle));

            // Ensure that start and endpoint will not match, so that arc is displayed.
            if (arcWidth >= 2 * Math.PI)
            {
                context.angle -= Math.Sign(context.angle - context.minAngle) * 0.01;
            }

            Point arcEndPoint = RadialGaugePanel.CreateRotatedPoint(context.angle, context.radius, context.center, 1);

            context.arc.IsLargeArc = arcWidth > Math.PI;
            context.arc.Size       = new Size(context.radius, context.radius);
            context.arc.Point      = arcEndPoint;
        }
        /// <summary>
        /// This method is called whenever the segments
        /// need to recreate their visual representation.
        /// </summary>
        /// <param name="availableSize">The available size which the visual parts can occupy.</param>
        internal override void ResetSegments(Size availableSize)
        {
            this.PrepareReset(availableSize);
            this.SegmentInfos.Clear();

            var currentstartAngle = this.minAngle;
            var angleSpan         = this.maxAngle - this.minAngle;

            foreach (BarIndicatorSegment segment in this.Segments)
            {
                if (segment.Path == null)
                {
                    Debug.Assert(false, "Missing segment path.");
                    continue;
                }

                double lengthRatio = segment.Length / this.TotalSegmentLength;
                double angle       = currentstartAngle + (angleSpan * lengthRatio);

                PathFigure figure = new PathFigure();
                double     startAngleInRadians = RadialGaugePanel.ConvertDegreesToRadians(currentstartAngle);
                figure.StartPoint = RadialGaugePanel.CreateRotatedPoint(startAngleInRadians, this.radius, this.center, this.radiusScale);

                ArcSegment newArc = new ArcSegment();
                newArc.Point          = figure.StartPoint;
                newArc.SweepDirection = SweepDirection.Clockwise;
                this.SegmentInfos.Add(new SegmentInfo()
                {
                    PathSegment = newArc, Start = startAngleInRadians, End = RadialGaugePanel.ConvertDegreesToRadians(angle)
                });

                figure.Segments.Add(newArc);

                PathGeometry pathGeom = new PathGeometry();
                pathGeom.Figures.Add(figure);

                Path path = segment.Path;
                path.Stroke          = segment.Stroke;
                path.StrokeThickness = segment.Thickness;
                path.Data            = pathGeom;

                currentstartAngle = angle;
            }
        }