Exemplo n.º 1
0
        public void LoadExamPaper(BaobaoBook book)
        {
            ExamPaper paper = null;

            AnswerList.Clear();
            QuestionList.Clear();
            if (book != null)
            {
                if (!_books.ContainsKey(book) || _books[book] == null)
                {
                    string examPaper = book.Name;
                    paper = FileSettingsHelper <ExamPaper> .LoadSetting(Path.Combine(ZibaobaoLibContext.Instance.PersistentStorage.DataPath, examPaper));

                    _books[book] = paper;
                }
                else
                {
                    paper = _books[book];
                }
            }
            if (paper != null)
            {
                foreach (var question in paper.Questions)
                {
                    QuestionList.Add(question);
                }

                if (QuestionList.Count > 0)
                {
                    _currentQuestionIndex = -1;
                    CurrentQuestionIndex  = 0;
                }
            }
        }
Exemplo n.º 2
0
        public void LoadQuestionList(DifficultyType type)
        {
            QuestionList.Clear();

            String file = String.Format("{0}{1}/{2}/{3}/{4}.txt", questionRoot, Constants.CONTENT_DIRECTORY, Constants.DATA_DIRECTORY,
                                        Constants.LEVELS_DIRECTORY, type);

            var lines = MyGame.Manager.FileManager.LoadTxt(file);

            foreach (String line in lines)
            {
                Question question = LoadQuestion(line);
                QuestionList.Add(question);
            }
        }
Exemplo n.º 3
0
 private void GenerateCrosswordToolbtn_Click(object sender, EventArgs e)
 {
     if (WordList.Items.Count > 2)
     {
         _words.Sort(Comparer);
         _words.Reverse();
         _order = _words;
         QuestionList.Clear();
         QtextBox.Text = "";
         GenerateCrossword();
     }
     else
     {
         MessageBox.Show("В словаре не достаточно слов", "Оповещение", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemplo n.º 4
0
        private void SaveFile()
        {
            var serializer = new XmlSerializer(typeof(QuestionSet));
            var dialog     = new SaveFileDialog
            {
                Filter       = "Quesiton File (*.qst)|*qst",
                DefaultExt   = "qst",
                AddExtension = true
            };
            var showDialog = dialog.ShowDialog() ?? false;

            if (showDialog)
            {
                QuestionSet qs = new QuestionSet(_questionList);
                using (Stream writer = dialog.OpenFile())
                {
                    serializer.Serialize(writer, qs);
                }

                QuestionList.Clear();
            }
        }
Exemplo n.º 5
0
        public void Load(QuestionList list)
        {
            _list = list;
            _list.Clear();

            FileStream FileToLoad = new FileStream(@_path, FileMode.Open, FileAccess.Read);
            StreamReader Reader = new StreamReader(FileToLoad, System.Text.Encoding.Default);

            Question tmp = new Question();

            for (int i = 0; i < 15; i++)
            {
                tmp = new Question();
                tmp.Question_ = Reader.ReadLine();

                for (int j = 0; j < 4; j++)
                    tmp.Set_Answer(j, Reader.ReadLine());

                _list.Add(tmp);
            }

            Reader.Close();
            FileToLoad.Close();
        }
Exemplo n.º 6
0
        private void Import()
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.DefaultExt = ".xls";                                              // Default file extension
            dialog.Filter     = "Excel 2003 文档|*.xls|Excel 2007 文档|*.xlsx|所有文件|*.*"; // Filter files by extension
            if (dialog.ShowDialog() == true)
            {
                string filename = dialog.FileName;

                string fileType = Path.GetExtension(filename).ToLower();
                try
                {
                    ISheet     sheet       = null;
                    int        sheetNumber = 0;
                    FileStream fs          = new FileStream(filename, FileMode.Open, FileAccess.Read);
                    if (fileType == ".xlsx")
                    {
                        // 2007版本
                        XSSFWorkbook workbook = new XSSFWorkbook(fs);
                        sheet = workbook.GetSheetAt(0);
                        if (sheet != null)
                        {
                            QuestionList.Clear();
                            int count = sheet.LastRowNum;
                            for (int i = 1; i <= count; i++)
                            {
                                QuestionList.Add(new Question()
                                {
                                    Answer  = sheet.GetRow(i).GetCell(1).ToString(),
                                    Subject = sheet.GetRow(i).GetCell(0).ToString()
                                });
                            }
                            RandCount = SumCount = QuestionList.Count;
                        }
                    }
                    else if (fileType == ".xls")
                    {
                        // 2003版本
                        HSSFWorkbook workbook = new HSSFWorkbook(fs);
                        sheetNumber = workbook.NumberOfSheets;
                        sheet       = workbook.GetSheetAt(0);
                        if (sheet != null)
                        {
                            QuestionList.Clear();
                            int count = sheet.LastRowNum;
                            for (int i = 1; i <= count; i++)
                            {
                                QuestionList.Add(new Question()
                                {
                                    Answer  = sheet.GetRow(i).GetCell(1).ToString(),
                                    Subject = sheet.GetRow(i).GetCell(0).ToString()
                                });
                            }
                            RandCount = SumCount = QuestionList.Count;
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemplo n.º 7
0
        public void Load(QuestionList list)
        {
            _list = list;
            _list.Clear();

            Question tmp;

            string QuestExpression = "SELECT * from mainTable";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                  connection.Open();

                  SqlCommand command = new SqlCommand(QuestExpression, connection);
                  SqlDataReader reader = command.ExecuteReader();

                  if (reader.HasRows)
                  {
                      while (reader.Read())
                      {
                          tmp = new Question();
                          tmp.Question_ = reader.GetString(1);
                          tmp.Set_Answers(reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetString(5));
                          list.Add(tmp);
                      }
                  }
            }
        }