Пример #1
0
        private void webClient_DownloadCatalogCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            try
            {

                if (e.Result != null)
                {
                    busik = JsonConvert.DeserializeObject<BusModel>(e.Result);

                    this.IsDataLoaded = true;
                }
            }
            catch (Exception ex)
            {

            }
            mapka = new Map();
            var longi = double.Parse(busik.Longitude);
            var latit = double.Parse(busik.Latitude);
            mapka.Center = new GeoCoordinate(latit, longi);
            mapka.ZoomLevel = 18;
            Ellipse myCircle = new Ellipse();
            myCircle.Fill = new SolidColorBrush(Colors.Blue);
            myCircle.Height = 20;
            myCircle.Width = 20;
            myCircle.Opacity = 50;

            MapOverlay myLocationOverlay = new MapOverlay();
            myLocationOverlay.Content = myCircle;
            myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
            myLocationOverlay.GeoCoordinate = new GeoCoordinate(latit, longi);

            MapLayer myLocationLayer = new MapLayer();
            myLocationLayer.Add(myLocationOverlay);

            mapka.Layers.Add(myLocationLayer);
            mapka.Width = 500;
            mapka.Height = 500;
            ContentPanel.Children.Add(mapka);
        }
Пример #2
0
        void GetRequestStreamCallback(IAsyncResult callbackResult)
        {
            HttpWebRequest myRequest = (HttpWebRequest)callbackResult.AsyncState;

            // End the stream request operation
            Stream postStream = myRequest.EndGetRequestStream(callbackResult);

            // Create the post data
            string postData = "INSERT";
            BusModel busik = new BusModel();
            busik.BusID = 10;
            busik.Status = "OFF";
            busik.RegNum = "SZY95XH";

            postData = JsonConvert.SerializeObject(busik);

            byte[] byteArray = Encoding.UTF8.GetBytes(postData);

            // Add the post data to the web request
            postStream.Write(byteArray, 0, byteArray.Length);
            postStream.Close();

            // Start the web request
            myRequest.BeginGetResponse(new AsyncCallback(GetResponsetStreamCallback), myRequest);
        }