using System;
using System.Globalization;
using ThinkGeo.MapSuite.SilverlightCore;

namespace CSharp_Silverlight_HowDoISamples
{
    public static class Helper
    {
        public static PointShape PointShape;

        internal void GetCenterPointByFeatureId(string featureId)
        {
            PointShape = null;
            GeoDataService.GeoDataGettingClient client = new CSharp_Silverlight_HowDoISamples.GeoDataService.GeoDataGettingClient();
            client.GetPointShapeByIdCompleted += new EventHandler(client_GetPointShapeByIdCompleted);
            client.GetPointShapeByIdAsync(featureId);
        }

        void client_GetPointShapeByIdCompleted(object sender, CSharp_Silverlight_HowDoISamples.GeoDataService.GetPointShapeByIdCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                string[] positions = e.Result.Split(',');
                PointShape pointShape = new PointShape(double.Parse(positions[0], CultureInfo.InvariantCulture), double.Parse(positions[1], CultureInfo.InvariantCulture));
                PointShape = pointShape;
            }
        }
    }
}