Exemplo n.º 1
0
        public override void InternalMouseMove(MouseEventArgs objArg)
        {
            if (m_Rect.Contains(objArg.X, objArg.Y) && _ChartHotPoints != null)
            {
                MicroChartHotPoint newHotPoint = MicroChartHotPoint.Empty;
                Rectangle chartBounds = new Rectangle(_ChartLocation.X, _ChartLocation.Y, _ChartWidth, _ChartHeight);
                if (chartBounds.Contains(objArg.X, objArg.Y))
                {
                    foreach (MicroChartHotPoint point in _ChartHotPoints)
                    {
                        Point chartPoint = new Point(objArg.X - _ChartLocation.X, objArg.Y - _ChartLocation.Y);
                        Rectangle r = point.HotPointBounds;
                        Rectangle sliceBounds = point.ChartSliceBounds;
                        r.Offset(_ChartLocation);
                        if (!sliceBounds.IsEmpty)
                            sliceBounds.Offset(_ChartLocation);

                        if (_ChartType == eMicroChartType.Pie && PieSliceContains(chartPoint, point) ||
                            _ChartType != eMicroChartType.Pie && (r.Contains(objArg.X, objArg.Y) || sliceBounds.Contains(objArg.X, objArg.Y)))
                        {
                            newHotPoint = point;
                            break;
                        }
                    }
                }

                HotPoint = newHotPoint;
            }
            base.InternalMouseMove(objArg);
        }
Exemplo n.º 2
0
        private bool PieSliceContains(Point point, MicroChartHotPoint hotPoint)
        {
            int diameter = Math.Min(_ChartHeight, _ChartWidth);
            double a = diameter / 2 + (_ChartWidth - diameter) / 2;
            double b = diameter / 2 + (_ChartHeight - diameter) / 2; ;
            double x = point.X - a;
            double y = point.Y - b;
            double angle = Math.Atan2(y, x);
            if (angle < 0)
                angle += 2 * Math.PI;
            double angleDegrees = angle * 180 / Math.PI;
            // point is inside the pie slice only if between start and end angle

            if (angleDegrees >= hotPoint.StartAngle &&
                       angleDegrees <= hotPoint.StartAngle + hotPoint.SweepAngle)
            {
                return true;
            }
            return false;
        }
Exemplo n.º 3
0
 public override void InternalMouseLeave()
 {
     HotPoint = MicroChartHotPoint.Empty;
     if (_IsMouseOver)
     {
         _IsMouseOver = false;
         this.Refresh();
     }
     base.InternalMouseLeave();
 }