Example #1
0
        private static void OnIsActivatedPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            GeodeticDistance gd       = d as GeodeticDistance;
            bool             oldValue = (bool)e.OldValue;
            bool             newValue = (bool)e.NewValue;

            if (newValue != oldValue)
            {
                if (gd.Map != null)
                {
                    if (newValue)
                    {
                        gd.mapCursor       = gd.Map.Cursor;
                        gd.Map.MouseMove  += gd.map_MouseMove;
                        gd.Map.MouseClick += gd.map_MouseClick;
                        gd.Map.Layers.Add(gd.layer);
                        gd.Map.Cursor = Cursors.Hand;
                    }
                    else
                    {
                        gd.Map.MouseMove  -= gd.map_MouseMove;
                        gd.Map.MouseClick -= gd.map_MouseClick;
                        gd.Map.Layers.Remove(gd.layer);
                        gd.Map.Cursor = gd.mapCursor;                         //restore cursor
                    }
                }
            }
        }
Example #2
0
        private static void OnMapPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            GeodeticDistance gd = d as GeodeticDistance;
            Map  oldMap         = e.OldValue as Map;
            bool isActive       = gd.IsActivated;

            if (isActive)
            {
                gd.IsActivated = false;
            }
            if (oldMap != null)
            {
                gd.layer.ClearGraphics();
            }
            Map map = e.NewValue as Map;

            if (map != null)
            {
                //Create graphics layer and populate with the needed necessary graphics
                gd.layer = new GraphicsLayer();
                gd.layer.Graphics.Add(gd.radiusFill);

                gd.layer.Graphics.Add(gd.greatCircleLine);

                gd.layer.Graphics.Add(gd.radiusLine);

                Polyline line = new Polyline();
                ESRI.ArcGIS.Client.Geometry.PointCollection pnts = new ESRI.ArcGIS.Client.Geometry.PointCollection();
                pnts.Add(new MapPoint());
                pnts.Add(new MapPoint());
                line.Paths.Add(pnts);
                gd.straightLine.Geometry = line;

                gd.layer.Graphics.Add(gd.straightLine);

                gd.layer.Graphics.Add(gd.midMarker);

                gd.textPoint = new Graphic()
                {
                    Symbol = gd.textSymb
                };
                gd.textPoint.SetZIndex(2);
                gd.layer.Graphics.Add(gd.textPoint);
            }
            gd.IsActivated = isActive;
        }