Exemple #1
0
        private void ExecuteHostCommand()
        {
            var openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            openFileDialog.DefaultExt       = ".bin";
            var viewModel = new HostExamViewModel();

            if (openFileDialog.ShowDialog() == true)
            {
                var fileName = openFileDialog.FileName;

                var serializer = new ObjectSerialization <Exam>(null, fileName);
                var exam       = serializer.DeSerialize();

                viewModel.Exam = exam;

                CurrentViewModel = viewModel;
            }
        }
Exemple #2
0
        private void ExecuteEditExamCommand()
        {
            var openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            openFileDialog.DefaultExt       = ".bin";
            var viewModel = new CreateExamViewModel();

            if (openFileDialog.ShowDialog() == true)
            {
                var fileName = openFileDialog.FileName;

                var serializer = new ObjectSerialization <Exam>(null, fileName);
                var exam       = serializer.DeSerialize();

                viewModel.ExamName  = exam.ExamTitle;
                viewModel.Questions = new ObservableCollection <BaseQuestion>(exam.QuestionList);
                viewModel.ExamGuid  = exam.ExamId;

                CurrentViewModel = viewModel;
            }
        }