Exemple #1
0
        /// <summary>
        /// Shows and moves the snap vertex.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="graphic">The graphic.</param>
        /// <param name="args">The <see cref="System.Windows.Input.MouseEventArgs"/> instance containing the event data.</param>
        private void vertexLayer_MouseMove(object sender, GraphicMouseEventArgs args)
        {
            var graphic = args.Graphic;

            if (DraggingVertex != null)
            {
                return;
            }
            if (graphic.Geometry is Polyline)             //We are over a hover line
            {
                Polyline line    = graphic.Geometry as Polyline;
                Point    pScreen = args.GetPosition(MyMap);
                MapPoint pMap    = MyMap.ScreenToMap(pScreen);
                MapPoint snap    = FindPointOnLineClosestToPoint(line.Paths[0][0], line.Paths[0][1], pMap);

                if (snapVertex == null)
                {
                    snapVertex = new Graphic()
                    {
                        Symbol = snapSymbol, Geometry = snap
                    };
                    vertexLayer.Graphics.Add(snapVertex);
                }
                else
                {
                    snapVertex.Geometry = snap;
                }
            }
        }
        // Get mouse position
        void GraphicsLayer_MouseEnterOrMove(object sender, GraphicMouseEventArgs args)
        {
            _mousePos = args.GetPosition(AssociatedObject);
            GraphicsLayer graphicsLayer = sender as GraphicsLayer;

#if DEBUG
            if (args.Graphic != null)
            {
                if (args.Graphic.Symbol is ESRI.ArcGIS.Client.Clustering.FlareSymbol)
                {
                    Debug.WriteLine(string.Format("@@MouseEnter/Move, flare, {0}", MapApplication.GetLayerName(graphicsLayer)));
                }
                else if (args.Graphic.Attributes.ContainsKey("NAME"))
                {
                    Debug.WriteLine(string.Format("@@MouseEnter/Move, {0}, {1}", args.Graphic.Attributes["NAME"], MapApplication.GetLayerName(graphicsLayer)));
                }
                else
                {
                    Debug.WriteLine(string.Format("@@MouseEnter/Move, no NAME field, {0}", MapApplication.GetLayerName(graphicsLayer)));
                }
            }
#endif
            if (ESRI.ArcGIS.Client.Extensibility.LayerProperties.GetIsPopupEnabled(graphicsLayer))
            {
                if (!ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetPopUpsOnClick(graphicsLayer))
                {
                    HoverResults hoverResults = graphicsLayer.MapTip as HoverResults;
                    if (graphicsLayer.MapTip == null) //if not a custom map tip
                    {
                        //if first time, attach map tip to layer
                        attachApplicationMapTipToLayer(graphicsLayer, args.Graphic);
                        hoverResults = graphicsLayer.MapTip as HoverResults;
                    }

                    //if map tip dirty, rebuild map tip
                    if (hoverResults != null)
                    {
                        if (ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetIsMapTipDirty(graphicsLayer) &&
                            args.Graphic == hoverResults.Graphic)
                        {
                            rebuildMapTipContentsBasedOnFieldVisibility(hoverResults);
                        }
                        //clear map tip dirty flag
                        ESRI.ArcGIS.Mapping.Core.LayerExtensions.SetIsMapTipDirty(graphicsLayer, false);
                    }
                }
                else
                {
                    graphicsLayer.MapTip = null;
                }
            }
            else if (graphicsLayer.MapTip is HoverResults)
            {
                graphicsLayer.MapTip = null;
            }
        }
Exemple #3
0
 private void graphicsLayer_MouseMove(object sender, GraphicMouseEventArgs e)
 {
     //Recenter the maptip as long as the maptip isn't displaying yet
     if (Visibility == Visibility.Collapsed)
     {
         Point p = e.GetPosition(Parent as UIElement);
         SetValue(Canvas.LeftProperty, p.X + HorizontalOffset);
         SetValue(Canvas.TopProperty, p.Y + VerticalOffset);
         timer.Start();
     }
 }
Exemple #4
0
 private void graphicsLayer_MouseEnter(object sender, GraphicMouseEventArgs args)
 {
     mouseIsOver = true;
     Graphic graphic = args.Graphic;
     if (currentFeature != graphic) //Mouse entered a new feature
     {
         this.expanded = false;
         currentFeature = graphic;
         Point p = args.GetPosition(Parent as UIElement);
         SetValue(Canvas.LeftProperty, p.X + HorizontalOffset);
         SetValue(Canvas.TopProperty, p.Y + VerticalOffset);
         this.DataContext = this.ItemsSource = graphic.Attributes;
         if (!string.IsNullOrEmpty(TitleMember))
         {
             object title = null;
             if (graphic.Attributes.ContainsKey(TitleMember))
                 title = string.Format("{0}", graphic.Attributes[TitleMember]);
             else
             {
                 string firstKey = null;
                 foreach (string key in graphic.Attributes.Keys)
                 {
                     if (firstKey == null) firstKey = key;
                     if (graphic.Attributes[key].GetType() == typeof(string))
                     {
                         title = graphic.Attributes[key] as string;
                         break;
                     }
                 }
                 if (title == null && !string.IsNullOrEmpty(firstKey))
                     title = string.Format("{0}", graphic.Attributes[firstKey]);
             }
             this.Title = title;
         }
         ChangeVisualState(false);
         Visibility = Visibility.Collapsed;
     }
     if (Visibility == Visibility.Collapsed)
     {
         timer.Start(); //Delay showing maptip
     }
 }