//Load Selected Gesture private void GesturesList_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (((ComboBox)sender).SelectedItem == null) { return; } if (((ComboBox)sender).SelectedItem.ToString() != "NEWGESTURE") { BTCGesture temp = btc.GetGesture(((ComboBox)sender).SelectedItem.ToString()); if ((StartPose.Items.IndexOf(temp.StartPose) == -1) || (EndPose.Items.IndexOf(temp.EndPose) == -1)) { MessageBox.Show("Please Load The Correct List For Pose :" + temp.StartPose + " & " + temp.EndPose); GesturesList.SelectedIndex = GesturesList.Items.IndexOf("NEWGESTURE"); return; } GestureID.Text = temp.ID; GestureValue.Text = temp.value; GestureTime.Text = temp.MaxDuration.ToString(); EndHoldTime.Text = temp.EndPoseHold.ToString(); StartPose.SelectedIndex = StartPose.Items.IndexOf(temp.StartPose); EndPose.SelectedIndex = EndPose.Items.IndexOf(temp.EndPose); } else { GestureID.Text = ""; GestureValue.Text = ""; GestureTime.Text = "0.0"; EndHoldTime.Text = "0.0"; StartPose.SelectedItem = null; EndPose.SelectedItem = null; } }
//// Save Gesture private void Save_Gesture_Button(object sender, RoutedEventArgs e) { if ((string.IsNullOrWhiteSpace(GestureValue.Text)) || (string.IsNullOrWhiteSpace(GestureID.Text))) { MessageBox.Show("ID and Return Value can not be Empty"); return; } if (string.IsNullOrEmpty(StartPose.Text) || string.IsNullOrEmpty(EndPose.Text)) { MessageBox.Show("Select Start and End Pose"); return; } //Check if gesture exists BTCGesture temp = btc.GetGesture(GestureID.Text); // If is a new gesture if (temp == null) { //create gesture temp = new BTCGesture(); temp.StartPose = StartPose.Text; temp.EndPose = EndPose.Text; temp.MaxDuration = float.Parse(GestureTime.Text); temp.ID = GestureID.Text; temp.value = GestureValue.Text; temp.EndPoseHold = double.Parse(EndHoldTime.Text); btc.AddGesture(temp, true); interfaceManager.UpdateGesturesLists(); MessageBox.Show("Gesture Saved"); } else { // if gesture exists if (MessageBox.Show("Update Gesture ?", "Gesture Exist", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { //Update gesture temp.StartPose = StartPose.Text; temp.EndPose = EndPose.Text; temp.MaxDuration = float.Parse(GestureTime.Text); temp.ID = GestureID.Text; temp.value = GestureValue.Text; temp.EndPoseHold = double.Parse(EndHoldTime.Text); } } }