Select to view content in your preferred language

Navigation Control - Left side rotate is backwards *Quick Fix*

1013
2
12-23-2010 06:32 AM
DanielWalton
Frequent Contributor
Just wanted to share a quick and dirty fix to the Nav control's left side (mis)behavior. Just download the source from Codeplex and make the following change inside Navigation/Navigation.cs:


        private void RotateRing_MouseMove(object sender, MouseEventArgs e)
        {
            Point p = e.GetPosition(this);
            double delta = (p.Y - startMousePos.Y);

            //added to correct left-side drag behavior
            if (p.X < this.ActualWidth / 2.0)
                delta *= -1;
            //end correction

            startMousePos = p;
            angle += delta;
            SetMapRotation(angle);
        }
0 Kudos
2 Replies
DanielWalton
Frequent Contributor
Another addition to the Nav control; I found that the zoom slider wasn't accurately reflecting the map zoom level until I used the Nav to zoom. A quick fix for that :

        private static void OnMapPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Navigation nav = d as Navigation;
            Map map = e.NewValue as Map;
            Map oldmap = e.OldValue as Map;

            if (oldmap != null)
            {
                oldmap.RotationChanged -= nav.Map_RotationChanged;
                oldmap.ExtentChanged -= nav.Map_ExtentChanged;
                oldmap.ExtentChanging -= nav.Map_ExtentChanged;
                if (oldmap.Layers != null)
                    oldmap.Layers.LayersInitialized -= nav.Layers_LayersInitialized;
            }
            if (map != null)
            {
                map.RotationChanged += nav.Map_RotationChanged;
                map.ExtentChanged += nav.Map_ExtentChanged;
                map.ExtentChanging += nav.Map_ExtentChanged;
                if (map.Layers != null)
                    map.Layers.LayersInitialized += nav.Layers_LayersInitialized;
                if (nav.TransformRotate != null)
                    nav.TransformRotate.Angle = map.Rotation;

                //Added for cases when Map binding is created after template is applied
                nav.SetupZoom();
                //end correction
            }
        }
0 Kudos
OrenGal
Regular Contributor
Thank you so much for sharing Dan!
I was wondering why the SL team did not fix it since ver 1.0.
Immediately updated my demo.
Oren
http://www.gal-systems.com/esri-silverlight-api.html
0 Kudos