Example #1
0
        protected override void OnMouseMove(MouseEventArgs args)
        {
            base.OnMouseMove(args);
            var location = args.GetPosition(this);

            // Look for the mouse op to perform
            var op = MouseOperations.Active;

            if (op != null)
            {
                if (!op.Cancelled)
                {
                    op.DropClient = location;                     // Note: in ChartControl space, not ChartPanel space
                    op.DropChart  = ClientToChart(location);
                    op.MouseMove(args);
                }
            }
            // Otherwise, provide mouse hover detection
            else if (SceneBounds != Rect_.Zero)
            {
                var hit     = HitTestCS(location, Keyboard.Modifiers, args.ToMouseBtns(), null);
                var hovered = hit.Hits.Select(x => x.Element).ToHashSet(0);

                // Remove elements that are no longer hovered
                // and remove existing hovered's from the set.
                for (int i = Hovered.Count; i-- != 0;)
                {
                    if (hovered.Contains(Hovered[i]))
                    {
                        hovered.Remove(Hovered[i]);
                    }
                    else
                    {
                        Hovered.RemoveAt(i);
                    }
                }

                // Add elements that are now hovered
                Hovered.AddRange(hovered);

                // Notify that the chart coordinate at the mouse pointer has changed
                if (hit.Zone == EZone.Chart && ShowValueAtPointer)
                {
                    NotifyPropertyChanged(nameof(ValueAtPointer));
                }
            }
        }