Exemple #1
0
 public static void ShowInfoBox(GeometryBase shape, Point offset)
 {
     //Instance.Show(shape, offset);
 }
Exemple #2
0
        protected virtual void ShowCore(GeometryBase shape, object content, Point offset)
        {
            int _version = Interlocked.Increment(ref version);
            if (!Dispatcher.CheckAccess())
            {
                Dispatcher.BeginInvoke(() =>
                                           {
                                               if (_version == version)
                                               {
                                                   ShowCore(shape, content, offset);
                                               }
                                           });
            }
            else
            {
                InfoBoxEventBehavior.AttachToMap(shape.MapInstance, this);

                currentShape = shape;

                //use content control to ensure that the InfoBox.Template does
                //not change from different ShapeLayer.InfoBoxTemplate values
                var contentControl = new ContentControl
                                         {
                                             Content = content
                                         };
                //if (shape.Layer.InfoBoxContentTemplate != null) {
                //    contentControl.ContentTemplate = shape.Layer.InfoBoxContentTemplate;
                //}

                Content = contentControl;

                currentShape.MouseEnter += OnMouseEnter;
                currentShape.MouseLeave += OnMouseLeave;

                IsVisible = true;
                IsMouseOver = true;

                Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

                Size size = DesiredSize;
                GeneralTransform mapScreenTransform = shape.MapInstance.TransformToVisual(Application.Current.RootVisual);
                var mapScreenBounds = new Rect(
                    mapScreenTransform.Transform(new Point(0, 0)),
                    mapScreenTransform.Transform(new Point(shape.MapInstance.ActualWidth, shape.MapInstance.ActualHeight))
                    );

                bool displayOnLeft = false, displayOnTop = true;

                Point displayPoint = shape.TransformToVisual(Application.Current.RootVisual).Transform(new Point(0, 0));
                displayPoint.X += (offset.X + shape.ActualWidth);
                displayPoint.Y += (offset.Y - size.Height);

                if ((displayPoint.X + size.Width) > mapScreenBounds.Right)
                {
                    //revert the offset above
                    displayPoint.X -= (offset.X + shape.ActualWidth);

                    //shift the point for displaying on the left of the shape
                    displayPoint.X -= (offset.X + size.Width);
                    displayOnLeft = true;
                }

                if (displayPoint.Y < 0)
                {
                    //revert the offset above
                    displayPoint.Y -= (offset.Y - size.Height);

                    //shift the point for displaying on the bottom of the shape
                    //displayPoint.Y += (offset.Y + shape.ActualHeight);
                    displayPoint.Y += offset.Y;
                    displayOnTop = false;
                }

                SetDisplayState(displayOnLeft, displayOnTop);

                popup.HorizontalOffset = displayPoint.X;
                popup.VerticalOffset = displayPoint.Y;

                infoBoxContent = content as IInfoBoxContent;
                if (infoBoxContent != null)
                {
                    infoBoxContent.OnShown();
                }
            }
        }
Exemple #3
0
 public static void ShowInfoBox(GeometryBase shape)
 {
     //Instance.Show(shape);
 }