コード例 #1
0
        void OnHover(object sender, MouseEventArgs e)
        {
            Point pos = e.GetPosition(this);

            foreach (double inflation in new double[] { 0, 2, 5, 10, 20 })
            {
                foreach (BeginEndEvent record in data)
                {
                    Rect bounds = record.Bounds;
                    bounds.Inflate(inflation, inflation);
                    if (bounds.Contains(pos))
                    {
                        gesture.ShowPopup(GetPopupContent(record));
                        return;
                    }
                }
            }
        }
コード例 #2
0
        void OnHover(object sender, MouseEventArgs e)
        {
            Connector.Visibility = System.Windows.Visibility.Hidden;
            Dot.Visibility       = System.Windows.Visibility.Hidden;
            if (scaled != null)
            {
                int closest = FindClosestPoint(e);
                if (closest >= 0)
                {
                    Grid grid = GetPopupContent(closest);
                    if (grid != null)
                    {
                        Popup popup = hover.ShowPopup(grid);
                        Dispatcher.BeginInvoke(new Action(() => {
                            try
                            {
                                Point p       = scaled[closest];
                                Point topleft = new Point(0, 0);
                                topleft       = popup.Child.PointToScreen(topleft);
                                topleft       = this.PointFromScreen(topleft);

                                Connector.X1         = topleft.X;
                                Connector.Y1         = topleft.Y;
                                Connector.X2         = p.X;
                                Connector.Y2         = p.Y;
                                Connector.Visibility = System.Windows.Visibility.Visible;

                                Canvas.SetLeft(Dot, p.X - Dot.Width / 2);
                                Canvas.SetTop(Dot, p.Y - Dot.Height / 2);
                                Dot.Visibility = System.Windows.Visibility.Visible;
                            }
                            catch
                            {
                            }
                        }), System.Windows.Threading.DispatcherPriority.Background);
                    }
                }
            }
        }