public static void Start(string lessonName, int startSlideNum, string voiceName) { Debug.WriteLine("Start lesson" + Directory.GetCurrentDirectory()); GlobalFlowControl.Lesson.ResetAll(); //UpperBodyHelper.MoveRandomlyAllMotors(); RobotActionHelper.MoveDuringLesson(); form2 = new LessonSpeechUI(); form2.ShowForm(); _lessonName = lessonName; QuestionNumber = 0; _thread = new Thread(new ThreadStart(() => { int endSlideNum = FileHelper.GetLessonSlidesNumber(lessonName); string codePath = FileHelper.BasePath + @"\" + lessonName + @"\code.pptx"; progData = PowerpointHelper.GetSlidesData(codePath); for (CurrentSlideNumber = 1; CurrentSlideNumber <= endSlideNum; CurrentSlideNumber++) { if (CurrentSlideNumber < startSlideNum) { RobotProgSlide _currentProgSlide = progData[CurrentSlideNumber - 1]; var commands = _currentProgSlide.Commands; foreach (var cmd in commands) { if (cmd.Type.ToLower() == "start" && cmd.Value.ToLower() == "quiz") { QuestionNumber++; } } } else { while (LessonHelper.PauseRequested) { Thread.Sleep(1000); // Remove busy waiting overloading } Debug.WriteLine("Current Slide -----------" + CurrentSlideNumber); LessonStatusHelper.Update(lessonName, CurrentSlideNumber, "started", null, null, null); RobotProgSlide _currentProgSlide = progData[CurrentSlideNumber - 1]; _robotCommands = new RobotCommands(_currentProgSlide.Commands); _robotCommands.OnCommandUpdate += _robotCommands_OnCommandUpdate; _robotCommands.Execute(); } } OnLessonEnded(); })); _thread.Start(); }
private static async void Save(string lessonFolder, string dateModified) { string codePath = lessonFolder + @"\code.pptx"; var lesson = new Lesson(); lesson.Id = DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt"); lesson.Name = Path.GetFileName(lessonFolder); lesson.DateModified = dateModified; lesson.Slides = FileHelper.GetLessonSlidesNumber(lesson.Name); var slidesData = PowerpointHelper.GetSlidesData(codePath); lesson.Teacher_Id = slidesData[0].TeacherId; lesson.Subject = slidesData[0].Subject; var lessonSaved = await WebHelper.AddLesson(lesson); if (lessonSaved == "true") { int _questionNumber = 0; for (int i = 0; i < slidesData.Count; i++) { var question = slidesData[i].Question; if (question != null) { question.Id = 1; question.Lesson_Id = lesson.Id; _questionNumber += 1; question.Number = _questionNumber; WebHelper.AddQuestion(question); } } } else { MessageBox.Show($"Lesson {lesson.Name} not saved!"); } }