//private void btnGeocode_Click(object sender, RoutedEventArgs e)
        //{
        //    SaveScreenToDealer();
        //    YahooGeoCoder.GeocodeDealer(_selectedDealer);
        //    txtLatitude.Text = _selectedDealer.Latitude.ToString();
        //    txtLongitude.Text = _selectedDealer.Longitude.ToString();
        //}

        // center markers on load

        //void MainMap_MouseEnter(object sender, MouseEventArgs e)
        //{
        //    MainMap.Focus();
        //}

        //void MainMap_Loaded(object sender, RoutedEventArgs e)
        //{
        //    MainMap.ZoomAndCenterMarkers(null);
        //}

        //void MainMap_OnMapTypeChanged(MapType type)
        //{
        //    sliderZoom.Minimum = MainMap.MinZoom;
        //    sliderZoom.Maximum = MainMap.MaxZoom;
        //}

        //void MainMap_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        //{
        //    System.Windows.Point p = e.GetPosition(MainMap);
        //    currentMarker.Position = MainMap.FromLocalToLatLng((int)p.X, (int)p.Y);
        //}

        //// move current marker with left holding
        //void MainMap_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        //{
        //    if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed)
        //    {
        //        System.Windows.Point p = e.GetPosition(MainMap);
        //        currentMarker.Position = MainMap.FromLocalToLatLng((int)p.X, (int)p.Y);
        //    }
        //}

        //// zoo max & center markers
        //private void button13_Click(object sender, RoutedEventArgs e)
        //{
        //    MainMap.ZoomAndCenterMarkers(null);
        //}

        //// tile louading starts
        //void MainMap_OnTileLoadStart()
        //{
        //    System.Windows.Forms.MethodInvoker m = delegate()
        //    {
        //        //progressBar1.Visibility = Visibility.Visible;
        //    };

        //    try
        //    {
        //        this.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, m);
        //    }
        //    catch
        //    {
        //    }
        //}

        //// tile loading stops
        //void MainMap_OnTileLoadComplete(long ElapsedMilliseconds)
        //{
        //    MainMap.ElapsedMilliseconds = ElapsedMilliseconds;

        //    System.Windows.Forms.MethodInvoker m = delegate()
        //    {
        //        //progressBar1.Visibility = Visibility.Hidden;
        //        //groupBox3.Header = "loading, last in " + MainMap.ElapsedMilliseconds + "ms";
        //    };

        //    try
        //    {
        //        this.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, m);
        //    }
        //    catch
        //    {
        //    }
        //}

        //// current location changed
        //void MainMap_OnCurrentPositionChanged(PointLatLng point)
        //{
        //    //mapgroup.Header = "gmap: " + point;
        //}

        private void SaveDealer()
        {
            if (txtLatitude.Text.Length == 0 || txtLatitude.Text == "0")
            {
                //MapQuestGeoCoder.GeocodeDealer(_selectedDealer);
                GoogleGeocoder.GeocodeDealer(_selectedDealer);
            }
            //TODO put in transation

            DealerService.Save(_selectedDealer);

            //delete all
            DealerService.DeleteDealerZipCodes(_selectedDealer.ID);

            //then add back
            if (_dealerZipCodes != null)
            {
                foreach (ZipGeoCode _zipGeoCode in _dealerZipCodes)
                {
                    DealerService.AddDealerZipCode(new DealerZipCode()
                    {
                        DealerID = _selectedDealer.ID, ZipGeoCodeID = _zipGeoCode.ID
                    });
                }
            }
        }