Пример #1
0
 public CExerciseSet(ExerciseSetType type, TypingMode mode, string sName, int beginInstruction, int endInstruction)
 {
     m_iExSetType = type;
     m_typingMode = mode;
     m_sName = sName;
     m_iBeginInstruction = beginInstruction;
     m_iEndInstruction = endInstruction;
 }
Пример #2
0
        private static readonly int m_iTableAmount = 70 - 3; // số phần tử trong bảng ánh xạ các kiểu gõ

        #endregion Fields

        #region Methods

        /// <summary>
        /// Chuyển chuỗi Unicode sang các kiểu gõ khác với mã số của kiểu gõ
        /// </summary>
        /// <param name="sString">Chuỗi Unicode cần được chuyển</param>
        /// <param name="estMode">Mã số kiểu gõ hiện tại
        ///     1: VNI
        ///     2: Telexe
        ///     3: NoMark
        /// </param>
        /// <returns>Chuỗi đã được chuyển</returns>
        public static string ConvertStrWithMode(string sString, ExerciseSetType estExSetType)
        {
            switch (estExSetType)
            {
                case ExerciseSetType.NOMARK:
                case ExerciseSetType.NOMARK_BRAILLE:
                    return Str2NoMark(sString);
                case ExerciseSetType.VNI:
                    return Str2VNI(sString);
                case ExerciseSetType.TELEX:
                    return Str2Telex(sString);
                case ExerciseSetType.MARK_BRAILLE:
                    return sString;
            }
            return string.Empty;
        }
Пример #3
0
        /// <summary>
        /// Khi có sự kiện nhấn phím vào Main Menu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnKeyDown(object sender, KeyEventArgs e)
        {
            /************************************************************************/
            /* Nhấn phím Enter vô Main Menu                                         */
            /************************************************************************/
            int idx = this.lbMainMenu.SelectedIndex;
            string strHelpString;

            switch (e.KeyCode)
            {
                /*******************/
                /* Nhấn phím Enter */
                /*******************/
                case Keys.Enter:
                    if (idx < 0 && this.lbMainMenu.Visible == true)
                    {
                        /************************************************************************/
                        /* Speak "Bạn chưa chọn gì cả, hãy chọn một Option"                       */
                        /************************************************************************/
                        strHelpString = "Bạn chưa chọn lựa chọn nào cả. Hãy chọn và nhấn phím Enter hoặc nhấn nhanh chuột trái 2 lần liên tiếp";
                        ShowHelp(strHelpString);

                        break;
                    }
                    switch (iCurrLayer)
                    {
                        case 1:
                            iCurrLayer++;
                            tmCurrMode = (TypingMode)idx;
                            ShowLayer2();
                            break;
                        case 2:
                            estCurrExerciseSet = (ExerciseSetType)(10 * (int)tmCurrMode + idx);

                            if (estCurrExerciseSet == ExerciseSetType.RECORNITION ||
                                estCurrExerciseSet == ExerciseSetType.RECORNITION_BRAILLE)
                            {
                                iCurrLayer += 2;
                                iCurrExercise = ((int)estCurrExerciseSet == 0 ? -1 : -2);
                                ShowLayer4();
                            }
                            else
                            {
                                iCurrLayer++;
                                ShowLayer3();
                            }

                            break;
                        case 3:
                            iCurrLayer++;
                            iCurrExercise = idx;
                            this.lbMainMenu.Visible = false;
                            ShowLayer4();
                            break;
                    }
                    break;

                /*******************/
                /* Nhấn phím Escape */
                /*******************/
                case Keys.Escape:
                    switch (iCurrLayer)
                    {
                        case 1:
                            if (MessageBox.Show("Bạn có muốn thoát chương trình không?", "Thoát", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                this.Close();
                            break;

                        case 2:
                            iCurrLayer--;
                            ShowLayer1();
                            break;

                        case 3:
                            iCurrLayer--;
                            ShowLayer2();
                            break;

                        case 4:
                            if (estCurrExerciseSet == ExerciseSetType.RECORNITION ||
                                estCurrExerciseSet == ExerciseSetType.RECORNITION_BRAILLE)
                            {
                                iCurrLayer -= 2;
                                this.lbMainMenu.Visible = true;
                                ShowLayer2();
                            }
                            else
                            {
                                iCurrLayer--;
                                this.lbMainMenu.Visible = true;
                                ShowLayer3();
                            }

                            resetProcessProperties();
                            break;
                    }
                    break;

                /*******************/
                /* Nhấn phím F1    */
                /*******************/
                case Keys.F1:
                    /************************************************************************/
                    /* Giới thiệu về chương trình, hệ thống các bài tập...                  */
                    /************************************************************************/
                    ShowHelp(51);

                    break;

                /*******************/
                /* Nhấn phím F2    */
                /*******************/
                case Keys.F2:
                    /************************************************************************/
                    /* Giới thiệu hệ thống các Hot Key sử dụng trong chương trình           */
                    /************************************************************************/
                    ShowHelp(52);
                    break;

                /*******************/
                /* Nhấn phím F3    */
                /*******************/
                case Keys.F3:
                    /************************************************************************/
                    /* Chuyển đổi qua lại giữ các chế độ BlindView và ClearView             */
                    /************************************************************************/
                    ShowHelp(53);
                    isBlindView = !isBlindView;

                    if (isBlindView)
                    {
                        this.Width -= Business.CConfig.iDeltaWidth;
                    }
                    else
                    {
                        this.Width += Business.CConfig.iDeltaWidth;
                    }
                    break;

                /*******************/
                /* Nhấn phím F4    */
                /*******************/
                case Keys.F4:
                    /************************************************************************/
                    /* Tạm ngừng đọc hướng dẫn                                              */
                    /************************************************************************/
                    ShowHelp(54);

                    break;
                case Keys.F5:
                    /************************************************************************/
                    /* Hướng dẫn cách gõ từ đang gõ                                         */
                    /************************************************************************/
                    ShowHelp(55);

                    break;

                /*******************/
                /* Nhấn phím F9    */
                /*******************/
                case Keys.F9:
                    /************************************************************************/
                    /* Giảm thời gian chờ giữa các phím Braille 10 mili giây                */
                    /************************************************************************/
                    try
                    {
                        Clock.Interval -= 10;
                    }
                    catch { }

                    ShowHelp(59);

                    break;

                /*******************/
                /* Nhấn phím F10    */
                /*******************/
                case Keys.F10:
                    /************************************************************************/
                    /* Tăng thời gian chờ giữa các phím Braille 10 mili giây                */
                    /************************************************************************/
                    try
                    {
                        Clock.Interval += 10;
                    }
                    catch { }
                    ShowHelp(510);
                    break;

                /*******************/
                /* Nhấn phím F11    */
                /*******************/
                case Keys.F11:
                    /************************************************************************/
                    /* Giảm kích cỡ chữ                                                     */
                    /************************************************************************/
                    ShowHelp(511);

                    try
                    {
                        this.rtbHint.ZoomFactor -= (float)0.1;
                        this.layer4RTBVungTapGo.ZoomFactor -= (float)0.1;
                        this.layer4LabelString.Font = ChangeFontSize(this.layer4LabelString.Font, 0.9F * this.layer4LabelString.Font.Size);
                        this.lbMainMenu.Font = ChangeFontSize(this.lbMainMenu.Font, 0.9F * (this.lbMainMenu.Font.Size));
                        ChangeHeight(-Business.CConfig.iDeltaHeight);
                    }
                    catch (System.Exception exc)
                    {
                        MessageBox.Show(exc.Message);
                    }

                    break;

                /*******************/
                /* Nhấn phím F12    */
                /*******************/
                case Keys.F12:
                    /************************************************************************/
                    /* Tăng kích cỡ chữ                                                     */
                    /************************************************************************/
                    ShowHelp(512);

                    try
                    {
                        this.rtbHint.ZoomFactor += (float)0.1;
                        this.layer4RTBVungTapGo.ZoomFactor += (float)0.1;
                        this.layer4LabelString.Font = ChangeFontSize(this.layer4LabelString.Font, 1.1F * this.layer4LabelString.Font.Size);
                        this.lbMainMenu.Font = ChangeFontSize(this.lbMainMenu.Font, 1.1F * this.lbMainMenu.Font.Size);
                        ChangeHeight(Business.CConfig.iDeltaHeight);
                    }
                    catch (System.Exception exc)
                    {
                        MessageBox.Show(exc.Message);
                    }

                    break;

            }
        }
Пример #4
0
        /// <summary>
        /// Khi có sự kiện double click vào Main Menu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lbMainMenu_DoubleClick(object sender, EventArgs e)
        {
            /************************************************************************/
            /* Double Click vô Main Menu                                            */
            /************************************************************************/

            int idx = this.lbMainMenu.SelectedIndex;

            if (idx < 0)
                return;

            switch (iCurrLayer)
            {
                case 1:
                    iCurrLayer++;
                    tmCurrMode = (TypingMode)idx;
                    ShowLayer2();
                    break;
                case 2:
                    estCurrExerciseSet = (ExerciseSetType)(10 * (int)tmCurrMode + idx);

                    if (estCurrExerciseSet == ExerciseSetType.RECORNITION ||
                        estCurrExerciseSet == ExerciseSetType.RECORNITION_BRAILLE)
                    {
                        iCurrLayer += 2;
                        iCurrExercise = ((int)estCurrExerciseSet == 0 ? -1 : -2);
                        ShowLayer4();
                    }
                    else
                    {
                        iCurrLayer++;
                        ShowLayer3();
                    }
                    break;
                case 3:
                    iCurrLayer++;
                    iCurrExercise = idx;
                    this.lbMainMenu.Visible = false;
                    ShowLayer4();
                    break;
            }
        }
Пример #5
0
 /// <summary>
 /// Tính ID của bài tập dựa vào các tham số đầu vào
 /// </summary>
 /// <param name="Mode"></param>
 /// <param name="ExSetType"></param>
 /// <param name="idxEx"></param>
 /// <returns></returns>
 private int ComputeExID(TypingMode Mode, ExerciseSetType ExSetType, int idxEx)
 {
     if (idxEx < 0)
         return idxEx;
     return 10 * (10 * ((int)Mode + 1) + (int)ExSetType % 10) + idxEx;
 }
Пример #6
0
        /// <summary>
        /// Load dữ liệu ()
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ViewDlg_Load(object sender, EventArgs e)
        {
            /************************************************************************/
            /* Lấy và xử lý User Name ở đây                                         */
            /* Lấy các thông tin sau:                                               */
            /*      isBlindView                                                     */
            /*      tmCurrMode                                                      */
            /*      estCurrExerciseSet                                              */
            /*      iCurrExercise                                                   */
            /*      iCurrLayer : suy ra từ các thông tin ở trên (để T làm cái này)  */
            /************************************************************************/

            // cần lấy thông tin từ dialog về curModel

            /************************************************************************/
            /* Nếu UserName đã tồn tại thì load vô mục bài tập đang làm             */
            /************************************************************************/
            if (curModel.UserManager.IsUserExisted(strCurrentUser))
            {
                tmCurrMode = curModel.UserManager.GetUsingTypingMode(strCurrentUser);
                estCurrExerciseSet = curModel.UserManager.GetUsingExerciseSet(strCurrentUser);
                if (estCurrExerciseSet == ExerciseSetType.RECORNITION||
                    estCurrExerciseSet == ExerciseSetType.RECORNITION_BRAILLE)
                {
                    iCurrLayer = 4;
                    ShowLayer4();
                }
                else
                {
                    iCurrExercise = curModel.UserManager.GetUsingExercise(strCurrentUser);
                    iCurrExercise = DecodeExIndex(iCurrExercise);
                    iCurrLayer = 3;
                    ShowLayer3();
                }
            }
            else
            {
                // User mới, khởi tạo thông số mặc định
                tmCurrMode = TypingMode.NORMAL;
                iCurrExercise = 0;
                if (!curModel.UserManager.AddUser(strCurrentUser))
                    MessageBox.Show("Cannot add user", "Error");
                iCurrLayer = 1;
                ShowLayer1();
            }

            ShowListHotKeyBalloon();
        }
Пример #7
0
        /// <summary>
        /// Trả về Danh sách các Exercise thuộc exerciseSet cho trước.
        /// </summary>
        /// <param name="type"><see cref="ExerciseSetType"/></param>
        /// <returns>Danh sách các Exercise. Nếu có lỗi, trả về null.</returns>
        /// <remarks>LƯU Ý: Để tiết kiệm thời gian thì hàm này sẽ không trả về nội dung của các bài tập.
        /// Nghĩa là các <see cref="CExercise"/> trong này chỉ có ID và ExName là nên dùng.</remarks>
        public CExercise[] LoadExerciseList(ExerciseSetType type)
        {
            try
            {
                DataRow[] arrRows = m_dtExercise.Select("ExSetID = " + (int)type);

                List<CExercise> lsRet = new List<CExercise>();

                foreach (DataRow dtRow in arrRows)
                {
                    CExercise ex = new CExercise();
                    ex.ExID = (int)dtRow[0];
                    ex.ExName = (string)dtRow[2];
                    string sDataFile = (string)dtRow[3];
                    ex.BeginInstruction = (int)dtRow[4];
                    ex.EndInstruction = (int)dtRow[5];

                    //StreamReader streamFile = new StreamReader(CurrentPath + sDataFile);
                    //while (!streamFile.EndOfStream)
                    //{
                    //    ex.AddString(streamFile.ReadLine());
                    //}
                    lsRet.Add(ex);
                }
                return lsRet.ToArray();
            }
            catch (System.Exception /*ex*/)
            {
                return null;
            }
        }
Пример #8
0
 public int GetExSetInstruction(bool bBegin, ExerciseSetType type)
 {
     try
     {
         DataRow[] arrRows = m_dtExSet.Select("ID=" + (int)type);
         if (arrRows == null || arrRows.Length == 0)
         {
             return 0;
         }
         return (int)arrRows[0][bBegin ? 3 : 4];
     }
     catch (System.Exception /*ex*/)
     {
         return 0;
     }
 }
Пример #9
0
        public string HowToTypeWord_str(string sWord, ExerciseSetType estCurExSet)
        {
            //string sModeStr = CPersistantData.Instance.LoadCurrentTypeMode(ref m_iModeCode);
            string sModeStr = "";
            switch (estCurExSet)
            {
                case ExerciseSetType.NOMARK:
                    sModeStr = "Không dấu";
                    break;
                case ExerciseSetType.NOMARK_BRAILLE:
                    sModeStr = "Không dấu Braille";
                    break;
                case ExerciseSetType.TELEX:
                    sModeStr = "TELEX";
                    break;
                case ExerciseSetType.VNI:
                    sModeStr = "VNI";
                    break;
                case ExerciseSetType.MARK_BRAILLE:
                    sModeStr = "Có dấu Braille";
                    break;
            }

            string m_sResult;

            if ((int)estCurExSet/10 > 0)
            {
                CBrailleMode BrailleMode = new CBrailleMode();
                string Encode;
                if (estCurExSet == ExerciseSetType.NOMARK_BRAILLE)
                    Encode = BrailleMode.Str2Braille(CConverter.Str2NoMark(sWord));
                else
                    Encode = BrailleMode.Str2Braille(sWord);
                string newEncode = "";
                for (int i = 0; i < Encode.Length; i++ )
                {
                        switch (Encode[i])
                        {
                            case 's':
                                newEncode += "một ";
                                break;
                            case 'd':
                                newEncode += "hai ";
                                break;
                            case 'f':
                                newEncode += "ba ";
                                break;
                            case 'j':
                                newEncode += "bốn ";
                                break;
                            case 'k':
                                newEncode += "năm ";
                                break;
                            case 'l':
                                newEncode += "sáu ";
                                break;
                            case '_':
                                newEncode += "và ";
                                break;
                        }
                }
                m_sResult = String.Format("Để gõ {0} theo cách gõ {1} chúng ta phải gõ như sau {2}",
                        sWord, sModeStr, newEncode);
            }
            else
            {
                m_sResult = String.Format("Để gõ {0} theo cách gõ {1} chúng ta phải gõ như sau {2}",
                sWord, sModeStr, CConverter.ConvertStrWithMode(sWord, estCurExSet));
            }
            return m_sResult;
        }