public void sendCommentAndActualLocationToSave(string description)
        {
            Locations location;
            try
            {
                location = new Locations(globalPositionSystemForMap.actualLocation.Position.Location.Longitude, globalPositionSystemForMap.actualLocation.Position.Location.Latitude);
            }
            catch (Exception)
            {
                return;
            }

            string locationJson = location.serialize();

            Comments comment = new Comments(description, true);

            ServicesReference.Comments commentWeb = new ServicesReference.Comments();
            commentWeb.description = comment.description;
            commentWeb.isText = true;

            ServicesReference.Locations locationWeb = new ServicesReference.Locations();
            locationWeb.latitude = location.latitude;
            locationWeb.longitude = location.longitude;

            string commentJson = comment.serialize();

            string uri = baseWebServer + "CommentsWebServices/addCommentoToLocation?location=" + locationJson + "&comment=" + commentJson + "&code=wonders";

            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);

            var webRequest = (HttpWebRequest)HttpWebRequest.Create(uri);
            webRequest.BeginGetResponse(new AsyncCallback(requestCallBackSaveCommentAndLocation), webRequest);
        }
        public MainPage()
        {
            /*
             Database database = new Database();
             LocalDataBaseForLatLongAndSound item = new LocalDataBaseForLatLongAndSound(1.0, 1.0, "!@312312");
             database.createTableForLatLongAndSound();
             int idItem = database.addItemAndReturnId(item);
             database.getListItems();
             database.findLocalDataBaseForLatLongAndSoundById(idItem);
             database.removeLocalDataBaseForLatLongAndSound(idItem);
             */

            comments = new Comments(baseWebserver);

            InitializeComponent();

            initializeGameTimer();

            sound.play("welcome");

            System.Threading.Thread.Sleep(2000);

            sound.play("map");

            panorama.SelectionChanged += SelectionChanged;

            Menu.DoubleTap += DoubleTap;


            Thread thread = new Thread(new ThreadStart((Action)(() =>
            {
                try
                {
                    List<int> locationsAlreadySaid = new List<int>();
                    int count = 0;

                    while (true)
                    {
                        Thread.Sleep(2000);

                        while (globalPositionSystemForMap == null)
                        {
                            Thread.Sleep(1000);
                        }

                        if (globalPositionSystemForMap.userPushpin == null)
                            continue;

                        if (count == 0 || locations.locationsNearUser.Count == 0)
                        {
                            locations.getLocationsAround();
                        }


                        if (count++ > 100)
                            count = 0;

                        if (locations.locationsNearUser == null)
                            continue;

                        foreach (Locations location in locations.locationsNearUser)
                        {
                            double distance = location.distanceTo(globalPositionSystemForMap.actualLocation.Position.Location.Longitude, globalPositionSystemForMap.actualLocation.Position.Location.Latitude);

                            if (distance < 0.0004)
                            {
                                if (locationsAlreadySaid.Contains(location.id) == false)
                                {
                                    locationsAlreadySaid.Add(location.id);

                                    comments.getCommentFromLocationIdAndTypeOfComment(location.id, (Application.Current as App).idMessageType);
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                }
            })));

            //Moq 
            thread.Start();
        }
        public void sendCommentAndSoundToActualLocationToSave(string description, MyMicrophone myMicrophone)
        {
            Locations location;
            byte[] soundStream = myMicrophone.streamMicrophone.ToArray();

            try
            {
                location = new Locations(globalPositionSystemForMap.actualLocation.Position.Location.Longitude, globalPositionSystemForMap.actualLocation.Position.Location.Latitude);
            }
            catch (Exception)
            {
                return;
            }

            string locationJson = location.serialize();

            Comments comment = new Comments(description, false);

            ServicesReference.Comments commentWeb = new ServicesReference.Comments();
            commentWeb.description = comment.description;
            commentWeb.isText = false;
            commentWeb.typeOfCommentsId = (Application.Current as App).idMessageType;
            commentWeb.archiveDescription = " ";
            commentWeb.sound = null;

            ServicesReference.Locations locationWeb = new ServicesReference.Locations();
            locationWeb.latitude = location.latitude;
            locationWeb.longitude = location.longitude;

            string commentJson = comment.serialize();

            var client = new WebService1SoapClient(new BasicHttpBinding(BasicHttpSecurityMode.None)
            {
                MaxReceivedMessageSize = 2147483647,
                MaxBufferSize = 2147483647
            }, new EndpointAddress(Properties.getEndPoint()));

            client.addComentAndSoundToLocationAsync(locationJson, soundStream, commentWeb, "wonders");
            client.addComentAndSoundToLocationCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(webService_addComentAndSoundToLocationCompleted);
        }