private void jointSelectionChanged(object sender, RoutedEventArgs e) { if (IsLoaded && sender.GetType() == typeof(CheckBox)) { var box = (CheckBox)sender; var joint = FubiUtils.getJointID(box.Name); if (UseHand) { var handJoint = FubiUtils.getHandJointID(box.Name); if (handJoint != FubiUtils.SkeletonHandJoint.NUM_JOINTS) { joint = (FubiUtils.SkeletonJoint)handJoint; } } if (joint != FubiUtils.SkeletonJoint.NUM_JOINTS) { if (box.IsChecked == true) { if (SelectedJoints.Count == 0 || (Type == XMLGenerator.RecognizerType.TemplateRecording && SelectedJoints[SelectedJoints.Count - 1].Relative != FubiUtils.SkeletonJoint.NUM_JOINTS)) { if (m_type == XMLGenerator.RecognizerType.FingerCount && ((!m_useHand && joint != FubiUtils.SkeletonJoint.LEFT_HAND && joint != FubiUtils.SkeletonJoint.RIGHT_HAND) || (m_useHand && joint != (FubiUtils.SkeletonJoint)FubiUtils.SkeletonHandJoint.PALM))) { box.IsChecked = false; showToolTipOnElement(box, "You can only select the left/right hand or the palm for a " + Type.ToString()); } else { SelectedJoints.Add(new XMLGenerator.RelativeJoint(joint)); box.Background = Brushes.LightGreen; } } else if (SelectedJoints[SelectedJoints.Count - 1].Relative == FubiUtils.SkeletonJoint.NUM_JOINTS && ((SelectedJoints.Count == 1 && (Type == XMLGenerator.RecognizerType.JointRelation || Type == XMLGenerator.RecognizerType.LinearMovement)) || Type == XMLGenerator.RecognizerType.TemplateRecording)) { SelectedJoints[SelectedJoints.Count - 1].Relative = joint; box.Background = Brushes.Yellow; } else { box.IsChecked = false; showToolTipOnElement(box, "You cannot select more joints for a " + Type.ToString()); } } else // box.IsChecked == false { box.Background = Brushes.White; if (SelectedJoints.Count == 1) { if (SelectedJoints[0].Main == joint) { if (SelectedJoints[0].Relative == FubiUtils.SkeletonJoint.NUM_JOINTS) { SelectedJoints.Clear(); } else { SelectedJoints[0].Main = SelectedJoints[0].Relative; SelectedJoints[0].Relative = FubiUtils.SkeletonJoint.NUM_JOINTS; var jointName = FubiUtils.getJointName(SelectedJoints[0].Main); var otherBox = (CheckBox)FindName(jointName); if (otherBox != null) { otherBox.Background = Brushes.LightGreen; } } } else if (SelectedJoints[0].Relative == joint) { SelectedJoints[0].Relative = FubiUtils.SkeletonJoint.NUM_JOINTS; } } else // SelectedJoints.Count > 1 { var relJoint = SelectedJoints.Find(j => j.Main == joint); if (relJoint != null) { if (relJoint.Relative != FubiUtils.SkeletonJoint.NUM_JOINTS) { uncheckJointBox(relJoint.Relative); } SelectedJoints.Remove(relJoint); } relJoint = SelectedJoints.Find(j => j.Relative == joint); if (relJoint != null) { relJoint.Relative = FubiUtils.SkeletonJoint.NUM_JOINTS; } } } } checkSelections(); } }
protected string getJointName(FubiUtils.SkeletonJoint jointID) { return(UseHand ? FubiUtils.getHandJointName((FubiUtils.SkeletonHandJoint)jointID) : FubiUtils.getJointName(jointID)); }
private void uncheckJointBox(FubiUtils.SkeletonJoint joint) { var box = (CheckBox)FindName(UseHand ? FubiUtils.getHandJointName((FubiUtils.SkeletonHandJoint)joint) : FubiUtils.getJointName(joint)); if (box != null) { box.Background = Brushes.White; box.IsChecked = false; } }