コード例 #1
0
        private async void CabsListView_ItemClick(object sender, ItemClickEventArgs e)
        {
            Cab cabDetails = e.ClickedItem as Cab;

            if (_source == null || _source == "")
            {
                await new MessageDialog("Please Enter Source").ShowAsync();
                return;
            }
            if (_destination == null || _destination == "")
            {
                await new MessageDialog("Please Enter Destination").ShowAsync();
                return;
            }
            if (_destination != null && _source != null)
            {
                Dictionary <string, object> Parameters = new Dictionary <string, object>();
                Parameters.Add("eta", cabDetails.Eta);
                Parameters.Add("price", cabDetails.FareData.Surge);
                Parameters.Add("distance", cabDetails.Distance);
                Parameters.Add("time", cabDetails.Time);
                Parameters.Add("source", _source);
                Parameters.Add("destination", _destination);
                Arguments data = new Arguments(null);
                data.AddType(VoiceCommandType.NO_VOICE, true);
                data.Values = Parameters;
                Frame.Navigate(typeof(BookingPage), data);
            }
        }
コード例 #2
0
        private void CabsListView_ItemClick(object sender, ItemClickEventArgs e)
        {
            Cab cabDetails = e.ClickedItem as Cab;
            Dictionary <string, object> Parameters = new Dictionary <string, object>();

            Parameters.Add("eta", cabDetails.Eta);
            Parameters.Add("price", cabDetails.Provider);
            Parameters.Add("capacity", cabDetails.Capacity);
            Parameters.Add("time", cabDetails.Capacity);
            Parameters.Add("source", SrcBox.Text);
            Parameters.Add("destination", DestBox.Text);
            Arguments data = new Arguments(null);

            data.AddType(VoiceCommandType.NO_VOICE, true);
            data.Values = Parameters;
            Frame.Navigate(typeof(BookingPage), data);
        }
コード例 #3
0
        private void CabsListView_ItemClick(object sender, ItemClickEventArgs e)
        {
            CabEstimate cabDetails = e.ClickedItem as CabEstimate;
            Dictionary <string, object> Parameters = new Dictionary <string, object>();

            Parameters.Add("eta", cabDetails.Eta);
            Parameters.Add("low", cabDetails.CurrentEstimate.LowRange);
            Parameters.Add("high", cabDetails.CurrentEstimate.HighRange);
            Parameters.Add("distance", cabDetails.CurrentEstimate.Distance);
            Parameters.Add("time", cabDetails.CurrentEstimate.Time);
            Parameters.Add("source", mSource);
            Parameters.Add("destination", mDestination);
            Arguments data = new Arguments(null);

            data.AddType(VoiceCommandType.ESTIMATE_FROM, true);
            data.Values = Parameters;
            Frame.Navigate(typeof(BookingPage), data);
        }
コード例 #4
0
        private Arguments ProcessBookFromXToY(SpeechRecognitionResult res)
        {
            Arguments args = new Arguments(null);

            args.AddType(VoiceCommandType.BOOK_ME_A_CAB_FROM_X_TO_Y, true);
            try
            {
                var source      = res.SemanticInterpretation.Properties["bookFromX"];
                var destination = res.SemanticInterpretation.Properties["bookFromY"];
                args.AddArgument("source", source.FirstOrDefault());
                args.AddArgument("destination", destination.FirstOrDefault());
                ReadSpeech(new MediaElement(), "All Success ");
            }
            catch (Exception ex)
            {
                args.AddArgument("source", "Auntys Place");
                args.AddArgument("destination", "Home");
                //ReadSpeech(new MediaElement(), ex.ToString());
            }
            return(args);
        }
コード例 #5
0
        private async Task <Arguments> ToCustomLocation(VoiceCommandActivatedEventArgs voiceCommandArgs)
        {
            string      slat, dlat, slng, dlng, desiredLocation, token;
            GeoResponse locationResponse;
            CabsAPI     api           = new CabsAPI();
            var         localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            token = localSettings.Values["Token"].ToString();
            IReadOnlyList <string> voiceCommandPhrases;

            if (voiceCommandArgs.Result.SemanticInterpretation.Properties.TryGetValue("location", out voiceCommandPhrases))
            {
                desiredLocation = voiceCommandPhrases.First();
            }
            else
            {
                desiredLocation = "";
            }
            Geolocator locator = new Geolocator();

            locator.DesiredAccuracyInMeters = 50;
            var position = await locator.GetGeopositionAsync();

            slat = position.Coordinate.Point.Position.Latitude.ToString();
            slng = position.Coordinate.Point.Position.Longitude.ToString();
            string             source;
            ReverseGeoResposne current = await api.GetReverseCodingResultlatlng(token, position.Coordinate.Point.Position.Latitude.ToString() + "," + position.Coordinate.Point.Position.Longitude.ToString());

            try
            {
                source = current.FormattedAddress.Substring(0, current.FormattedAddress.IndexOf(", Hyderabad"));
            }
            catch
            {
                source = current.FormattedAddress;
            }
            ReadSpeech(new MediaElement(), source);
            ReadSpeech(new MediaElement(), desiredLocation);
            locationResponse = await api.GeoCodingResult(token, desiredLocation);

            if (locationResponse.Code == ResponseCode.SUCCESS)
            {
                dlat = locationResponse.Position.Latitude;
                dlng = locationResponse.Position.Longitude;
                PriceEstimateResponse mResponseprice = await api.GetEstimate(token, slat, slng, dlat, dlng);

                if (mResponseprice.Code == ResponseCode.SUCCESS)
                {
                    List <CabEstimate> desiredList = mResponseprice.Estimates;
                    var sortedCabs = desiredList.OrderBy(o => o.CurrentEstimate.HighRange);
                    Dictionary <string, object> Parameters = new Dictionary <string, object>();
                    Parameters.Add("location", desiredLocation);
                    Parameters.Add("source", source);
                    Parameters.Add("list", desiredList);
                    Arguments data = new Arguments(null);
                    data.AddType(VoiceCommandType.IF_FROM_APP, true);
                    data.AddType(VoiceCommandType.BOOK_TO_CUSTOM_LOCATION, true);
                    data.Values = Parameters;
                    return(data);
                }
                else
                {
                    await new MessageDialog("Errors fetching estimates").ShowAsync();
                    return(null);
                }
            }
            else
            {
                await new MessageDialog("Errors fetching cordinates").ShowAsync();
                return(null);
            }
        }
コード例 #6
0
        private async Task <Arguments> ProcessBookCheapest(VoiceCommandActivatedEventArgs voiceCommandArgs)
        {
            string      slat, dlat, slng, dlng, mSource, mDestination, token;
            GeoResponse mResponse;
            CabsAPI     api           = new CabsAPI();
            var         localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            token = localSettings.Values["Token"].ToString();
            IReadOnlyList <string> voiceCommandPhrases;

            if (voiceCommandArgs.Result.SemanticInterpretation.Properties.TryGetValue("source", out voiceCommandPhrases))
            {
                mSource = voiceCommandPhrases.First();
            }
            else
            {
                mSource = "";
            }
            if (voiceCommandArgs.Result.SemanticInterpretation.Properties.TryGetValue("destination", out voiceCommandPhrases))
            {
                mDestination = voiceCommandPhrases.First();
            }
            else
            {
                mDestination = "";
            }
            if (mSource == "")
            {
                Geolocator locator = new Geolocator();
                locator.DesiredAccuracyInMeters = 50;
                var position = await locator.GetGeopositionAsync();

                slat = position.Coordinate.Point.Position.Latitude.ToString();
                slng = position.Coordinate.Point.Position.Longitude.ToString();
                ReverseGeoResposne mRevResponse = await api.GetReverseCodingResultlatlng(token, position.Coordinate.Point.Position.Latitude.ToString() + "," + position.Coordinate.Point.Position.Longitude.ToString());

                //mSource = mRevResponse.FormattedAddress;
                try
                {
                    mSource = mRevResponse.FormattedAddress.Substring(0, mRevResponse.FormattedAddress.IndexOf(", Hyderabad"));
                }
                catch
                {
                    mSource = mRevResponse.FormattedAddress;
                }
                System.Diagnostics.Debug.WriteLine("source is" + mSource);
            }
            else
            {
                mResponse = await api.GeoCodingResult(token, mSource);

                if (mResponse.Code == ResponseCode.SUCCESS)
                {
                    slat = mResponse.Position.Latitude;
                    slng = mResponse.Position.Longitude;
                }
                else
                {
                    await new MessageDialog("Errors fetching source cordinates").ShowAsync();
                    return(null);
                }
            }
            if (mDestination == "")
            {
                await new MessageDialog("No Destination provided").ShowAsync();
                return(null);
            }
            else
            {
                mResponse = await api.GeoCodingResult(token, mDestination);

                if (mResponse.Code == ResponseCode.SUCCESS)
                {
                    dlat = mResponse.Position.Latitude;
                    dlng = mResponse.Position.Longitude;
                    PriceEstimateResponse mResponseprice = await api.GetEstimate(token, slat, slng, dlat, dlng);

                    if (mResponseprice.Code == ResponseCode.SUCCESS)
                    {
                        List <CabEstimate> mList = mResponseprice.Estimates;
                        //var sortedCabs = mList.OrderBy(o => o.AverageEstimate);
                        Dictionary <string, object> Parameters = new Dictionary <string, object>();
                        Parameters.Add("source", mSource);
                        Parameters.Add("destination", mDestination);
                        Parameters.Add("list", mList);
                        Arguments data = new Arguments(null);
                        data.AddType(VoiceCommandType.IF_FROM_APP, true);
                        data.AddType(VoiceCommandType.BOOK_CHEAPEST_TO_DEST, true);
                        data.AddType(VoiceCommandType.BOOK_ME_CHEAPEST_CAB_FROM_X_TO_Y, true);
                        data.Values = Parameters;
                        return(data);
                    }
                    else
                    {
                        await new MessageDialog("Error fetching estimaates").ShowAsync();
                        return(null);
                    }
                }
                else
                {
                    await new MessageDialog("Error retrieving Destination cordinates").ShowAsync();
                    return(null);
                }
            }
        }