//save exercise session to memory //add exercise session to user history info //delete exercise session //This constructor is for when a health care professional adds an exercise to the patient's //profile, rep number not defined //Default Constructor public ExerciseSession() { this.type = exerciseType.pinch; this.state = exerciseState.incomplete; this.addedDate = DateTime.Now; this.attempts = 0; //default number of reps if not indicated this.reps = 5; this.completedReps = 0; }
//This constructor is for when a health care professional adds an exercise to the patient's //profile, rep number defined public ExerciseSession(UserInfo user, exerciseType type, int reps) { //for (UserHistoryData this.user = user; this.type = type; this.state = exerciseState.incomplete; this.addedDate = DateTime.Now; this.attempts = 0; this.reps = reps; this.completedReps = 0; }
public ExerciseSession(UserInfo user, exerciseType type) { //for (UserHistoryData this.user = user; this.type = type; this.state = exerciseState.incomplete; this.addedDate = DateTime.Now; this.attempts = 0; //default number of reps if not indicated this.reps = 5; this.completedReps = 0; }
//This constructor is for copying an existing ExerciseSession, and cancelling the old session ExerciseSession(ExerciseSession old) { this.user = old.user; this.type = old.type; this.state = old.state; old.state = exerciseState.cancelled; this.attempts = old.attempts; this.addedDate = DateTime.Now; old.lastModified = DateTime.Now; this.reps = old.reps; this.completedReps = 0; }
void readSession() { String filename = this.user.getUsername(); StreamReader readstream = new StreamReader(filename + ".txt", true); // add password check? try { this.state = (exerciseState) Int32.Parse(readstream.ReadLine()); this.type = (exerciseType)Int32.Parse(readstream.ReadLine()); this.attempts = Int32.Parse(readstream.ReadLine()); this.reps = Int32.Parse(readstream.ReadLine()); this.completedReps = Int32.Parse(readstream.ReadLine()); this.addedDate = DateTime.Parse(readstream.ReadLine()); this.lastModified = DateTime.Parse(readstream.ReadLine()); this.startTime = DateTime.Parse(readstream.ReadLine()); this.endTime = DateTime.Parse(readstream.ReadLine()); readstream.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
//When exercise is exited before session is complete. void modifyOnIncomplete() { this.state = exerciseState.incomplete; this.endTime = DateTime.Now; this.lastModified = DateTime.Now; this.attempts = this.attempts + 1; }
//When session ends when user has complete exerciese void modifyOnComplete() { this.state = exerciseState.complete; this.endTime = DateTime.Now; this.lastModified = DateTime.Now; }
protected override void Update(GameTime gameTime) { MouseState mouseState = Mouse.GetState(); secondState = Mouse.GetState(); mousePosition.X = mouseState.X; mousePosition.Y = mouseState.Y; int x = Mouse.GetState().X; int y = Mouse.GetState().Y; KeyboardState keyboardState = Keyboard.GetState(); Keys[] pressedKeys; pressedKeys = keyboardState.GetPressedKeys(); patientNameList = new List<string>(); switch (state) { case gameState.titleScreen: if (gamePlayMeditationInstance.State == SoundState.Stopped) { gamePlayMeditationInstance.Volume = 1; gamePlayMeditationInstance.Play(); } else gamePlayMeditationInstance.Resume(); //tells where the mouse can be clicked and responded to for each button //switches to different gameState if clicked in the proper x, y coordinate if (Mouse.GetState().LeftButton == ButtonState.Pressed) { if ((x > 100) && (x < 510)) { if ((y > 300) && (y < 450)) { buttonClick.Play(); state = gameState.kinectCalibrationScreen; } } } GC.Collect(); break; case gameState.enterPatientNameScreen: currentState = Keyboard.GetState(); if (previousState != currentState) { for (int i = 0; i < pressedKeys.Length; ++i) { patientNameList.Add(pressedKeys[i].ToString()); if (keyboardState.IsKeyDown(Keys.Back)) { text = text.Remove(text.Length - 1, 1); } else if (keyboardState.IsKeyDown(Keys.Space)) { text = text + " "; } else { text = text + patientNameList[i]; } } } if (Mouse.GetState().LeftButton == ButtonState.Pressed) { if ((x > 225) && (x < 375)) { if ((y > 300) && (y < 375)) { buttonClick.Play(); state = gameState.kinectCalibrationScreen; } } } previousState = currentState; GC.Collect(); break; case gameState.kinectCalibrationScreen: if (count < 25) { elevation = calculate.getCameraAngle(head.Position.Y, head.Position.Z, rightFoot.Position.Y, leftFoot.Position.Y); elevation = elevation * -1; elevation2 = (int)(Math.Floor(elevation + .5)); count += 1; } if (count >= 25) { if (isfirst == true) { kinectSensor.ElevationAngle = elevation2; } isfirst = false; } state = gameState.excerciseChoiceScreen; break; case gameState.excerciseChoiceScreen: //tells where the mouse can be clicked and responded to for each button //switches to different gameState if clicked in the proper x, y coordinate if (Mouse.GetState().LeftButton == ButtonState.Pressed) { if (firstState != secondState) { if ((x > 68) && (x < 212)) { if ((y > 100) && (y < 160)) { buttonClick.Play(); state = gameState.areYouSureScreen; exState = exerciseState.rightArm; } else if ((y > 247) && (y < 310)) { buttonClick.Play(); state = gameState.areYouSureScreen; exState = exerciseState.rightLeg; } } if ((x > 342) && (x < 486)) { if ((y > 100) && (y < 160)) { buttonClick.Play(); state = gameState.areYouSureScreen; exState = exerciseState.leftArm; } else if ((y > 247) && (y < 310)) { buttonClick.Play(); state = gameState.areYouSureScreen; exState = exerciseState.leftLeg; } } } } firstState = secondState; GC.Collect(); break; case gameState.areYouSureScreen: if (firstState != secondState) { if (Mouse.GetState().LeftButton == ButtonState.Pressed) { if ((y > 250) && (y < 310)) { // user picks YES if ((x > 52) && (x < 200)) { buttonClick.Play(); startTime = DateTime.Now; state = gameState.mainGame; } //user picks NO+ else if ((x > 410) && (x < 550)) { buttonClick.Play(); state = gameState.excerciseChoiceScreen; } } } } firstState = secondState; break; case gameState.saveScreen: //tells where the mouse can be clicked and responded to for each button //switches to different gameState if clicked in the proper x, y coordinate if (firstState != secondState) { if (Mouse.GetState().LeftButton == ButtonState.Pressed) { if ((y > 250) && (y < 310)) { // user picks YES if ((x > 52) && (x < 200)) { buttonClick.Play(); recordSkeleton.StopRecording(); gamePlayMeditationInstance.Stop(); applause.Play(); foreach (string k in skeletalJointFileNames) { string sourcePath = @"C:\Users\Josh\Desktop\Kinect_Stroke1.6\Kinect_Stroke\Kinect_Stroke\bin\x86\Debug\" + k; string targetFolder = @"c:\Kinect_Skeletal_Point_Data\" + text + "\\" + exState; // Create sub-folder if necessary. if (Directory.Exists(targetFolder) == false) { Directory.CreateDirectory(targetFolder); } // Build full path for target folder and file. FileInfo docFileInfo = new FileInfo(sourcePath); string targetPath = string.Format(@"{0}\{1}", targetFolder, docFileInfo.Name); // Delete old copy if necessary - copy will not work if it already exists // in the target folder. if (File.Exists(targetPath)) { File.Delete(targetPath); } // Copy file to target folder. File.Copy(sourcePath, targetPath); } state = gameState.savingPromptScreen; } //user picks NO+ else if ((x > 410) && (x < 550)) { buttonClick.Play(); gamePlayMeditationInstance.Stop(); state = gameState.titleScreen; } } } } startTime2 = DateTime.Now; firstState = secondState; GC.Collect(); break; case gameState.savingPromptScreen: endTime2 = DateTime.Now; timeSpan2 = endTime2 - startTime2; if (timeSpan2.TotalSeconds > 10) { state = gameState.titleScreen; } break; case gameState.mainGame: currentState = Keyboard.GetState(); if (gamePlayMeditationInstance.State == SoundState.Stopped) { gamePlayMeditationInstance.Volume = 1; gamePlayMeditationInstance.Play(); } else gamePlayMeditationInstance.Resume(); if (previousState != currentState) { if (keyboardState.IsKeyDown(Keys.R)) { flagSecondCount = true; } if (keyboardState.IsKeyDown(Keys.P)) { if (isPaused == true) { isPaused = false; } else isPaused = true; } if (isPaused == true) { gamePlayMeditationInstance.Pause(); } //if spacebar is pressed, game switches to save screen if (Keyboard.GetState().IsKeyDown(Keys.Space)) { buttonClick.Play(); state = gameState.saveScreen; } } previousState = currentState; break; } if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { this.Exit(); } if (countRecord % 10 == 0) { recordSkeleton.StopRecording(); } countRecord++; base.Update(gameTime); }