private async void SayFoundAppointment(IAsyncResult result)
        {
//            SpeechSynthesizer synth = new SpeechSynthesizer();
            String detailsString = "", response="";
            Appointment app = result.AsyncState as Appointment;
            if (app == null)
            {
                response = ("You have no such appointment or event in next Year.");
                detailsString = "no appointment maches";
            }
            else
            {
                string TimeString;
                if (app.StartTime.Date.Equals(DateTime.Now.Date))
                    TimeString = "today";
                else if (app.StartTime.Date.Equals(DateTime.Now.Add(new TimeSpan(1, 0, 0, 0)).Date))
                    TimeString = "tomarow";
                else
                    TimeString = "on " + app.StartTime.ToShortDateString();
                if (!app.IsAllDayEvent)
                {
                    if (!app.StartTime.Equals(DateTime.Now.Date) || !app.EndTime.Equals(DateTime.Now.Date.AddDays(1)))
                        TimeString += " at " + app.StartTime.ToShortTimeString();
                }
                if (!app.IsPrivate)
                {
                    response = "You appointment about " + app.Subject + " is " + TimeString;
                    if (app.Location != null)
                        response += " in " + app.Location;
                    detailsString = "Subject: " + app.Subject
                                    + "\r\nFrom: " + app.StartTime.ToLongDateString() + "," +
                                    app.StartTime.ToLongTimeString()
                                    + "\r\nTo: " + app.EndTime.ToLongDateString() + "," +
                                    app.EndTime.ToLongTimeString()
                                    + "\r\nLocation: " + app.Location
                                    + "\r\nDetails:" + app.Details;
                }
                RecentItem = new ResponseItem(AppointmentImageUri, detailsString, response);
                sendViewableResult.Invoke(new Task(o => { }, RecentItem));
                try
                {
                    await SpeechSynthesizer.SpeakTextAsync(response);
                }
                catch (TaskCanceledException) { }
                onFinish.Invoke(new Task(o => { }, "Have Fun"));
            }
            if (onFinish != null)
            {
                onFinish.Invoke(new Task(o => { }, null));
            }
        }
        private async void SayBattery(object sender, RoutedEventArgs e)
        {
//            SpeechSynthesizer synth = new SpeechSynthesizer();
            int battery = Battery.GetDefault().RemainingChargePercent;
            String sentence = string.Format("your phone has {0}% of battery remaining.", battery);
            String detailsString = battery + "% remaining" ;
            RecentItem = new ResponseItem(BatteryImageUri, detailsString, sentence);
            sendViewableResult.Invoke(new Task(o => { }, RecentItem));
            try
            {
                await SpeechSynthesizer.SpeakTextAsync(sentence);
            }
            catch (TaskCanceledException){}
            onFinish.Invoke(new Task(o => { }, "Have Fun"));
        }
        private async Task SayAppointment(Appointment app)
        {
//            SpeechSynthesizer synth = new SpeechSynthesizer();
            String detailsString, response;
            if (app == null)
            {
                response = ("You have no appointments in next weak! have fun.");
                detailsString = "no appointments in next weak";
            }
            else
            {
                string TimeString;
                if (app.StartTime.Date.Equals(DateTime.Now.Date))
                    TimeString = "today";
                else if (app.StartTime.Date.Equals(DateTime.Now.Add(new TimeSpan(1, 0, 0, 0)).Date))
                    TimeString = "tomarow";
                else
                    TimeString = "on " + app.StartTime.DayOfWeek.ToString();
                if (!app.IsAllDayEvent)
                {
                    if (!app.StartTime.Equals(DateTime.Now.Date) || !app.EndTime.Equals(DateTime.Now.Date.AddDays(1)))
                        TimeString += " at " + app.StartTime.ToShortTimeString();
                }
                if (!app.IsPrivate)
                {
                    response = "You have an appointment about " + app.Subject + " " + TimeString;
                    if (app.Location != null)
                        response += " in " + app.Location;
                    detailsString = "Subject: " + app.Subject
                                    + "\r\nFrom: " + app.StartTime.ToLongDateString() + "," +
                                    app.StartTime.ToLongTimeString()
                                    + "\r\nTo: " + app.EndTime.ToLongDateString() + "," +
                                    app.EndTime.ToLongTimeString()
                                    + "\r\nLocation: " + app.Location
                                    + "\r\nDetails:" + app.Details;
                }
                else
                {
                    response = "you have a private appointment " + TimeString;
                    detailsString = "Subject: private"
                                    + "\r\nFrom: " + app.StartTime.ToLongDateString() + "," +
                                    app.StartTime.ToLongTimeString()
                                    + "\r\nTo: " + app.EndTime.ToLongDateString() + "," +
                                    app.EndTime.ToLongTimeString()
                                    + "\r\nLocation: private "
                                    + "\r\nDetails: private";
                }
                RecentItem = new ResponseItem(AppointmentImageUri, detailsString, response);
                sendViewableResult.Invoke(new Task(o => { }, RecentItem));
                try
                {
                    await SpeechSynthesizer.SpeakTextAsync(response);
                }
                catch (TaskCanceledException) { }
                onFinish.Invoke(new Task(o => { }, "Have Fun"));
            }
            if (onFinish != null)
            {
                onFinish.Invoke(new Task(o => { }, null));
            }
        }
        private async void SayDate(String type, DateTime date)
        {
//            SpeechSynthesizer synth = new SpeechSynthesizer();
            String response = "";
            String detailsString = "";
            CultureInfo responseCultureInfo = new CultureInfo("fa-IR");
//            date.ToString("D",)
            String dateString = " an unsupported calendar type. sorry!";
            switch (type)
            {
                case "Gregorian":
                    dateString = date.ToLongDateString();
                    break;
                case "Hejri":

                    dateString = GetDateString(date, new CultureInfo("en-US"));
                    //                    System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar();
                    //                    string cal = hc.ToString();
//                    sentence = ("it's um please wait for next version!");
                    //                    MessageBox.Show(cal);
                    break;
                default:
                    break;

            }
            response = "it's " + dateString;
            detailsString = dateString;
            
            RecentItem = new ResponseItem(DateImageUri, detailsString, response);
            sendViewableResult.Invoke(new Task(o => { }, RecentItem));
            try
            {
                await SpeechSynthesizer.SpeakTextAsync(response);
            }
            catch (TaskCanceledException) { }
            onFinish.Invoke(new Task(o => { }, "Have Fun"));
        }
        private async void Saytime(DateTime time)
        {
//            SpeechSynthesizer synth = new SpeechSynthesizer();
            String response = "it's "+SayTime(time);
            string detailsString = time.ToLongTimeString();
            RecentItem= new ResponseItem(TimeImageUri,detailsString,response);
            sendViewableResult.Invoke(new Task(o => { }, RecentItem));
            try
            {
                await SpeechSynthesizer.SpeakTextAsync(response);
            }
            catch (TaskCanceledException) { }
            onFinish.Invoke(new Task(o => { }, "Have Fun"));
        }
        private async void SayWeather(DateTime date, string place, String orginalDateString)
        {
            WeatherDataManager weatherDataManager = WeatherDataManager.GetInstance();
            String imageuri = WeatherImageUri;
            if (place == "[current]")
            {
                Dictionary<string, Place> dictionaryEntries = WeatherDataManager.GetInstance().getPlaces();
                if (dictionaryEntries.Count != 0)
                {
                    place = dictionaryEntries.GetEnumerator().Current.Key;

                    foreach (KeyValuePair<string, Place> dictionaryEntry in dictionaryEntries)
                    {
                        string key = (string)dictionaryEntry.Key;
                        Place value = dictionaryEntry.Value;
                        if (value.IsLocal)
                            place = key;
                    }    
                }
                if (place == "[current]")
                {
//                    SpeechSynthesizer synth = new SpeechSynthesizer();
                    try
                    {
                        await SpeechSynthesizer.SpeakTextAsync("please set your local location in settings page");
                    }
                    catch (TaskCanceledException e)
                    {
                        
                    }
                    return;
                }

                
            }
            String responseSentence = "";
            String detailsString = "";
            LocalWeather localWeather = weatherDataManager.getWeather(place);
            if (localWeather == null)
            {
                responseSentence = "sorry! but weather data for " + place + " is not available.";
                detailsString = "Sorry! No data :[\r\n" + "please add " + place +
                                   " to your weather checkout list and make sure you connect your phone to internet every few days you can Manually update weather data from App bar";
            }
            else
            {
                Weather.LocalWeather.Weather weatherToShow = null;
                for (int i = 0; i < localWeather.data.weather.Count; i++)
                {
                    Weather.LocalWeather.Weather weather = localWeather.data.weather[i];
                    if (weather.date.Date.Equals(date.Date))
                    {
                        weatherToShow = weather;
                        break;
                    }

                }

                String dateString = date.ToLongDateString();
                dateString = dateString.Substring(0, dateString.Length - 4);
                if (weatherToShow == null)
                {
                    responseSentence = "sorry! but weather data for " + place + " on " + dateString +
                                       " is not available";
                    detailsString = "Sorry! No data :[";
                    imageuri = WeatherImageUri + "/" + "sync.png";
                }
                else
                {


                    responseSentence = "it's " + weatherToShow.weatherDesc[0].value + " at " + place + " on " +
                                       dateString + " the Minimum of  Temperature is " +
                                       GetTemp(weatherToShow.tempMinC, "none") + " and the Maximum is " +
                                       GetTemp(weatherToShow.tempMaxC, "long") +
                                       ".";
                    detailsString = "Location : " + place
                                    + "\r\nDescription: " + weatherToShow.weatherDesc[0].value
                                    + "\r\nMin Temp.: " + GetTemp(weatherToShow.tempMinC ,"short")
                                    + "\r\nMax Temp.: " + GetTemp(weatherToShow.tempMaxC, "short")
                                    + "\r\nWind Speed: " + weatherToShow.windspeedKmph + " Km/h"
                                    + "\r\nWind Degree: " + weatherToShow.winddirDegree;

                    imageuri = (WeatherImageUri + "/" + weatherToShow.weatherCode + ".png");

                }

            }
            RecentItem = new ResponseItem(imageuri,detailsString,responseSentence);
            sendViewableResult.Invoke(new Task(o => { },RecentItem));
//            SpeechSynthesizer synth = new SpeechSynthesizer();
            try
            {
                await SpeechSynthesizer.SpeakTextAsync(responseSentence);
            }
            catch (TaskCanceledException e) { }
            onFinish.Invoke(new Task(o=>{},"Have Fun"));

        }
        private async Task createAlarm(string notification, DateTime dateTime)
        {
            Alarm alarm = new Alarm(Settings.ApplicationName+DateTime.Now);
            alarm.Content = notification;
            alarm.BeginTime = dateTime;
            alarm.ExpirationTime = alarm.BeginTime.AddSeconds(5.0);
            alarm.RecurrenceType = RecurrenceInterval.None;
            ScheduledActionService.Add(alarm);
//            SpeechSynthesizer synth = new SpeechSynthesizer();
            int battery = Battery.GetDefault().RemainingChargePercent;
            String sentence = "alarm created for " + SayTime(dateTime);
            if (notification.Equals("wake me up"))
                sentence += ". Have a good sleep!";
            String detailsString = "alarm created for " + dateTime.ToString();
            RecentItem = new ResponseItem(AlarmImageUri, detailsString, sentence);
            sendViewableResult.Invoke(new Task(o => { }, RecentItem));
            await SpeechSynthesizer.SpeakTextAsync(sentence);
            onFinish.Invoke(new Task(o => { }, "Have Fun"));
        }
        private async Task CreateReminderAndRespond(string reminderAction, string contactName, DateTime reminderTime)
        {
//            SpeechSynthesizer synth = new SpeechSynthesizer();
            string response;
            if (reminderTime.Ticks < DateTime.Now.AddMinutes(2).Ticks)
            {
                response = "sorry. the reminder should be at least in one minuets from now!";
                try
                {
                    await SpeechSynthesizer.SpeakTextAsync(response);
                }
                catch (TaskCanceledException) { }
                onFinish.Invoke(new Task(o => { }, "Have Fun"));
                return;
            }
            String reminderContent = reminderAction + " " + contactName;
            try
            {
                createReminder("reminder", reminderAction + " " + contactName, reminderTime);
            }
            catch (Exception e)
            {
                response = "sorry. couldn't create the reminder! please check if you have disabled background agenst or maybe I have reached the number of allowd reminder and or alerts!";
                try
                {
                    SpeechSynthesizer.SpeakTextAsync(response);
                }
                catch (TaskCanceledException) { }
                onFinish.Invoke(new Task(o => { }, "Have Fun"));
                return;
            }
            response = "reminder created for " + reminderTime.DayOfWeek + " " + SayTime(reminderTime);
            String detailsString = "remindier: " + reminderAction + " " + contactName + "\n\r" + "Date: " +
                                   reminderTime.ToLongDateString()
                                   + "\n\r" + "Time: " + reminderTime.ToLongTimeString();
            RecentItem = new ResponseItem(ReminderImageUri, detailsString, response);
            sendViewableResult.Invoke(new Task(o => { }, RecentItem));
            try
            {
                await SpeechSynthesizer.SpeakTextAsync(response);
            }
            catch (TaskCanceledException) { }
            onFinish.Invoke(new Task(o => { }, "Have Fun"));
        }