Example #1
0
        /// <summary>
        /// Persists a recorded gesture
        /// </summary>
        /// <param name="args">The recording arguments</param>
        /// <returns>The name of the created file</returns>
        public string SaveGesture(GestureRecordingEventArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("arguments cannot be null");
            }

            if (args.Frames == null ||
                args.Frames.Count == 0)
            {
                throw new ArgumentException("arguments should contain some frames to be serialized");
            }

            if (args.Id == GestureId.Unknown)
            {
                throw new ArgumentException("Invalid gesture id");
            }

            string fileName = string.Format("{0}gesture_{1}.dat", this.GesturesFolder, args.Id.ToString());

            using (FileStream file = new FileStream(fileName, FileMode.Create, FileAccess.Write))
            {
                BinaryFormatter formatter = new BinaryFormatter();
                formatter.Serialize(file, args.Frames);
            }

            return(fileName);
        }
Example #2
0
 private void recordingState_FrameRecorded(object sender, GestureRecordingEventArgs args)
 {
     AddMessage(string.Format("Recording gesture. Frames: {0}", ++frmCount));
 }
Example #3
0
 void recordingState_RecordingStarting(object sender, GestureRecordingEventArgs args)
 {
     AddMessage(string.Format("Recording will start in {0} seconds", RecognitionConstants.PreRecordingIdleTime));
     recordingState.RecordingId = (GestureId)int.Parse(((ComboBoxItem)cmbGestureId.SelectedValue).Content.ToString());
 }
Example #4
0
 private void recordingState_RecordingStarted(object sender, GestureRecordingEventArgs args)
 {
     AddMessage("Perform gesture NOW");
     frmCount = 0;
 }
Example #5
0
 void recordingState_RecordingStopped(object sender, GestureRecordingEventArgs args)
 {
     AddMessage("Gesture recorded");
     Configuration.Instance.SaveGesture(args);
 }