Esempio n. 1
0
        //void DoOnNewConversationItem(RosterItem item, bool bReceived, TextMessage msg)
        void XMPPClient_OnNewConversationItem(RosterItem item, bool bReceived, TextMessage msg)
        {
            /// Save the conversation first
            ChatPage.SaveConversation(item);

            //Microsoft.Phone.PictureDecoder.DecodeJpeg(

            if (bReceived == true)
            {
                if (msg.Message != null)
                {
                    Microsoft.Phone.Shell.ShellToast toast = new Microsoft.Phone.Shell.ShellToast();
                    toast.Title = msg.Message;
                    //toast.NavigationUri = new Uri(string.Format("/ChatPage.xaml?JID={0}", msg.From.BareJID));
                    toast.Show();

                    if (App.Options.PlaySoundOnNewMessage == true)
                    {
                        Microsoft.Phone.BackgroundAudio.BackgroundAudioPlayer.Instance.Track = newmessagetrack;
                        Microsoft.Phone.BackgroundAudio.BackgroundAudioPlayer.Instance.Play();

                        //System.IO.Stream stream = TitleContainer.OpenStream("sounds/ding.wav");
                        //SoundEffect effect = SoundEffect.FromStream(stream);
                        //FrameworkDispatcher.Update();
                        //effect.Play();
                        //stream.Close();
                    }
                    if (App.Options.VibrateOnNewMessage == true)
                    {
                        Microsoft.Devices.VibrateController.Default.Start(TimeSpan.FromMilliseconds(200));
                    }
                }
            }
        }
Esempio n. 2
0
        void PushChannel_ShellToastNotificationReceived(object sender, NotificationEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("PushChannel_ShellToastNotificationReceived");

            string title    = string.Empty;
            string subtitle = string.Empty;
            string extras   = string.Empty;

            e.Collection.TryGetValue("wp:Text1", out title);
            e.Collection.TryGetValue("wp:Text2", out subtitle);
            e.Collection.TryGetValue("wp:Param", out extras);

            Toast toast = new Toast();

            toast.Title    = title;
            toast.Subtitle = subtitle;
            toast.Extra    = extras;

            if (IsRunningInBackground)
            {
                Microsoft.Phone.Shell.ShellToast ShellToast = new Microsoft.Phone.Shell.ShellToast();
                ShellToast.Content       = toast.Subtitle;
                ShellToast.Title         = toast.Title;
                ShellToast.NavigationUri = new Uri(toast.Extra, UriKind.Relative);
                ShellToast.Show();
            }
            else
            {
                PluginResult result = new PluginResult(PluginResult.Status.OK, toast);
                var          script = new ScriptCallback(this.toastCallback, new string[] { result.Message });
                this.InvokeCustomScript(script, false);
            }
        }
Esempio n. 3
0
 public Page2()
 {
     InitializeComponent();
     Microsoft.Phone.Shell.ShellToast toast = new Microsoft.Phone.Shell.ShellToast();
     toast.Title = "Location: ";
     toast.NavigationUri = new Uri("/Page2.xaml", UriKind.Relative);
     toast.Show();
 }
Esempio n. 4
0
 void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
 {
     if (!DGGeofencing.RunningInBackground)
     {
         Deployment.Current.Dispatcher.BeginInvoke(() =>
         {
             System.Diagnostics.Debug.WriteLine("======= Geolocator =======");
             System.Diagnostics.Debug.WriteLine(args.Position.Coordinate.Latitude.ToString("0.00"));
             System.Diagnostics.Debug.WriteLine(args.Position.Coordinate.Longitude.ToString("0.00"));
         });
     }
     else
     {
         System.Diagnostics.Debug.WriteLine("======= Geolocator RunningInBackground =======");
         Microsoft.Phone.Shell.ShellToast toast = new Microsoft.Phone.Shell.ShellToast();
         System.Diagnostics.Debug.WriteLine(args.Position.Coordinate.Latitude.ToString("0.00"));
         System.Diagnostics.Debug.WriteLine(args.Position.Coordinate.Longitude.ToString("0.00"));
     }
 }
Esempio n. 5
0
        static async void watcher_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
        {
            if (App.RunningInBackground)
            {
                if (App.fbAppID != String.Empty)
                {
                    staticObjects.CurrentLatitude  = args.Position.Coordinate.Latitude;
                    staticObjects.CurrentLongitude = args.Position.Coordinate.Longitude;
                    await GPS.GetAddress(staticObjects.CurrentLatitude, staticObjects.CurrentLongitude);

                    Broadcast.TryUploadPosition(true);

                    Microsoft.Phone.Shell.ShellToast toast = new Microsoft.Phone.Shell.ShellToast();
                    toast.Content = AppResources.BroadcastView_BroadcastSucceeded;
                    toast.Title   = "It F****n works!";
                    toast.Show();
                }
            }
        }
        void geoWatcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
        {
            GeoCoordinate currentLoc = e.Position.Location;
            double minDis = Double.Parse(appdata["data2"].ToString());
            double minDistance = minDis*1000 ;
            double currentLongitude = e.Position.Location.Longitude;
            double currnetLatitude = e.Position.Location.Latitude;
            double latitude = Double.Parse(appdata["latitude"].ToString());
            double longitude = Double.Parse(appdata["longitude"].ToString());
            GeoCoordinate location = new GeoCoordinate(latitude, longitude);
            double distanceInMeter = currentLoc.GetDistanceTo(location);
            double disInKm = distanceInMeter / 1000;
            if (distanceInMeter < minDistance)
            {
              if (!App.RunningInBackground)
               {
                   Dispatcher.BeginInvoke(() =>
                 {
                     textBlock2.Text = disInKm.ToString();

                      status = "You have reached your destination !!!!!!";
                      CreateAlarm(15);
                 });
                }
              else
               {
                   CreateAlarm(15);
                Microsoft.Phone.Shell.ShellToast toast = new Microsoft.Phone.Shell.ShellToast();
                toast.Content = status;
                toast.Title = "Status: ";
                toast.NavigationUri = new Uri("/Page4.xaml", UriKind.Relative);
                toast.Show();

                }
            }
            else
             {
               textBlock2.Text = disInKm.ToString();
               status = "Not at Reached the Destination...";
             }
                textBlock3.Text = status;
        }
Esempio n. 7
0
        void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
        {
            if (!App.RunningInBackground)
            {

                Dispatcher.BeginInvoke(() =>
                {
                    LatitudeTextBlock.Text = args.Position.Coordinate.Latitude.ToString("0.00");
                    LongitudeTextBlock.Text = args.Position.Coordinate.Longitude.ToString("0.00");
                });
            }
            else
            {
                Microsoft.Phone.Shell.ShellToast toast = new Microsoft.Phone.Shell.ShellToast();
                toast.Content = args.Position.Coordinate.Latitude.ToString("0.00");
                toast.Title = "Location: ";
                toast.NavigationUri = new Uri("/Page2.xaml", UriKind.Relative);
                toast.Show();
            }
        }
Esempio n. 8
0
		void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
		{

            if (!DGGeofencing.RunningInBackground)
		    {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
		        {
		        	System.Diagnostics.Debug.WriteLine("======= Geolocator =======");
		            System.Diagnostics.Debug.WriteLine(args.Position.Coordinate.Latitude.ToString("0.00"));
		            System.Diagnostics.Debug.WriteLine(args.Position.Coordinate.Longitude.ToString("0.00"));
		        });
		    }
		    else
		    {
		    	System.Diagnostics.Debug.WriteLine("======= Geolocator RunningInBackground =======");
		        Microsoft.Phone.Shell.ShellToast toast = new Microsoft.Phone.Shell.ShellToast();
		        System.Diagnostics.Debug.WriteLine(args.Position.Coordinate.Latitude.ToString("0.00"));
	            System.Diagnostics.Debug.WriteLine(args.Position.Coordinate.Longitude.ToString("0.00"));
		    }
		}
Esempio n. 9
0
 void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
 {
     if (!App.RunningInBackground)
     {
         Dispatcher.BeginInvoke(() =>
         {
             txtBlock.Text += "Lat: " + args.Position.Coordinate.Latitude.ToString("0.000000") + "\n";
             txtBlock.Text += "Long: " + args.Position.Coordinate.Longitude.ToString("0.000000") + "\n";
             txtBlock.Text += "Alt: " + args.Position.Coordinate.Altitude.ToString() + "\n\n";
         });
     }
     else
     {
         Microsoft.Phone.Shell.ShellToast toast = new Microsoft.Phone.Shell.ShellToast();
         toast.Content       = args.Position.Coordinate.Latitude.ToString("0.000");
         toast.Title         = "Location: ";
         toast.NavigationUri = new Uri("/MainPage.xaml", UriKind.Relative);
         toast.Show();
     }
 }
Esempio n. 10
0
        /*This method will detirmine and add when a postion is changed to the phone. It will first initialize 
         a new Geocooridante object that will be used to track the position of the phone. It will Initialize
         this and set this positon to our latttidue and longitude string. If this is the first time it is 
         called it will push this current point to the database. This creates a key and allows the constanst sync feature
         provided by the application. If not it will calculate the distance and the speed; display that information as well
         as draw a line based on where you are from the last collected point.*/
        void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
        {
            var lineCoord = new GeoCoordinate(args.Position.Coordinate.Latitude, args.Position.Coordinate.Longitude);

            if (!App.RunningInBackground)
            {
                Dispatcher.BeginInvoke(() =>
                {
                    lattitudetextblock = args.Position.Coordinate.Latitude.ToString("0.00");
                    longitudetextblock = args.Position.Coordinate.Longitude.ToString("0.00");
                    ShowMyLocationOnTheMap();
                });
            }
            else
            {
                Microsoft.Phone.Shell.ShellToast toast = new Microsoft.Phone.Shell.ShellToast();
                toast.Content = args.Position.Coordinate.Latitude.ToString("0.00");
                toast.Title = "Location: ";
                toast.NavigationUri = new Uri("/Page2.xaml", UriKind.Relative);
                toast.Show();

            }



            Dispatcher.BeginInvoke(async() =>
            {
                lattitudetextblock = args.Position.Coordinate.Latitude.ToString("0.0000000000");
                lat = lattitudetextblock;

                longitudetextblock = args.Position.Coordinate.Longitude.ToString("0.0000000000");
                longi = longitudetextblock;
                

                int index = lattitude.Count;
                double storeThresholdx = 0.0;
                double storeThresholdy = 0.0;
                x = Convert.ToDouble(lat);
                y = Convert.ToDouble(longi);
                if (lattitude.Count == 0 || longitude.Count == 0)
                {
                    lattitude.Add(lat);
                    longitude.Add(longi);
                    string defaultURL = "http://107.170.254.134/db2/add.php?name=insertName&type=insertType";
                    HttpContent content;

                    defaultURL = defaultURL.Replace("insertName", name);
                    defaultURL = defaultURL.Replace("insertType", path);
                    HttpClient httpClient = new HttpClient();
                    String locationString = RoadToString();
                    content = new StringContent(locationString);
                    try
                    {
                        HttpResponseMessage response = await httpClient.PostAsync(defaultURL, content).ConfigureAwait(false);
                        String newString = await response.Content.ReadAsStringAsync();
                        System.Diagnostics.Debug.WriteLine(newString);
                        String keyValue = newString;
                        keyValue = keyValue.Replace("key:", "");
                        keyValue = keyValue.Replace("time:", "^");
                        keyValue = keyValue.Replace(" ", "");
                        String[] keyTime = keyValue.Split('^');
                        key = keyTime[0];

                    }
                    catch (HttpRequestException hre)
                    {
                        System.Diagnostics.Debug.WriteLine(hre);
                    }
                }
                else if (lattitude.Count != 0 || longitude.Count != 0)
                {
                    index = index - 1;
                    xPrev = Convert.ToDouble(lattitude[lattitude.Count - 1]);
                    yPrev = Convert.ToDouble(longitude[longitude.Count -1]);
                    storeThresholdx = x - xPrev;
                    storeThresholdy = y - yPrev;
                    if (storeThresholdx != 0 || storeThresholdy != 0)
                    {
                        lattitude.Add(lat);
                        longitude.Add(longi);

                        Sync(RoadToString());
                        storeThresholdx = 0;
                        storeThresholdy = 0;
                        dist += distance(x, y, xPrev, yPrev);

                        stringDistance = Convert.ToString(Math.Round(dist,5));

                        string speedText = "";
                        
                       
                        MenuDistance.Text = "Distance: " + stringDistance + " mi";
                       

                        if (args.Position.Coordinate.Speed != null)
                        {
                            //speedText = args.Position.Coordinate.Speed.ToString("0.000"); // in meters/second
                            speedText = args.Position.Coordinate.Speed.HasValue ? args.Position.Coordinate.Speed.ToString() : "UNKNOWN"; // in meters/second
                            MenuSpeed.Text = "Speed: " + speedText + " meters/second";
                        }

                        
                    }
                    
                    // to show path
                    pathLine.Path.Add(lineCoord);
                }





            });
        }
Esempio n. 11
0
         void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
         {

             if (!App.RunningInBackground)
             {
                 MediaPlayer.Play(songs,0);
             }
             else
             {
                 Microsoft.Phone.Shell.ShellToast toast = new Microsoft.Phone.Shell.ShellToast();
                 toast.Content = args.Position.Coordinate.Latitude.ToString("0.00");
                 toast.Title = "Location: ";
                 toast.NavigationUri = new Uri("/Page2.xaml", UriKind.Relative);
                 toast.Show();

             }
         }
Esempio n. 12
0
        void PushChannel_ShellToastNotificationReceived(object sender, NotificationEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("PushChannel_ShellToastNotificationReceived");

            string title = string.Empty;
            string subtitle = string.Empty;
            string extras = string.Empty;

            e.Collection.TryGetValue("wp:Text1", out title);
            e.Collection.TryGetValue("wp:Text2", out subtitle);
            e.Collection.TryGetValue("wp:Param", out extras);

            Toast toast = new Toast();
            toast.Title = title;
            toast.Subtitle = subtitle;
            toast.Extra = extras;

            if (IsRunningInBackground)
            {
                Microsoft.Phone.Shell.ShellToast ShellToast = new Microsoft.Phone.Shell.ShellToast();
                ShellToast.Content = toast.Subtitle;
                ShellToast.Title = toast.Title;
                ShellToast.NavigationUri = new Uri(toast.Extra, UriKind.Relative);
                ShellToast.Show();
            }
            else
            {
                PluginResult result = new PluginResult(PluginResult.Status.OK, toast);
                var script = new ScriptCallback(this.toastCallback, new string[] { result.Message });
                this.InvokeCustomScript(script, false);
            }
        }
Esempio n. 13
0
        void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
        {
            ObjLocationTbl = new DataAccessLayer.LocationTable();
            try
            {

                ObjLocationTbl.Journeyid = lastJourneyID;
                ObjLocationTbl.Lat = args.Position.Coordinate.Latitude.ToString();
                ObjLocationTbl.Long = args.Position.Coordinate.Longitude.ToString();

                ObjLocationTbl.DateTime = String.Format("{0:yyyy-MM-dd H:mm:ss}", System.DateTime.Now.ToLocalTime());
                var context = new DataAccessLayer.AgeasDriverDetails(ClsDBHelper.ClsDBHelper.DBConnectionString);

                if (IsFirst)
                {
                    StartLatitude = args.Position.Coordinate.Latitude;
                    StartLongitude = args.Position.Coordinate.Longitude;
                    EndLatitude = args.Position.Coordinate.Latitude;
                    EndLongitude = args.Position.Coordinate.Longitude;
                    IsFirst = false;

                }
                else
                {
                    EndLatitude = args.Position.Coordinate.Latitude;
                    EndLongitude = args.Position.Coordinate.Longitude;
                }
                objDBHelper.InsertLocation(ObjLocationTbl);
            }

            catch { }

            ObjLocationTbl = null;
            if (!App.RunningInBackground)
            {

                Dispatcher.BeginInvoke(() =>
                {
                    ;
                });
            }
            else
            {

                Microsoft.Phone.Shell.ShellToast toast = new Microsoft.Phone.Shell.ShellToast();
                toast.Content = args.Position.Coordinate.Latitude.ToString("0.00") + "," + args.Position.Coordinate.Longitude.ToString("0.00");
                toast.Title = "Location: ";
                toast.NavigationUri = new Uri("/Page2.xaml", UriKind.Relative);
                toast.Show();

            }
        }
Esempio n. 14
0
        //void DoOnNewConversationItem(RosterItem item, bool bReceived, TextMessage msg)
        void XMPPClient_OnNewConversationItem(RosterItem item, bool bReceived, TextMessage msg)
        {
            /// Save the conversation first
            ChatPage.SaveConversation(item);

            //Microsoft.Phone.PictureDecoder.DecodeJpeg(

            if (bReceived == true)
            {
                if (msg.Message != null)
                {
                    Microsoft.Phone.Shell.ShellToast toast = new Microsoft.Phone.Shell.ShellToast();
                    toast.Title = msg.Message;
                    //toast.NavigationUri = new Uri(string.Format("/ChatPage.xaml?JID={0}", msg.From.BareJID));
                    toast.Show();

                    if (App.Options.PlaySoundOnNewMessage == true)
                    {

                        Microsoft.Phone.BackgroundAudio.BackgroundAudioPlayer.Instance.Track = newmessagetrack;
                        Microsoft.Phone.BackgroundAudio.BackgroundAudioPlayer.Instance.Play();

                        //System.IO.Stream stream = TitleContainer.OpenStream("sounds/ding.wav");
                        //SoundEffect effect = SoundEffect.FromStream(stream);
                        //FrameworkDispatcher.Update();
                        //effect.Play();
                        //stream.Close();
                    }
                    if (App.Options.VibrateOnNewMessage == true)
                        Microsoft.Devices.VibrateController.Default.Start(TimeSpan.FromMilliseconds(200));
                }
            }
        }