Beispiel #1
0
 private void toolMoreInfo_Click(object sender, EventArgs e)
 {
     if (gridUnisuite.SelectedRows.Count != 0 &&
         gridUnisuite.SelectedRows[0].Tag != null)
     {
         int           i     = (int)gridUnisuite.SelectedRows[0].Tag;
         Core.KeySuite suite = Core.Ref.UniSuite[i];
         StringBuilder s     = new StringBuilder();
         s.AppendLine(suite.ToString());
         foreach (Core.Key k in suite.Items)
         {
             s.AppendFormat("{2} Đề: {0}, đáp án: {1} {2}",
                            k.problem, Core.Utility.ClearLook(k.key), Environment.NewLine);
         }
         Core.Utility.Msg(s.ToString());
     }
 }
Beispiel #2
0
        private void gridUnisuite_CreateRow(int index, Core.KeySuite suite)
        {
            DataGridViewRow row = new DataGridViewRow();

            if (index % 2 == 1)
            {
                row.DefaultCellStyle.BackColor = HighlightColor;
            }
            //StringBuilder description = new StringBuilder(string.Format("Số đề: {0}. Các mã: ", suite.Items.Length),1000);
            ////string date = "";
            //if (suite.Items.Length == 0) return;
            ////else date = suite.Items[0].date.ToString("dd/MM/yyyy hh:mm");
            //foreach (Core.Key key in suite.Items)
            //    description.AppendFormat("{0}, ", key.problem);
            row.CreateCells(gridUnisuite, suite.name, suite.ToString());
            row.Tag = index;
            gridUnisuite.ClearSelection();
            gridUnisuite.Rows.Add(row);
            row.Selected = true;
        }
Beispiel #3
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     Core.KeySuite keysuite = new Core.KeySuite();
     keysuite.name = "";
     if (listSubject.SelectedItems != null && listSubject.SelectedItems.Count >= 1)
     {
         keysuite.name = listSubject.SelectedItems[0].ToolTipText;
     }
     saveFileDialog.Filter = UI.Properties.Settings.Default.KeyFileFilter;
     // Tên file mặc định là môn và ngày tháng
     saveFileDialog.FileName = keysuite.name + DateTime.Now.ToString(" ddMMyyyy-hhmm");
     keysuite.name          += " {0}" + DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss");
     if (saveFileDialog.ShowDialog() == DialogResult.OK)
     {
         keysuite.questions = (int)Math.Round(numQuestions.Value);
         keysuite.portion   = trackTestPortion.Value;
         for (int i = 0; i < gridProblems.RowCount - 1; i++)
         {
             Core.Key key = new Core.Key();
             key.date = DateTime.Now;
             if (gridProblems.Rows[i].Cells["colProblem"].Value != null &&
                 gridProblems.Rows[i].Cells["colKey"].Value != null)
             {
                 key.problem = (int)gridProblems.Rows[i].Cells["colProblem"].Value;
                 key.key     = (string)gridProblems.Rows[i].Cells["colKey"].Value;
                 if (key.problem == 0 || key.key == "")
                 {
                     continue;
                 }
                 keysuite.AddItem(key);
             }
         }
         Core.Utility.XmlSerialize(saveFileDialog.FileName, keysuite, Core.Utility.MyXmlFileType.KeySuite,
                                   ((FormMain)this.MdiParent).toolProgressStrip,
                                   ((FormMain)this.MdiParent).toolStatusText);
         // Tự động thêm key suite mới vào Unisuite
         FormNewsuite.newSuiteIndex = Core.Ref.UniSuite.Add(keysuite);
         this.Close();
     }
 }
Beispiel #4
0
        private void toolBtnRecognize_Click(object sender, EventArgs e)
        {
            if (_isRecognized)
            {
                return;
            }
            if (Core.Ref.UniSuite.ActiveSuiteIndex == -1)
            {
                Core.Utility.Msg("Chưa có bộ đáp án nào được chọn");
                return;
            }
            _keys = Core.Ref.UniSuite.ActiveSuite;
            // Tạm dừng hoạt động, tránh người sử dụng bấm lung tung -> hỏng việc
            // : )

            toolBtnRecognize.Enabled = false;
            #region Xác định nguồn dữ liệu quuét
            Hashtable tag = (Hashtable)this.Tag;
            _automate          = new Core.Automate();
            _automate.CoreMsg += new Core.CoreMsgEventHandler(CoreMsg_Handler);
            switch ((Core.Automate.Source)tag[TagKeys.AutomateSource])
            {
            case Core.Automate.Source.Files:
                _files = (string[])tag[TagKeys.Files];
                break;

            case Core.Automate.Source.Folder:
                _automate.Folder((string)tag[TagKeys.Path]);
                _files = _automate.FileList;
                break;
            }
            if (_files == null)
            {
                _automate.Inform(_automate, "Không có tệp nào.");
                return;
            }
            UseWaitCursor = true;
            #endregion
            #region Kiểu cũ: dựa vào dropDown
            //if (tag[TagKeys.KeySuite] != null && Core.Ref.UniSuite[(int)tag[TagKeys.KeySuite]] != null)
            //    // Lấy thẳng từ tag của form trỏ đến Unisuite
            //    _keys = Core.Ref.UniSuite[(int)tag[TagKeys.KeySuite]] as Core.KeySuite;
            //else
            //{
            //    // Tìm nguồn suite thay thế
            //    DialogResult doAction = MessageBox.Show(string.Format(
            //        "Chưa có bộ đáp án nào được chuyển đến để chấm điểm.{0}" +
            //        "\tChọn Yes nếu muốn *tạo mới* một bộ đáp án.{0}" +
            //        "\tChọn No nếu muốn *mở hay nạp* một bộ đáp án có sẵn.{0}" +
            //        "\tChọn Cancel để nhận dạng bài làm thuần tuý Trong lúc đó bạn sẽ nhập bộ đáp án {0}" +
            //        "\tvà việc lên điểm diễn ra sau cùng.", Environment.NewLine),
            //        UI.Properties.Settings.Default.WindowCaption, MessageBoxButtons.YesNoCancel,
            //        MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            //    switch (doAction)
            //    {
            //        case DialogResult.Yes:
            //            #region Tạo mới một bộ đáp án và chuyển luôn vào của sổ hiện tại

            //                FormNewsuite fns = new FormNewsuite();
            //                fns.MdiParent = this.MdiParent;
            //                this.Enabled = false;
            //                fns.Show();
            //                fns.FormClosing += new FormClosingEventHandler(fns_FormClosing);
            //                return;


            //            #endregion
            //        case DialogResult.No:
            //            #region Mở một bộ đáp án có sẵn

            //            ToolStripMenuItem mnuFile = (this.ParentForm.MainMenuStrip.Items["mnuFile"]) as ToolStripMenuItem;
            //            ToolStripMenuItem mnuFileOpen = mnuFile.DropDownItems["mnuFileOpen"] as ToolStripMenuItem;
            //            if (mnuFileOpen == null)
            //            {
            //                Core.Utility.Error("Develop: Không tìm thấy chức năng Open trong menu File");
            //                return;
            //            }
            //            mnuFileOpen.PerformClick();
            //            if (mnuFileOpen.Tag == null)
            //            {
            //                Core.Utility.Msg("Quá trình chấm điểm dừng do không có tệp nào *được chọn*.");
            //            }
            //            else
            //            {
            //                _keys = Core.Ref.UniSuite[(int)mnuFileOpen.Tag] as Core.KeySuite;
            //            }
            //            break;
            //            #endregion
            //        case DialogResult.Cancel:
            //            #region Quét ngầm, tạo mới đáp án, lên điểm sau cùng.
            //            return;

            #endregion
            #region Chấm
            gridMark.Hide();
            _numberBlurSources = 0;
            UseWaitCursor      = true;
            int ri;// result index in Discovers
            for (int i = 0; i < _files.Length; i++)
            {
                txtLog.AppendText(string.Format("{1}#{0}{1}", i, Environment.NewLine));
                Core.Discover result = _automate.OneFileG2(_files[i], ref _keys);
                #region Chuyển kết quả vào grid và cập nhật trạng thái
                if (result != null)
                {
                    result.date = DateTime.Now;
                    ri          = this.Result.AddItem(result);
                    gridMark_Populate(result, ri, _files[i]);
                }
                progressBar.Value = (int)((i + 1) * 100.0f / _files.Length);
                #endregion
            }
            #endregion
            UseWaitCursor = false;
            Cursor        = Cursors.WaitCursor;
            System.Media.SystemSounds.Beep.Play();
            if (_numberBlurSources != 0)
            {
                Core.Utility.Error(string.Format("Có   {0}*   bài không nhận dạng được do:{1}" +
                                                 "1. Giấy bị mờ chặc bẩn (đặc biệt ở bốn góc) {1}" +
                                                 "2. Khi quét nghiêng quá mức, quăn mép; dữ liệu không đúng chuẩn. {1}" +
                                                 "3. Học sinh tô không đủ đậm, cần nhắc nhở. {1}" +
                                                 "4. Mã đề trong đáp án không đúng với mã đề trong bài làm.{1}{1}" +
                                                 "Những bài chắc chắn có lỗi được tô đỏ, hãy dùng nút 'Bài gốc' để xem lại{1}" +
                                                 "và hiệu chỉnh cho đúng. Nhấn vào tiêu đề cột điểm sẽ liệt kê chúng.",
                                                 _numberBlurSources,
                                                 Environment.NewLine));
            }
            UseWaitCursor            = false;
            Cursor                   = Cursors.Default;
            toolBtnRecognize.Enabled = true;
            toolBtnRecognize.Text    = "Chấm lại";
            _isRecognized            = true;
            toolBtnRecognize.Click  += new EventHandler(toolBtnRecaculate_Click);
            gridMark.Show();
        }