示例#1
0
        /// <summary>
        /// Place the Label at x, y.
        /// </summary>
        /// <param name="x">X position</param>
        /// <param name="y">Y position</param>
        public void UpdateLabelVisualPosition()
        {
            Double x = Position.X, y = Position.Y;

            // For left side labels line should target to the right handside of the label
            if (x < Center.X)
            {
                if (x - LabelVisual.Width < 0)
                {
                    x = 0;
                }
                else
                {
                    x = x - LabelVisual.Width;
                }
            }

            // if (y + LabelVisual.Height > YRadiusLabel * 2)
            //     y = YRadiusLabel * 2 - LabelVisual.Height;

            // if (y < 0)
            //     y = 0;

            // Set the position
            LabelVisual.SetValue(Canvas.LeftProperty, x);
            LabelVisual.SetValue(Canvas.TopProperty, y);
        }
示例#2
0
        public Boolean CheckOutOfBounds()
        {
            //Point position = GetCartesianCoordinates4Labels(BaseMeanAngle);

            //if (BaseMeanAngle >= 7 * Math.PI / 4 && BaseMeanAngle <= 0 || BaseMeanAngle >= 0 && BaseMeanAngle <= Math.PI / 4
            //    || BaseMeanAngle >= 3 * Math.PI / 4 && BaseMeanAngle <= 5 * Math.PI / 4)
            //{
            //    if (Math.Abs(position.X - Position.X) > XRadiusLabel)
            //        return true;

            //    if (Math.Abs(position.Y - Position.Y) > YRadiusLabel)
            //        return true;
            //}
            //else
            //{
            //    if (Math.Abs(BaseMeanAngle - ResetMeanAngle(CurrentMeanAngle)) > Math.PI / 4)
            //        return true;
            //}

            Double left = (Double)LabelVisual.GetValue(Canvas.LeftProperty);
            Double top  = (Double)LabelVisual.GetValue(Canvas.TopProperty);

            Double labelLinePointX, labelLinePointY;

            if (left < Center.X)
            {
                labelLinePointX = left + Width + LabelPlacementHelper.LABEL_LINE_GAP;
            }
            else
            {
                labelLinePointX = left - LabelPlacementHelper.LABEL_LINE_GAP;
            }

            labelLinePointY = top + Height / 2;
            Point pointOverPie = GetCartesianCoordinates4Chart(BaseMeanAngle);

            Point labelLinePoint = new Point(labelLinePointX, labelLinePointY);

            Point intersectionPoint = Graphics.IntersectingPointOfTwoLines(Center, labelLinePoint, pointOverPie, new Point(labelLinePoint.X, Center.Y));

            Double b = Graphics.DistanceBetweenTwoPoints(Center, intersectionPoint);

            Double angle = Math.Atan(b / XRadiusChart);

            angle = Math.PI / 2 - angle;

            if (angle > Math.PI / 2)
            {
                return(true);
            }

            //  Graphics.DrawPointAt(labelLinePoint, Visual, Colors.Red);

            return(false);
        }
示例#3
0
        protected override VisualGroup CreateVisual(IRenderContext context, ILabel label)
        {
            var layout = label.GetLayout();

            // don't render invisible labels
            if (layout.Width < 0 || layout.Height < 0)
            {
                return(null);
            }
            var group = new LabelVisual();

            group.Size = layout.GetSize();

            // Draw the label background as a rounded rectangle
            var gp         = CreatePath(layout);
            var pathVisual = new GeneralPathVisual(gp)
            {
                Brush = pathBrush, Pen = Pens.SkyBlue
            };

            group.Add(pathVisual);

            // Draw the label's text
            if (context.Zoom >= buttonZoomThreshold)
            {
                // draw the action button
                group.Add(CreateButton(layout));
                group.Add(new TextVisual {
                    Text = label.Text, Font = Font, Brush = Brushes.Black, Location = PointD.Origin
                });
            }
            else
            {
                group.Add(new TextVisual {
                    Text     = label.Text,
                    Font     = Font,
                    Brush    = Brushes.Black,
                    Location = new PointD((buttonWidth + 2 * inset) * 0.5, 0)
                });
            }
            // convert to convenient coordinate space
            group.Transform = GetTransform(context, layout, true);

            return(group);
        }