public ExampleViewModel() { #if SILVERLIGHT Uri serviceUri = new Uri(URIHelper.CurrentApplicationURL, "RadMapDataService.svc"); EndpointAddress address = new EndpointAddress(serviceUri); BasicHttpBinding binding = new BasicHttpBinding() { MaxBufferSize = int.MaxValue, MaxReceivedMessageSize = int.MaxValue }; RadMapDataServiceClient client = new RadMapDataServiceClient(binding, address); client.GetSalesAreasCompleted += ServiceClient_GetSalesAreasCompleted; client.GetSalesAreasAsync(); #else GetSalesAreas(); #endif }
public void MapItemsRequest(object sender, MapItemsRequestEventArgs eventArgs) { double minZoom = eventArgs.MinZoom; Location upperLeft = eventArgs.UpperLeft; Location lowerRight = eventArgs.LowerRight; if (this.dataContext == null) return; #if WPF if (minZoom == 3) { // request areas List<StoreLocation> list = this.dataContext.GetStores( upperLeft.Latitude, upperLeft.Longitude, lowerRight.Latitude, lowerRight.Longitude, StoreType.Area); dataContext.SetStores(list, eventArgs); } if (minZoom == 9) { // request areas List<StoreLocation> list = this.dataContext.GetStores( upperLeft.Latitude, upperLeft.Longitude, lowerRight.Latitude, lowerRight.Longitude, StoreType.Store); this.dataContext.SetStores(list, eventArgs); } #elif SILVERLIGHT const string exceptionFormat = "Store Service Exception: {0}"; EndpointAddress address = new EndpointAddress(this.serviceUri); BasicHttpBinding binding = new BasicHttpBinding() { MaxBufferSize = int.MaxValue, MaxReceivedMessageSize = int.MaxValue }; RadMapDataServiceClient client = new RadMapDataServiceClient(binding, address); client.GetStoresCompleted += this.dataContext.DataServiceGetStoresCompleted; if (minZoom == 3) { // request areas try { client.GetStoresAsync( upperLeft.Latitude, upperLeft.Longitude, lowerRight.Latitude, lowerRight.Longitude, RadMapDataServiceStoreType.Area, eventArgs); } catch (Exception ex) { throw new Exception(string.Format(exceptionFormat, ex.Message)); } } if (minZoom == 9) { // request stores try { client.GetStoresAsync( upperLeft.Latitude, upperLeft.Longitude, lowerRight.Latitude, lowerRight.Longitude, RadMapDataServiceStoreType.Store, eventArgs); } catch (Exception ex) { throw new Exception(string.Format(exceptionFormat, ex.Message)); } } #endif }