Example #1
0
        public Presenter(Application app, SlideShowWindow win)
        {
            app_ = app;
            win_ = win;

            try
            {
                provider_ = new Nui.Provider();
            }
            catch (InvalidOperationException)
            {
                provider_ = null;

                if (MessageBox.Show(
                    "Kinect is not detected. Check the connection and device.\nWould you like to disable Kinect for the presentation?",
                    "Kynapsee", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.Yes)
                {
                    win_.Presentation.SetKinectEnable(false);
                    return;
                }
                win_.View.Exit();
                return;
            }

            gestures_ = win.Presentation.GetNuiModel();

            provider_.GestureDone += GestureDone;
            app.SlideShowNextSlide += SlideShowNextSlide;

            LoadSlideGestures();
        }
        public GesturesViewModel(GestureSet set)
        {
            set_ = set;

            Gestures = new ObservableCollection<GestureItem>(set.Gestures.Select((x) => new GestureItem(this, x)));

            NewGestureCommand = new RelayCommand(NewGesture);
            SaveAndCloseCommand = new RelayCommand(() =>
                                               {
                                                   Save();
                                                   DialogResult = true;
                                               });
            SaveCommand = new RelayCommand(Save);

            try
            {
                StatusText = "Reading gestures...";
                nuiProvider_ = new Nui.Provider(set);

                nuiProvider_.CaptureEnd += NuiProviderCaptureEnd;
                nuiProvider_.CaptureProgress += NuiProviderCaptureProgress;
                nuiProvider_.GestureDone += NuiProviderGestureDone;
            }
            catch (InvalidOperationException)
            {
                StatusText = "No Kinect device connected.";
                nuiProvider_ = null;
            }
        }
Example #3
0
 public void Bind(GestureSet set, Presentation pres)
 {
     Gesture = set.Gestures.Where((x) => x.Guid == guid_).FirstOrDefault();
     try
     {
         TargetSlide = pres.Slides.FindBySlideID(slideId_);
     }
     catch (COMException)
     {
         TargetSlide = null;
     }
 }
Example #4
0
        void UpdatePresentation()
        {
            // Enable states.
            var enabled = model_.Presentation != null;
            if (toggleKinect.Enabled != enabled)
            {
                toggleKinect.Enabled = enabled;
                buttonRun.Enabled = enabled;
                buttonGestures.Enabled = enabled;
                buttonGesturesImport.Enabled = enabled;
                buttonGesturesExport.Enabled = enabled;
            }
            // Update values.
            if (enabled)
            {
                toggleKinect.Checked = model_.Presentation.GetKinectEnable();

                dropSlideTransition.Items.Clear();
                AddDropDownItem(dropSlideTransition, "[none]");
                gestures_ = model_.Presentation.GetNuiModel();
                foreach (var gesture in gestures_.Gestures)
                    AddDropDownItem(dropSlideTransition, gesture.Name);
            }
        }
Example #5
0
        /// <summary>
        /// Creates a new provider on the first found NUI device.
        /// </summary>
        /// <param name="gestures">Gesture model.</param>
        /// <param name="enableColor">Enable color capture.</param>
        /// <param name="enableDepth">Enable depth capture.</param>
        public Provider(GestureSet gestures = null, bool enableColor = false, bool enableDepth = false)
        {
            try
            {

                // limititation: we take the first found Kinect.
                // todo: let the user choose?
                nui_ = Runtime.Kinects[0];

                nui_.Initialize(RuntimeOptions.UseSkeletalTracking
                                | (enableColor ? RuntimeOptions.UseColor : 0)
                                | (enableDepth ? RuntimeOptions.UseDepthAndPlayerIndex : 0));

            }
            catch (Exception)
            {
                throw new InvalidOperationException("There is no connected NUI device.");
            }

            dtw_ = new DtwGestureRecognizer(VectorDimension, JointsTracked, SequenceSimilarityThreshold, FinalPositionThreshold, MaxSlope, MinGestureLength);
            RemoveAllFramesSkeletonTimeSequence();

            if (gestures != null)
            {
                foreach (var gesture in gestures.Gestures)
                {
                    dtw_.AddOrUpdate(gesture);
                }
            }

            nui_.SkeletonFrameReady += SkeletonExtractSkeletonFrameReady;
            sde_.Skeleton3DDataCoordReady += NuiSkeleton3DDataCoordReady;
        }
 public static void SetNuiModel(this Presentation pres, GestureSet model)
 {
     pres.Tags.Add(TagNuiModel, model.ToString());
 }
 public static TransitionSet GetTransitions(this Slide sr, Presentation pr, GestureSet set)
 {
     if (sr.Tags[TagTransitions] == "")
         return new TransitionSet() { Transitions = new List<Transition>() };
     return TransitionSet.FromString(sr.Tags[TagTransitions], set, pr);
 }
Example #8
0
 /// <summary>
 /// Creates the model from a XML string.
 /// </summary>
 /// <param name="data">XML data.</param>
 /// <returns>Model.</returns>
 public static TransitionSet FromString(string data, GestureSet gestures, Presentation pres)
 {
     var tr = (TransitionSet)Xml.Deserialize(new StringReader(data));
     tr.Transitions.ForEach((x) => x.Bind(gestures, pres));
     return tr;
 }