Esempio n. 1
0
        private void initSCM()
        {
            callHistory = new CallHistory();
            if (!callHistory.existsAny())
            {
                callHistory.CallLogHelper(callHistory.getCallLog());
            }

            favorites = new Favorites();
            if (!favorites.existsAny())
            {
                favorites.FavoriteHelper();
            }
        }
Esempio n. 2
0
        private void RemindButton_Click(object sender, RoutedEventArgs e)
        {
            List <PhoneCall> favoriteList      = favorites.GetAllFavorites();
            List <PhoneCall> callList          = callHistory.getCallLog1();
            List <PhoneCall> toCommunicateList = new List <PhoneCall>();

            foreach (PhoneCall fav in favoriteList)
            {
                bool found = false;
                foreach (PhoneCall call in callList)
                {
                    if (fav.PhoneNumber == call.PhoneNumber)
                    {
                        found = found || true;
                    }
                }

                string   callDateTimeStr = fav.CallDateTimeStr;
                DateTime dt        = Convert.ToDateTime(callDateTimeStr);
                double   totalDays = (DateTime.Today - dt).TotalDays;

                if (!found && totalDays >= 30)
                {
                    toCommunicateList.Add(fav);
                }
            }

            foreach (PhoneCall toComm in toCommunicateList)
            {
                CustomMessageBox messageBox = new CustomMessageBox()
                {
                    Message            = String.Format("Do you want to connect with this person {0} ", toComm.Name, toComm.PhoneNumber),
                    Caption            = "Stay connected?",
                    LeftButtonContent  = "Call",
                    RightButtonContent = "Text"
                };

                messageBox.Dismissed += (s1, e1) =>
                {
                    switch (e1.Result)
                    {
                    case CustomMessageBoxResult.LeftButton:
                        var phoneTask = new PhoneCallTask
                        {
                            DisplayName = toComm.Name,
                            PhoneNumber = toComm.PhoneNumber.ToString()
                        };
                        phoneTask.Show();
                        Favorites.Update(toComm);
                        populateFavoritesList();

                        break;

                    case CustomMessageBoxResult.RightButton:
                        SmsComposeTask smsComposeTask = new SmsComposeTask();
                        smsComposeTask.To   = toComm.PhoneNumber.ToString();
                        smsComposeTask.Body = "Hey how have you been doing!";
                        smsComposeTask.Show();
                        Favorites.Update(toComm);
                        populateFavoritesList();

                        break;

                    case CustomMessageBoxResult.None:
                        // Do something.
                        break;

                    default:
                        break;
                    }
                };

                messageBox.Show();
            }
        }