Beispiel #1
0
        //static public void show_special_list_modeless2(Form caller, KB9TextBox txtFocused)
        //{

        //    KB9TextBox t = txtFocused;
        //    if (t == null)
        //        return;

        //    frmSpecialKey frmKeyList = frmSpecialKey.Instance();
        //    //if (frmKeyList == null)
        //    //    frmKeyList = new frmSpecialKey();
        //    frmKeyList.TopMost = true;
        //    //set it initial position
        //    int dx = caller.Width;// -frmKeyList.Width;
        //    int dy = 0;//
        //    Point pt = caller.Location;
        //    pt.Offset(dx, dy);
        //    frmKeyList.Location = pt;
        //    frmKeyList.FocusedTextBox = t;
        //    if (frmKeyList.FocusedTextBox == null)
        //    {
        //        frmKeyList.Hide();

        //    }
        //    else
        //    {
        //        frmKeyList.Visible = false;
        //        frmKeyList.Show(caller);
        //    }
        //}

        static public void show_special_list_modeless(Form caller, KB9TextBox txtFocused)
        {
            KB9TextBox t = txtFocused;

            if (t == null)
            {
                return;
            }
            Control        c          = t.Parent;
            frmOnScreenKbd frmKeyList = frmOnScreenKbd.Instance();

            frmKeyList.TopMost = true;
            //set it initial position
            Point point = t.Location;

            point = c.PointToScreen(point);
            //point = caller.PointToClient(ppt);
            //point.X += t.Width;
            point.Y += t.Height;


            frmKeyList.Location       = point; //form location is screen coordinate
            frmKeyList.FocusedTextBox = t;
            if (frmKeyList.FocusedTextBox == null)
            {
                frmKeyList.Hide();
                //frmKeyList = null;
            }
            else
            {
                //if (!frmKeyList.Visible)
                frmKeyList.Visible = false;
                frmKeyList.Show(caller);
            }
        }
Beispiel #2
0
        private KB9TextBox GetFocusedTextBox()
        {
            KB9TextBox[] ar = new KB9TextBox[]
            {
                txtKeyCode,
                //txtLevel1,
                //txtLevel2,
                //txtLevel3,
                //txtLevel4,
                //txtLevel5,
                //txtLevel6,
                //txtLevel7,
                //txtLevel8,
                //txtLevel9,
            };

            for (int i = 0; i < ar.Length; i++)
            {
                if (ar[i].Visible &&
                    ar[i].Focused)
                {
                    return(ar[i]);
                }
            }
            return(null);
        }
Beispiel #3
0
        private void tsmClear_Click(object sender, EventArgs e)
        {
            KB9TextBox t = GetFocusedTextBox();

            if (t == null)
            {
                return;
            }
            t.Clear();
        }
Beispiel #4
0
        private void tsbUndo_Click(object sender, EventArgs e)
        {
            KB9TextBox t = GetFocusedTextBox();

            if (t == null)
            {
                return;
            }
            t.Undo();
        }
Beispiel #5
0
        private void tsbScan_Click(object sender, EventArgs e)
        {
            KB9TextBox t   = GetFocusedTextBox();
            frmAscii   frm = new frmAscii();
            string     s   = frm.InputAscii();

            if (s.Length <= 0)
            {
                return;
            }
            t.AddKeyCode(s, true);
        }
Beispiel #6
0
        private void tstMacro_Click(object sender, EventArgs e)
        {
            KB9TextBox t   = GetFocusedTextBox();
            frmMacro   frm = new frmMacro();
            string     s   = frm.input_macro(null);

            if (s == string.Empty)
            {
                return;
            }

            t.AddKeyCode(s, true);
        }
Beispiel #7
0
        private void tsmScan_Click(object sender, EventArgs e)
        {
            KB9TextBox t = GetFocusedTextBox();

            frmAscii frm     = new frmAscii();
            string   strscan = frm.InputAscii();

            if (strscan.Length > 0)
            {
                t.AddKeyCode(strscan, true);
            }
            //frm.ShowDialog();
        }
Beispiel #8
0
        static public string ValidateKeyTextBoxMsg(Form frmCaller, KB9TextBox ctrlText)
        {
            if (ctrlText == null)
            {
                return("");
            }
            string strKeys = ctrlText.Text;// GetInputedKeyCodes();

            if (strKeys == string.Empty)
            {
                return("");
            }
            KB9Validation kb9 = new KB9Validation();

            KB9Validation.ERR_VALIDATION err = kb9.ValidateKB9Keycodes(strKeys);
            if (err == KB9Validation.ERR_VALIDATION.OK)
            {
                return("");
            }

            string err_msg = ValidateErrMsg(err);

            return(err_msg);

            //if (err == KB9Validation.ERR_VALIDATION.Less_AltUp ||
            //    err == KB9Validation.ERR_VALIDATION.Less_RAltUp ||
            //    err == KB9Validation.ERR_VALIDATION.Less_CtrlUp ||
            //    err == KB9Validation.ERR_VALIDATION.Less_RCtrlUp ||
            //    err == KB9Validation.ERR_VALIDATION.Less_RShiftUp ||
            //    err == KB9Validation.ERR_VALIDATION.Less_ShiftUp)
            //{

            //    return err_msg;
            //    //err_msg += "\n\rDo you want utility append this key to end?";

            //    //DialogResult result = MessageBox.Show(frmCaller, err_msg, "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
            //    //if (result == DialogResult.Yes)
            //    //{
            //    //    string strAppend = AppendErrKey(err);
            //    //    ctrlText.AddKeyCode(strAppend, false);
            //    //}
            //}
            //else
            //{
            //    err_msg += "\n\rPlease fixed it manually.";
            //    MessageBox.Show(frmCaller, err_msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //}

            //return false;
        }
Beispiel #9
0
        private void tsmCombination_Click(object sender, EventArgs e)
        {
            KB9TextBox t = GetFocusedTextBox();

            if (t == null)
            {
                return;
            }
            frmCombination frm = new frmCombination();
            string         s   = frm.InputCombinationKeys();

            if (s.Length > 0)
            {
                t.AddKeyCode(s, true);
            }
        }
Beispiel #10
0
        private void tsbSpecial_Click(object sender, EventArgs e)
        {
            KB9TextBox     t   = GetFocusedTextBox();
            frmOnScreenKbd frm = new frmOnScreenKbd(true);

            frm.StartPosition = FormStartPosition.CenterParent;
            string s = frm.InputSpecialKey();

            // s = s.Replace("[", "");
            // s = s.Replace("]", "");
            if (s.Length <= 0)
            {
                return;
            }
            t.AddKeyCode(s, false);
        }
Beispiel #11
0
 private void UpdateUndoMenu()
 {
     // if (bEnable)
     {
         KB9TextBox t = GetFocusedTextBox();
         if (t != null)
         {
             tsbUndo.Enabled = (t.CanUndo());
             tsmUndo.Enabled = (t.CanUndo());
         }
         else
         {
             tsbUndo.Enabled = false;
             tsmUndo.Enabled = false;
         }
     }
 }
Beispiel #12
0
        private void tsmRepeat_Click(object sender, EventArgs e)
        {
            KB9TextBox t   = GetFocusedTextBox();
            frmRepeat  frm = new frmRepeat();
            int        n   = frm.InputRepeat();

            if (n <= 0)
            {
                return;
            }


            string s = n.ToString();

            s = "Repeat" + s;
            t.AddKeyCode(s, true);
        }
Beispiel #13
0
        private void tsbLevel_Click(object sender, EventArgs e)
        {
            KB9TextBox t = GetFocusedTextBox();

            if (t == null)
            {
                return;
            }
            frmLayers frm = new frmLayers();
            string    s   = frm.input_layer(t.Text);

            if (s == string.Empty)
            {
                return;
            }

            t.AddKeyCode(s, false);
        }
Beispiel #14
0
        static public bool ValidateKeyTextBox(Form frmCaller, KB9TextBox ctrlText)
        {
            string strKeys = ctrlText.Text;// GetInputedKeyCodes();

            if (strKeys == string.Empty)
            {
                return(true);
            }
            KB9Validation kb9 = new KB9Validation();

            KB9Validation.ERR_VALIDATION err = kb9.ValidateKB9Keycodes(strKeys);
            if (err == KB9Validation.ERR_VALIDATION.OK)
            {
                return(true);
            }

            string err_msg = ValidateErrMsg(err);

            if (err == KB9Validation.ERR_VALIDATION.Less_AltUp ||
                err == KB9Validation.ERR_VALIDATION.Less_RAltUp ||
                err == KB9Validation.ERR_VALIDATION.Less_CtrlUp ||
                err == KB9Validation.ERR_VALIDATION.Less_RCtrlUp ||
                err == KB9Validation.ERR_VALIDATION.Less_RShiftUp ||
                err == KB9Validation.ERR_VALIDATION.Less_ShiftUp ||
                err == KB9Validation.ERR_VALIDATION.Less_WinUp ||
                err == KB9Validation.ERR_VALIDATION.Less_RWinUp)
            {
                err_msg += "\n\rDo you want utility append this key to end?";

                DialogResult result = MessageBox.Show(frmCaller, err_msg, "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                if (result == DialogResult.Yes)
                {
                    string strAppend = AppendErrKey(err);
                    ctrlText.AddKeyCode(strAppend, false);
                }
            }
            else
            {
                err_msg += "\n\rPlease fixed it manually.";
                MessageBox.Show(frmCaller, err_msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(false);
        }
Beispiel #15
0
        private KB9TextBox GetFocusedTextBox()
        {
            KB9TextBox[] ar = new KB9TextBox[]
            {
                txtKey0,
                txtKey1,
                txtKey2
            };

            for (int i = 0; i < ar.Length; i++)
            {
                if (ar[i].Visible &&
                    ar[i].Focused)
                {
                    return(ar[i]);
                }
            }
            return(null);
        }
Beispiel #16
0
        private KB9TextBox GetFocusedTextBox()
        {
            KB9TextBox[] ar = new KB9TextBox[]
            {
                txtMacro1,
                txtMacro2,
                txtMacro3,
                txtMacro4,
                txtMacro5,
            };

            for (int i = 0; i < ar.Length; i++)
            {
                if (ar[i].Visible &&
                    ar[i].Focused)
                {
                    return(ar[i]);
                }
            }
            return(null);
        }
Beispiel #17
0
        private void tsbRepeat_Click(object sender, EventArgs e)
        {
            frmOnScreenKbd.Instance().Hide();
            KB9TextBox t = GetFocusedTextBox();

            if (t == null)
            {
                return;
            }
            frmRepeat frm = new frmRepeat();
            int       n   = frm.InputRepeat();

            if (n <= 0)
            {
                return;
            }


            string s = n.ToString();

            s = "Repeat" + s;
            t.AddKeyCode(s, true);
        }
Beispiel #18
0
        private void tsmDelay_Click(object sender, EventArgs e)
        {
            KB9TextBox t   = GetFocusedTextBox();
            frmDelay   frm = new frmDelay();
            decimal    d   = frm.InputDelay();

            if (d <= 0)
            {
                return;
            }

            /*
             * d *= 10; //delay time is nx0.1 format, so need to x10 to make string
             * int n = (int)d;
             * string s = n.ToString();
             *
             * s = "Pause" + s;
             * */
            string s = frmDelay.makePauseString(d);

            t.AddKeyCode(s, true);
            //frm.ShowDialog();
        }
Beispiel #19
0
        private void tsbSpecial_Click(object sender, EventArgs e)
        {
            KB9TextBox t = GetFocusedTextBox();

            if (t == null)
            {
                return;
            }

            frmOnScreenKbd.show_special_list_modeless(this, t);

            /*
             * frmSpecialKey frmKeyList = frmSpecialKey.Instance();
             * if (frmKeyList == null)
             *  frmKeyList = new frmSpecialKey();
             * frmKeyList.TopMost = true;
             * //set it initial position
             * int dx = this.Width;// -frmKeyList.Width;
             * int dy = 0;//
             * Point pt = this.Location;
             * pt.Offset(dx, dy);
             * frmKeyList.Location = pt;
             * frmKeyList.FocusedTextBox = t;
             * if (frmKeyList.FocusedTextBox == null)
             * {
             *  frmKeyList.Hide();
             *  //frmKeyList = null;
             * }
             * else
             * {
             *
             *  //if (!frmKeyList.Visible)
             *  frmKeyList.Visible = false;
             *      frmKeyList.Show(this);
             * }
             * */
        }
Beispiel #20
0
        private void txtMacro1_Validating(object sender, CancelEventArgs e)
        {
            KB9TextBox t = (KB9TextBox)sender;

            if (t == null)
            {
                return;
            }
            System.Diagnostics.Debug.Print("txtMacro1_Validating " + t.Name);
            int nres = KB9Validation.ValidateKeyTextBox2(this, t);

            if (nres == 0)
            {
                t.ClearUndo();
                return;
            }

            e.Cancel = true;

            if (nres == 3) //cancel changes
            {
                t.Undo();
            }
        }
Beispiel #21
0
 private KB9TextBox GetMultipleLevelTextBox(int nIndex)
 {
     KB9TextBox[] ar = new KB9TextBox[]
     {
         txtKeyCode,
         //txtLevel1,
         //txtLevel2,
         //txtLevel3,
         //txtLevel4,
         //txtLevel5,
         //txtLevel6,
         //txtLevel7,
         //txtLevel8,
         //txtLevel9,
     };
     if (nIndex >= 0 && nIndex < ar.Length)
     {
         return(ar[nIndex]);
     }
     else
     {
         return(null);
     }
 }
Beispiel #22
0
        private void tsbDelay_Click(object sender, EventArgs e)
        {
            frmOnScreenKbd.Instance().Hide();
            KB9TextBox t = GetFocusedTextBox();

            if (t == null)
            {
                return;
            }
            frmDelay frm = new frmDelay();
            decimal  d   = frm.InputDelay();

            if (d <= 0)
            {
                return;
            }
            //d *= 10; //delay time is nx0.1 format, so need to x10 to make string
            //int n = (int)d;
            //string s = n.ToString();
            //s = "Pause" + s;
            string s = frmDelay.makePauseString(d);

            t.AddKeyCode(s, true);
        }
Beispiel #23
0
        private bool ValidateKeyTextBox(KB9TextBox ctrlText)
        {
            return(KB9Validation.ValidateKeyTextBox(this, ctrlText));
            //string strKeys = ctrlText.Text;// GetInputedKeyCodes();
            //if (strKeys == string.Empty) return true;
            //KB9Validation kb9 = new KB9Validation();
            //KB9Validation.ERR_VALIDATION err = kb9.ValidateKB9Keycodes(strKeys);
            //if (err == KB9Validation.ERR_VALIDATION.OK) return true;

            //string err_msg = ValidateErrMsg(err);
            //if (err == KB9Validation.ERR_VALIDATION.Less_AltUp ||
            //    err == KB9Validation.ERR_VALIDATION.Less_RAltUp ||
            //    err == KB9Validation.ERR_VALIDATION.Less_CtrlUp ||
            //    err == KB9Validation.ERR_VALIDATION.Less_RCtrlUp ||
            //    err == KB9Validation.ERR_VALIDATION.Less_RShiftUp ||
            //    err == KB9Validation.ERR_VALIDATION.Less_ShiftUp)
            //{


            //    err_msg += "\n\rDo you want utility append this key to end?";

            //    DialogResult result = MessageBox.Show(err_msg, "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
            //    if (result == DialogResult.Yes)
            //    {
            //        string strAppend = AppendErrKey(err);
            //        ctrlText.AddKeyCode(strAppend, false);
            //    }
            //}
            //else
            //{
            //    err_msg += "\n\rPlease fixed it manually.";
            //    MessageBox.Show(err_msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //}

            //return false;
        }
Beispiel #24
0
        /************************************************************************/

        /*
         * return: 0: ok
         *          1: messagebox shown, and correct
         *          2: messagebox shown, and manually correct them
         *          3: cancel edit, undo
         */
        /************************************************************************/
        static public int ValidateKeyTextBox2(Form frmCaller, KB9TextBox ctrlText)
        {
            string strKeys = ctrlText.Text;// GetInputedKeyCodes();

            if (strKeys == string.Empty)
            {
                return(0);
            }
            KB9Validation kb9 = new KB9Validation();

            KB9Validation.ERR_VALIDATION err = kb9.ValidateKB9Keycodes(strKeys);
            if (err == KB9Validation.ERR_VALIDATION.OK)
            {
                return(0);
            }
            string err_msg = ValidateErrMsg(err);
            string strlog  = "Key contents validation error";

            strlog += KB9Logger.LOG_LF;
            strlog += KB9Logger.LOG_TAB;
            strlog += ("Key contents:" + strKeys);
            strlog += KB9Logger.LOG_LF;
            strlog += KB9Logger.LOG_TAB;
            strlog += err_msg;

            KB9Logger.Err(strlog);



            if (err == KB9Validation.ERR_VALIDATION.Single_Function_With_Up)
            { //if it is single function key, just keep down key.
                ctrlText.RemoveLastKey();
                ctrlText.Refresh();
                return(0);
            }

            if (err == ERR_VALIDATION.Repeat_Must_Follow_Key ||
                err == ERR_VALIDATION.Repeat_Can_Not_Follow_Combination_Macro_Pause)
            {
                MessageBox.Show(frmCaller,
                                err_msg,
                                "Warning",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                return(2);
            }

            if (err == ERR_VALIDATION.Less_AltDown ||
                err == ERR_VALIDATION.Less_CtrlDown ||
                err == ERR_VALIDATION.Less_RAltDown ||
                err == ERR_VALIDATION.Less_RCtrlDown ||
                err == ERR_VALIDATION.Less_RShiftDown ||
                err == ERR_VALIDATION.Less_RWinDown ||
                err == ERR_VALIDATION.Less_ShiftDown ||
                err == ERR_VALIDATION.Less_WinDown)
            {
                DialogResult r = frmKeyCodeLessDown.ConfirmCancel();// MessageBox.Show(frmCaller,
                if (r == DialogResult.Yes)
                {
                    return(3);
                }
                else
                {
                    return(2);
                }
            }

            //DialogResult result = MessageBox.Show(frmCaller,
            //                                      "Key release codes does not match with corresponding key press codes.  Automatic fix by inserting key release codes at the end?",
            //                                      "Warning",
            //                                      MessageBoxButtons.YesNo,
            //                                      MessageBoxIcon.Warning);
            DialogResult result = frmKeyCodeError.ConfirmError();// MessageBox.Show(frmCaller,

            if (result == DialogResult.Yes)
            {
                int nloop = 0;
                while (err != ERR_VALIDATION.OK)
                {
                    if (err == KB9Validation.ERR_VALIDATION.Less_AltUp ||
                        err == KB9Validation.ERR_VALIDATION.Less_RAltUp ||
                        err == KB9Validation.ERR_VALIDATION.Less_CtrlUp ||
                        err == KB9Validation.ERR_VALIDATION.Less_RCtrlUp ||
                        err == KB9Validation.ERR_VALIDATION.Less_RShiftUp ||
                        err == KB9Validation.ERR_VALIDATION.Less_ShiftUp ||
                        err == KB9Validation.ERR_VALIDATION.Less_WinUp ||
                        err == KB9Validation.ERR_VALIDATION.Less_RWinUp)
                    {
                        string strAppend = AppendErrKey(err);
                        //ctrlText.AddKeyCode(strAppend, false);
                        ctrlText.AppendKeyCode(strAppend);
                    }
                    //else if (err == KB9Validation.ERR_VALIDATION.Single_Function_With_Up)
                    //{
                    //    ctrlText.RemoveLastKey();
                    //}
                    else
                    { //less down, remove last up
                        string strRemove = RemoveErrKey(err);
                        ctrlText.RemoveLastKeyCode(strRemove);
                    }
                    strKeys = ctrlText.Text;
                    err     = kb9.ValidateKB9Keycodes(strKeys);
                    nloop++;
                    if (nloop > 256)
                    {
                        MessageBox.Show(frmCaller, "The automatic fix failed, please correct it manually.",
                                        "Warning",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Warning);
                        ctrlText.Refresh();
                        //log
                        strlog  = "Can not fixed automaticly.";
                        strlog += KB9Logger.LOG_LF;
                        strlog += KB9Logger.LOG_TAB;
                        strlog += "Result:";
                        strlog += ctrlText.Text;
                        KB9Logger.Err(strlog);
                        return(2);
                    }
                }
                ctrlText.Refresh();
                //log
                strKeys = ctrlText.Text;
                strlog  = "Auto fixed result:";
                strlog += KB9Logger.LOG_LF;
                strlog += KB9Logger.LOG_TAB;
                strlog += strKeys;
                KB9Logger.Log(strlog);
            }
            else
            {
                return(2);
            }



            return(1);
        }