Ejemplo n.º 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;
 }
Ejemplo n.º 2
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;

            }
        }
Ejemplo n.º 3
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;
            }
        }
Ejemplo n.º 4
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;
 }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Đọc danh sách các ExerciseSet
 /// </summary>
 /// <param name="mode">một giá trị <see cref="TypingMode"/> cho biết kiểu gõ.</param>
 /// <returns>Mảng các ExerciseSet đọc từ DB. Nếu có lỗi, trả về null.</returns>
 public CExerciseSet[] LoadExSetList(TypingMode mode)
 {
     try
     {
         List<CExerciseSet> lsRet = new List<CExerciseSet>();
         DataTableReader reader = m_dtExSet.CreateDataReader();
         while (reader.Read())
         {
             if (reader.GetInt32(1) == (int)mode)
             {
                 lsRet.Add(new CExerciseSet((ExerciseSetType)reader.GetInt32(0),
                         (TypingMode)reader.GetInt32(1),
                         reader.GetString(2), reader.GetInt32(3), reader.GetInt32(4)));
             }
         }
         return lsRet.ToArray();
     }
     catch (System.Exception /*ex*/)
     {
         return null;
     }
 }
Ejemplo n.º 7
0
 public bool SetUsingTypingMode(string sUserName, TypingMode mode)
 {
     return CPersistantData.Instance.UpdateUserTypingMode(sUserName, (int)mode);
 }