Esempio n. 1
0
        private void gridMark_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }
            DataGridViewRow row = gridMark.Rows[e.RowIndex];

            if (!row.IsNewRow && gridMark[e.ColumnIndex, e.RowIndex].IsInEditMode)
            {
                try
                {
                    int            resultIndex = ((MarkRowInfo)gridMark.Rows[e.RowIndex].Tag).ResultIndex;
                    Core.Interpret interpret   = new Core.Interpret();
                    interpret.CoreMsg      += new Core.CoreMsgEventHandler(interpret_CoreMsg);
                    interpret.keys          = _keys;
                    interpret.Result.answer = Core.Utility.Clarify((string)
                                                                   gridMark[colDetail.Index, e.RowIndex].Value);
                    interpret.Result.problem = int.Parse(row.Cells[colProblem.Index].Value.ToString());
                    interpret.Result.group   = int.Parse(row.Cells[colGroup.Index].Value.ToString());
                    interpret.Result.student = int.Parse(row.Cells[colStudentID.Index].Value.ToString());
                    interpret.FindMark();
                    interpret.Result.file          = Result[resultIndex].file;
                    interpret.Result.root          = Result[resultIndex].root;
                    row.Cells[colMark.Index].Value = interpret.Result.mark;

                    // Cập nhật dữ liệu mới.
                    Result[resultIndex] = interpret.Result;
                }
                catch (FormatException ex)
                {
                    Core.Utility.Msg("Dữ liệu không đúng. Xin cẩn thận." + ex.Message);
                    return;
                }
                catch (Exception ex2)
                {
                    Core.Utility.Msg("Lỗi nghiêm trọng. Xin vui lòng xem lại hướng dẫn trước khi thực hiện sửa chữa trực tiếp."
                                     + ex2.Message);
                    return;
                }
            }
            else
            {
                // cập nhật dữ liệu các cột khác với Result
            }
        }
Esempio n. 2
0
File: Core.cs Progetto: manhg/malyst
        public Discover OneFile(string fileName, ref KeySuite keys)
        {
            if (!File.Exists(fileName))
            {
                Inform(this, "Tệp {0} không có thực!", fileName);
                return(null);
            }
            else
            {
                Inform(this, "Xử lý: '{0}'", fileName);
            }
            FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
            Acquired   acq;

            try
            {
                Bitmap sourceBitmap = new Bitmap(fs);
                switch (sourceBitmap.PixelFormat)
                {
                case PixelFormat.Format24bppRgb:
                case PixelFormat.Format32bppArgb:
                case PixelFormat.Format8bppIndexed:
                    break;

                default:
                    Inform(this, "Hệ màu không hỗ trợ. Chỉnh lại cấu hình quét về màu RGB hoặc Grey 8-bit.");
                    return(null);
                }
                acq          = new Acquired(sourceBitmap, CoreMsgDelegates);
                acq.FileName = fileName;
            }
            catch (ArgumentException) { Inform(this, "Tệp'{0}' bị hỏng.", fileName); return(null); }
            finally { fs.Close(); }
            Anchor anchor = new Anchor(acq, this.CoreMsgDelegates);

            anchor.Detect(AnchorType.TopLeft);
            anchor.Detect(AnchorType.TopRight);
            anchor.Detect(AnchorType.BottomLeft);
            anchor.Detect(AnchorType.BottomRight);
            Inform(this, string.Format("Neo: TL{0}  TR{1}  BL{2}  BR{3}",
                                       anchor[AnchorType.TopLeft].ToString(),
                                       anchor[AnchorType.TopRight].ToString(),
                                       anchor[AnchorType.BottomLeft].ToString(),
                                       anchor[AnchorType.BottomRight].ToString()));
            if (anchor.Acceptable)
            {
                Interpret interpret = new Interpret(keys, acq, anchor, this.CoreMsgDelegates);
                interpret.FindAnswer();
                interpret.FindStudent();
                interpret.FindProblem();
                interpret.FindGroup();
                interpret.FindMark();
                interpret.Result.root    = anchor[AnchorType.TopLeft];
                interpret.Result.portion = keys.portion;
                return(interpret.Result);
            }
            else
            {
                return(null);
            }
        }