private void appbar_saveclick(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(gesture))
            {
                MessageBox.Show("Please record a new gesture", "Info", MessageBoxButton.OK
                                );
            }

            if (!String.IsNullOrEmpty(gesture))
            {
                if (GesContactsDB.getInstance().getContactData(gesture) == null)
                {
                    if (gestureToBeEdited != null)
                    {
                        GesContactsDB.getInstance().remove(gestureToBeEdited);
                    }
                    String action = "";
                    gestureData = new ContactData()
                    {
                        DisplayName = this.displayName, Number = this.displayNumber, Gesture = this.gesture, Action = action
                    };
                    GesContactsDB.getInstance().add(this.gesture, gestureData);
                    GesContactsDB.getInstance().save();


                    gestureControl.stopAccelerometer();

                    NavigationService.GoBack();
                }
                else
                {
                    MessageBox.Show("Gesture already exists", "Info", MessageBoxButton.OK
                                    );
                }
            }
        }
예제 #2
0
        private void performAction(string gesture)
        {
            /*long previousTS = previousTimeStamp;
             * long nowTimeStamp = getTimeMiliseconds();
             *
             * previousTimeStamp = nowTimeStamp;
             *
             * if (nowTimeStamp - previousTS < 500)
             * {
             *  return;
             * }*/



            if (GesContactsDB.getInstance().getContactData(gesture) != null)
            {
                gestureControl.stopAccelerometer();
                vibrateFeedback();


                // Microsoft.Phone.Applications.Common.AccelerometerHelper.Instance.Active = false;

                ContactData gestureData = GesContactsDB.getInstance().getContactData(gesture);

                if (gestureData == null)
                {
                    return;
                }

                if (gestureData.settings.connectSetting == ContactSettings.CallContact)
                {
                    phoneTask.DisplayName = gestureData.DisplayName;
                    phoneTask.PhoneNumber = gestureData.Number;
                    phoneTask.Show();
                }
                else if (gestureData.settings.connectSetting == ContactSettings.WriteMessage)
                {
                    smsComposeTask.To   = gestureData.DisplayName + "<" + gestureData.Number + ">"; // Mention here the phone number to whom the sms is to be sent
                    smsComposeTask.Body = "";                                                       // the string containing the sms body
                    smsComposeTask.Show();
                }
                else if (gestureData.settings.connectSetting == ContactSettings.SendDistressMessage)
                {
                    gestureData_i = gestureData;
                    //LocationInfo location = new LocationInfo();
                    this.statusBarTB.Text = "Please wait, getting GPS location data...";
                    locationTask.onLocationDataAvailableEvent += onLocationDataAvailable;
                    locationTask.start();

                    /*string latitude = locationTask.latitude;
                     * string longitude = locationTask.longitude;
                     *
                     * string location = "location:{" + latitude + "," + longitude + "}";
                     * smsComposeTask.To = gestureData.DisplayName + "<" + gestureData.Number + ">"; // Mention here the phone number to whom the sms is to be sent
                     * smsComposeTask.Body = "I need help, "+location; // the string containing the sms body
                     * smsComposeTask.Show();*/

                    //  locationTask.stopWatcher();
                }
            }
        }