コード例 #1
0
        public void RemoveExamInfo(ExamFileInfo info)
        {
            ExamFileCatalogueInfo examCatalogue;

            using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream("examCatalogue.json", FileMode.Open, _isolatedStorageFile))
            {
                using (StreamReader reader = new StreamReader(isoStream))
                    examCatalogue = JsonConvert.DeserializeObject <ExamFileCatalogueInfo>(reader.ReadToEnd());
            }

            int index = -1;

            for (int i = 0; i < examCatalogue.ExamFileInfos.Count; i++)
            {
                if (examCatalogue.ExamFileInfos[0].Id.Equals(info.Id))
                {
                    index = i;
                    break;
                }
            }

            if (index > -1)
            {
                examCatalogue.ExamFileInfos.RemoveAt(index);
            }

            _isolatedStorageFile.DeleteFile("examCatalogue.json");

            using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream("examCatalogue.json", FileMode.CreateNew, _isolatedStorageFile))
            {
                using (StreamWriter writer = new StreamWriter(isoStream))
                    writer.Write(JsonConvert.SerializeObject(examCatalogue));
            }
        }
コード例 #2
0
        public Exam LoadExam(ExamFileInfo examInfo)
        {
            if (File.Exists(examInfo.Path))
            {
                return(JsonConvert.DeserializeObject <Exam>(File.ReadAllText(examInfo.Path)));
            }

            return(null);
        }
コード例 #3
0
        public void BeginExam(ExamFileInfo examInfo)
        {
            ExamSession session = _uiManager.ShowExamConfigurationView(examInfo);

            if (session != null)
            {
                BeginExamSession(session);
            }

            OnExamCompleted?.Invoke(null, session == null ? ExamOutcome.NotStarted : ExamOutcome.Completed);
        }
コード例 #4
0
        public ExamSession ShowExamConfigurationView(ExamFileInfo examInfo)
        {
            Exam exam = _storageManager.LoadExam(examInfo);

            _examConfigurationView.ShowDialog(Application.OpenForms[0], exam);

            if (_examConfigurationView.CustomCloseReason == CustomCloseReason.ok)
            {
                return(_examConfigurationView.ExamSession);
            }

            return(null);
        }