コード例 #1
0
        private void setCurrentSubFrame()
        {
            IWiimoteReferenceRecord lRecord = mCurrentTrainingSegment.getReferenceRecord(mCurrentSubVideoIndex);

//            mCurrentTrainingSegment.TrainingReferenceRecord = lRecord;
            mOutputParent.SetCurrentSubFrame(mCurrentSubVideoIndex.ToString() + " : " + lRecord.RecordName);
        }
コード例 #2
0
        private void playTraining(IWiimoteReferenceRecord pReferenceRecord, VideoUserOptions pOptions)
        {
            try
            {
                if (!mTrainingStarted)
                {
                    initializeTraining();
                }

                if (isTrainingVideoRunning())
                {
                    return;
                }

                if (isTrainingVideoPaused())
                {
                    mVideoPlayer.resume();
                    return;
                }

                if (mCurrentVideoIndex == WiimoteDataStore.getWiimoteDataStore().getNumberOfTrainingSegmentInfoRecords())
                {
                    return;
                }

                playTrainingVideo(pReferenceRecord, pOptions);
            }
            catch (WiimoteConnectionException ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        public void newReferenceSelected(DataGridViewRow lTableReferenceRow)
        {
            TrainingSegmentInfo trainingSegmentInfo = (TrainingSegmentInfo)lTableReferenceRow.DataBoundItem;

            //add newly created Wiimote csv file to ReferenceDataStore
            IWiimoteReferenceRecord wiimoteRecord = trainingSegmentInfo.addWiimoteReferenceRecord(ProjectConstants.UNTITLED_REFERENCE_NAME + (trainingSegmentInfo.HighestRecordingItemIndex + 1),
                                                                                                  this.m_parent.VideoPathValue.Text);

            this.m_parent.SetReferenceDataBindingSource(trainingSegmentInfo.WiimoteReferenceRecords);
        }
コード例 #4
0
        public bool playTraining()
        {
            VideoUserOptions        lVideoUserOptions = new VideoUserOptions();
            IWiimoteReferenceRecord lRecord           = mCurrentTrainingSegment.getReferenceRecord(mCurrentSubVideoIndex);

            if (lRecord.SlowMoOption)
            {
                lVideoUserOptions.SlowMo = true;
            }

            playTraining(lRecord, lVideoUserOptions);
            return(true);
        }
コード例 #5
0
        private void startRecording(IWiimoteReferenceRecord pReferenceRecord, int pPrerecordingTime)
        {
            //setup Wiimote recording

            WiimoteDataStore dataStore   = WiimoteDataStore.getWiimoteDataStore();
            string           lDateString = DateTime.Now.Month.ToString() + "_" + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Year.ToString() +
                                           "_" + DateTime.Now.Hour.ToString() + "_" + DateTime.Now.Minute.ToString() + "_" + DateTime.Now.Second.ToString();

            string             lPlayname   = "Play" + pReferenceRecord.RecordName + "_" + lDateString;
            IWiimotePlayRecord lPlayRecord = mCurrentTrainingSegment.addWiimotePlayRecord(lPlayname, DateTime.Today, 0);

            mWiimotes.startRecording(lPlayRecord, false, this, "", false);
            mRecordingStarted = true;
            System.Threading.Thread.Sleep(pPrerecordingTime);
        }
コード例 #6
0
        private void playTrainingVideo(IWiimoteReferenceRecord pReferenceRecord, VideoUserOptions pOptions)
        {
            try
            {
                OpenTrainingVideo(ProjectConstants.PROJECT_MEDIA_PATH + @"\" + pReferenceRecord.VideoPath, pOptions);
                mVideoPlayer.VideoPlayCompleteEvent += new EventHandler(videoCompletedEvent);
                mVideoPlayer.FrameMilestoneEvent    += new EventHandler(frameMilestoneEvent);

                if (pReferenceRecord.ScoringOption)
                {
                    //Check to see if there is an event (Recording event) in the frame info.
                    //If there is a recording  event it indicates that recording needs to be started at that time
                    //and not right in the beginning
                    System.Collections.ObjectModel.ReadOnlyCollection <string> lEventList = mVideoPlayer.getFrameEventList();
                    bool lWiimoteEvent = false;
                    if (lEventList != null)
                    {
                        foreach (string lEventName in lEventList)
                        {
                            if (lEventName.CompareTo(ProjectConstants.TRAINING_START_RECORDING_EVENT_STRING) == 0)
                            {
                                lWiimoteEvent = true;
                            }
                        }
                    }


                    //If there is no recording event , the recording can be started right away
                    //Also start Wiimote recording a little earlier than the video play so there is some buffer recording
                    //before the actual movement starts
                    if (!lWiimoteEvent)
                    {
                        startRecording(pReferenceRecord, Configuration.getConfiguration().TrainingPreRecordingTime);
                    }
                }

                mVideoPlayer.play();

                if (pReferenceRecord.ScoringOption)
                {
                    mWiimotes.addInformationToRecording(START_VIDEO_CODE);
                }
            }
            catch (WiimoteConnectionException ex)
            {
                throw;
            }
        }
コード例 #7
0
        public bool scoreTraining()
        {
            if (!mCurrentTrainingSegment.ScoringOption)
            {
                return(false);
            }

            IWiimoteReferenceRecord lScoringReferenceRecord = mCurrentTrainingSegment.getScoringReferenceRecord();

            if (lScoringReferenceRecord == null)
            {
                return(false);
            }

            VideoUserOptions lOptions = new VideoUserOptions();

            playTraining(lScoringReferenceRecord, lOptions);
            return(true);
        }
コード例 #8
0
ファイル: Wiimotes.cs プロジェクト: ewin66/TRapperProject
        public string comparePlayToReference(IWiimoteReferenceRecord l_ReferenceRecord, IWiimotePlayRecord l_PlayRecord)
        {
            WiimoteReferenceRecordingItem l_ReferenceRecordingItem = l_ReferenceRecord.SelectedRecordingItem;

            if (l_ReferenceRecordingItem == null)
            {
                l_PlayRecord.Score         = 1;
                l_PlayRecord.NumberOfStars = (int)1;
                return("");
//                throw new WiimoteRecordingException("No Default Recording is selected from the Reference List");
            }

            double score, stars;

            string message = m_WiimoteDataAdaptor.getScore((IWiimoteChildRecord)l_ReferenceRecordingItem, (IWiimoteChildRecord)l_PlayRecord, out score, out stars);

            l_PlayRecord.Score         = score;
            l_PlayRecord.NumberOfStars = (int)stars;

            return(message);
        }
コード例 #9
0
        public bool slowMoTraining()
        {
            if (!mCurrentTrainingSegment.SlowMoOption)
            {
                return(false);
            }

            VideoUserOptions lOptions = new VideoUserOptions();

            lOptions.SlowMo = true;

            IWiimoteReferenceRecord lSlowMoReferenceRecord = mCurrentTrainingSegment.getSlowMoReferenceRecord();

            if (lSlowMoReferenceRecord == null)
            {
                return(false);
            }

            playTraining(lSlowMoReferenceRecord, lOptions);
            return(true);
        }
コード例 #10
0
        public string comparePlayToReference(IWiimoteReferenceRecord l_ReferenceRecord, IWiimotePlayRecord l_PlayRecord)
        {
            WiimoteReferenceRecordingItem l_ReferenceRecordingItem = l_ReferenceRecord.SelectedRecordingItem;

            if (l_ReferenceRecordingItem == null)
            {
                l_PlayRecord.Score = 1;
                l_PlayRecord.NumberOfStars = (int)1;
                return "";
            //                throw new WiimoteRecordingException("No Default Recording is selected from the Reference List");
            }

            double score, stars;

            string message = m_WiimoteDataAdaptor.getScore((IWiimoteChildRecord)l_ReferenceRecordingItem, (IWiimoteChildRecord)l_PlayRecord, out score, out stars);

            l_PlayRecord.Score = score;
            l_PlayRecord.NumberOfStars = (int)stars;

            return message;
        }
コード例 #11
0
        private void startRecording(IWiimoteReferenceRecord pReferenceRecord,int pPrerecordingTime)
        {
            //setup Wiimote recording

            WiimoteDataStore dataStore = WiimoteDataStore.getWiimoteDataStore();
            string lDateString = DateTime.Now.Month.ToString() + "_" + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Year.ToString() +
                "_" + DateTime.Now.Hour.ToString() + "_" + DateTime.Now.Minute.ToString() + "_" + DateTime.Now.Second.ToString();

            string lPlayname = "Play" + pReferenceRecord.RecordName + "_" + lDateString;
            IWiimotePlayRecord lPlayRecord = mCurrentTrainingSegment.addWiimotePlayRecord(lPlayname, DateTime.Today, 0);
            mWiimotes.startRecording(lPlayRecord, false, this, "", false);
            mRecordingStarted = true;
            System.Threading.Thread.Sleep(pPrerecordingTime);
        }
コード例 #12
0
        private void playTrainingVideo(IWiimoteReferenceRecord pReferenceRecord, VideoUserOptions pOptions)
        {
            try
            {
                OpenTrainingVideo(ProjectConstants.PROJECT_MEDIA_PATH + @"\" + pReferenceRecord.VideoPath, pOptions);
                mVideoPlayer.VideoPlayCompleteEvent += new EventHandler(videoCompletedEvent);
                mVideoPlayer.FrameMilestoneEvent += new EventHandler(frameMilestoneEvent);

                if (pReferenceRecord.ScoringOption)
                {

                    //Check to see if there is an event (Recording event) in the frame info.
                    //If there is a recording  event it indicates that recording needs to be started at that time
                    //and not right in the beginning
                    System.Collections.ObjectModel.ReadOnlyCollection<string> lEventList = mVideoPlayer.getFrameEventList();
                    bool lWiimoteEvent = false;
                    if (lEventList != null)
                    {
                        foreach (string lEventName in lEventList)
                        {
                            if (lEventName.CompareTo(ProjectConstants.TRAINING_START_RECORDING_EVENT_STRING) == 0)
                                lWiimoteEvent = true;
                        }
                    }

                    //If there is no recording event , the recording can be started right away
                    //Also start Wiimote recording a little earlier than the video play so there is some buffer recording
                    //before the actual movement starts
                    if (!lWiimoteEvent)
                        startRecording(pReferenceRecord, Configuration.getConfiguration().TrainingPreRecordingTime);
                }

                mVideoPlayer.play();

                if (pReferenceRecord.ScoringOption)
                    mWiimotes.addInformationToRecording(START_VIDEO_CODE);
            }
            catch (WiimoteConnectionException ex)
            {
                throw;
            }
        }
コード例 #13
0
        private void playTraining(IWiimoteReferenceRecord pReferenceRecord, VideoUserOptions pOptions)
        {
            try
            {
                if (!mTrainingStarted)
                    initializeTraining();

                if (isTrainingVideoRunning())
                    return;

                if (isTrainingVideoPaused())
                {
                    mVideoPlayer.resume();
                    return;
                }

                if (mCurrentVideoIndex == WiimoteDataStore.getWiimoteDataStore().getNumberOfTrainingSegmentInfoRecords())
                    return;

                playTrainingVideo(pReferenceRecord,pOptions);

            }
            catch (WiimoteConnectionException ex)
            {
                throw ex;
            }
        }
コード例 #14
0
        public void videoCompletedEvent(object sender, EventArgs args)
        {
            ConsoleLogger.logMessage("In videoCompletedEvent");
            if (mRecordingStarted) // Need to send this command early as dispose takes some time
            {
                mWiimotes.addInformationToRecording(END_VIDEO_CODE);
            }

            mVideoPlayer.dispose();

            if (mRecordingStarted)
            {
                mWiimotes.stopRecording();
                mRecordingStarted = false;

                IWiimoteReferenceRecord lScoringReferenceRecord = mCurrentTrainingSegment.getScoringReferenceRecord();

                if (!mCurrentTrainingSegment.TrainingPlayRecord.isRecordingValid())
                {
                    MessageBox.Show("Tap Rapper : There is an issue in recording\r\nPlease check your Wiimote connection",
                                    "Tap Rapper Says", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    mOutputParent.SetScoreFeedback("Error in Wiimote Recording", 0);
                    return;
                }

                mWiimotes.comparePlayToReference(mCurrentTrainingSegment.TrainingPlayRecord);

                int lNumStars = mCurrentTrainingSegment.TrainingPlayRecord.NumberOfStars;
                if (lNumStars == 1)
                {
                    lNumStars = 2;
                }

                StringBuilder lFeedbackMessage = new StringBuilder();

                switch (lNumStars)
                {
                case 1: lFeedbackMessage.Append(ProjectConstants.TRAINING_FEEDBACK_FOR_ONE_STAR);
                    break;

                case 2: lFeedbackMessage.Append(ProjectConstants.TRAINING_FEEDBACK_FOR_TWO_STARS);
                    break;

                case 3: lFeedbackMessage.Append(ProjectConstants.TRAINING_FEEDBACK_FOR_THREE_STARS);
                    break;

                case 4: lFeedbackMessage.Append(ProjectConstants.TRAINING_FEEDBACK_FOR_FOUR_STARS);
                    break;

                case 5: lFeedbackMessage.Append(ProjectConstants.TRAINING_FEEDBACK_FOR_FIVE_STARS);
                    break;

                default:
                    break;
                }

                mVideoPlayer.addInformation(lScoringReferenceRecord.RecordName, lNumStars);
                mOutputParent.SetScoreFeedback(lFeedbackMessage.ToString(), lNumStars);
            }

            setCurrentPlay();
        }
コード例 #15
0
        public void moveWiimoteReferenceRecord(IWiimoteReferenceRecord pReferenceRecord, int pPosition)
        {
            WiimoteReferenceRecord lReferenceRecord = (WiimoteReferenceRecord)pReferenceRecord;
            int lIndex = referenceRecordList.IndexOf(lReferenceRecord);

            if (pPosition == ProjectConstants.MOVE_ROW_DOWN)
            {
                referenceRecordList.Remove(lReferenceRecord);
                referenceRecordList.Insert(lIndex + 1, lReferenceRecord);
            }
            else
            {
                if (lIndex > 0)
                {
                    referenceRecordList.Remove(lReferenceRecord);
                    referenceRecordList.Insert(lIndex - 1, lReferenceRecord);
                }
            }
        }