示例#1
0
        public static void BeginKeypress(KeyboardCommand cmd)
        {
            if(mIsTimerOn) return;
            vKeyboard.ProcessCommand(cmd);

            mKBCommand = cmd;
            StartTimer();
        }
示例#2
0
 public static void ProcessCommand(KeyboardCommand kbCmd, bool?flag = null)
 {
     if (kbCmd.KBKeys.Length > 0 && KeyDict.ContainsKey(kbCmd.KBKeys[0]))
     {
         KeyItem keyItem = vKeyboard.KeyDict[kbCmd.KBKeys[0]];
         vKeyboard.PressKey(keyItem.code, flag);
     }
 }
示例#3
0
        }                                               //func

        public static void BeginKeypress(KeyboardCommand cmd)
        {
            if (mIsTimerOn)
            {
                return;
            }
            vKeyboard.ProcessCommand(cmd);

            mKBCommand = cmd;
            StartTimer();
        }//for
示例#4
0
        }//func

        public static void ProcessCommand(KeyboardCommand kbCmd)
        {
            List <int> aryLast = new List <int>();

            //........................................................
            //if shift and shSendString exists, then send that instead.
            if (isShiftActive && !String.IsNullOrEmpty(kbCmd.shSendString))
            {
                System.Windows.Forms.SendKeys.SendWait(kbCmd.SendString);
                isShiftActive = false;
                return;
            }//if

            //........................................................
            //if SendString exists, then send that instead.
            if (!String.IsNullOrEmpty(kbCmd.SendString))
            {
                System.Windows.Forms.SendKeys.SendWait(kbCmd.SendString);
                return;
            }//if

            //........................................................
            //User clicked shift, So just toggle shift state.
            if (kbCmd.KBKeys != null && kbCmd.KBKeys.Length == 1 && (kbCmd.KBKeys[0] == "RSHIFT" || kbCmd.KBKeys[0] == "LSHIFT"))
            {
                vKeyboard.isShiftActive = (vKeyboard.isShiftActive) ? false : true;
                return;
            }//if

            //Process the array of keys to execute
            KeyItem ki;

            String[] aryKey = kbCmd.KBKeys;

            //did the user press shift before
            if (isShiftActive)
            {
                if (kbCmd.KBShKeys != null)  //if there is a shift code, close shift and use those codes instead.
                {
                    aryKey        = kbCmd.KBShKeys;
                    isShiftActive = false;
                }
                else
                {
                    PressKey(KeyDict["LSHIFT"].code, false);    //Call shift
                }
            }//if

            if (aryKey != null)
            {
                for (int i = 0; i < aryKey.Length; i++)
                {
                    if (!KeyDict.ContainsKey(aryKey[i]))
                    {
                        continue;
                    }
                    ki = KeyDict[aryKey[i]];

                    if (ki.extendCode == null)
                    {
                        PressKey(ki.code, false);

                        if (ki.isUpLast)
                        {
                            aryLast.Add(ki.code);
                        }
                        else
                        {
                            PressKey(ki.code, true);
                        }
                    }
                    else
                    {
                        System.Windows.Forms.SendKeys.SendWait(ki.extendCode);
                    } //if
                }     //for
            }         //if

            //Some keys must be pressed up last, do it in reverse order
            if (aryLast.Count > 0)
            {
                for (int i = aryLast.Count - 1; i >= 0; i--)
                {
                    PressKey(aryLast[i], true);
                } //if
            }     //if

            //user pressed shift before, close key call and reset
            if (isShiftActive)
            {
                PressKey(KeyDict["LSHIFT"].code, true);
                isShiftActive = false;
            } //if
        }     //func
示例#5
0
        }        //func

        private static vButton CreateButton(XmlElement elm, int col)
        {
            string code, shCode, shText
            , title = elm.GetAttribute("text")
            , fsize = elm.GetAttribute("fsize");

            vButton btn = new vButton()
            {
            };

            Grid.SetRow(btn, 0);
            Grid.SetColumn(btn, col);
            btn.FontFamily = mIconFont;
            btn.Title      = title;
            if (!String.IsNullOrEmpty(fsize))
            {
                btn.FontSize = double.Parse(fsize);
            }

            switch (elm.Name)
            {
            //.........................................
            case "key":
                code   = elm.GetAttribute("code");
                shCode = elm.GetAttribute("shcode");
                shText = elm.GetAttribute("shtext");

                if (!String.IsNullOrEmpty(code))
                {
                    btn.KBCommand.KBKeys = code.Split(' ');
                }
                if (!String.IsNullOrEmpty(shCode))
                {
                    btn.KBCommand.KBShKeys = shCode.Split(' ');
                }
                if (!String.IsNullOrEmpty(shText))
                {
                    btn.ShiftText = shText;
                }

                btn.KBCommand.SendString   = elm.GetAttribute("string");
                btn.KBCommand.shSendString = elm.GetAttribute("shstring");

                btn.PreviewMouseLeftButtonDown += BtnTouch_Down;
                btn.PreviewMouseLeftButtonUp   += BtnTouch_Up;
                btn.PreviewTouchDown           += BtnTouch_Down;
                btn.PreviewTouchUp             += BtnTouch_Up;

                break;

            //.........................................
            case "menu":
                ContextMenu     menu = new ContextMenu();
                KeyboardCommand kbCmd;
                MenuItem        mItem;

                foreach (XmlElement itm in elm.ChildNodes)
                {
                    kbCmd = new KeyboardCommand();
                    title = itm.GetAttribute("text");
                    code  = itm.GetAttribute("code");

                    if (!String.IsNullOrEmpty(code))
                    {
                        kbCmd.KBKeys = code.Split(' ');
                    }
                    kbCmd.SendString = itm.GetAttribute("string");

                    mItem = new MenuItem()
                    {
                        Header = title, Tag = kbCmd
                    };
                    mItem.Click += OnMenuClick;
                    menu.Items.Add(mItem);
                }    //for

                btn.ContextMenu = menu;
                btn.Click      += OnMenuButtonPress;
                break;
            }//switch

            return(btn);
        }        //func
示例#6
0
        public static void ProcessCommand(KeyboardCommand kbCmd)
        {
            List<int> aryLast = new List<int>();

            //........................................................
            //if shift and shSendString exists, then send that instead.
            if(isShiftActive && !String.IsNullOrEmpty(kbCmd.shSendString)) {
                System.Windows.Forms.SendKeys.SendWait(kbCmd.SendString);
                isShiftActive = false;
                return;
            }//if

            //........................................................
            //if SendString exists, then send that instead.
            if(!String.IsNullOrEmpty(kbCmd.SendString)) {
                System.Windows.Forms.SendKeys.SendWait(kbCmd.SendString);
                return;
            }//if

            //........................................................
            //User clicked shift, So just toggle shift state.
            if(kbCmd.KBKeys != null && kbCmd.KBKeys.Length == 1 && (kbCmd.KBKeys[0] == "RSHIFT" || kbCmd.KBKeys[0] == "LSHIFT")) {
                vKeyboard.isShiftActive = (vKeyboard.isShiftActive) ? false : true;
                return;
            }//if

            //Process the array of keys to execute
            KeyItem ki;
            String[] aryKey = kbCmd.KBKeys;

            //did the user press shift before
            if(isShiftActive) {
                if(kbCmd.KBShKeys != null) { //if there is a shift code, close shift and use those codes instead.
                    aryKey = kbCmd.KBShKeys;
                    isShiftActive = false;
                } else PressKey(KeyDict["LSHIFT"].code, false); //Call shift
            }//if

            if(aryKey != null) {
                for(int i = 0; i < aryKey.Length; i++) {
                    if(!KeyDict.ContainsKey(aryKey[i])) continue;
                    ki = KeyDict[aryKey[i]];

                    if(ki.extendCode == null) {
                        PressKey(ki.code, false);

                        if(ki.isUpLast){ aryLast.Add(ki.code); }
                        else PressKey(ki.code, true);
                    } else {
                        System.Windows.Forms.SendKeys.SendWait(ki.extendCode);
                    }//if
                }//for
            }//if

            //Some keys must be pressed up last, do it in reverse order
            if(aryLast.Count > 0) {
                for(int i = aryLast.Count - 1; i >= 0; i--){
                    PressKey(aryLast[i], true);
                }//if
            }//if

            //user pressed shift before, close key call and reset
            if(isShiftActive) {
                PressKey(KeyDict["LSHIFT"].code, true);
                isShiftActive = false;
            }//if
        }
示例#7
0
        private static vButton CreateButton(XmlElement elm,int col)
        {
            string code, shCode, shText
                ,title = elm.GetAttribute("text")
                ,fsize = elm.GetAttribute("fsize");

            vButton btn = new vButton(){};
            Grid.SetRow(btn,0);
            Grid.SetColumn(btn,col);
            btn.FontFamily = mIconFont;
            btn.Title = title;
            if(!String.IsNullOrEmpty(fsize)) btn.FontSize = double.Parse(fsize);

            switch(elm.Name){
                //.........................................
                case "key":
                    code = elm.GetAttribute("code");
                    shCode = elm.GetAttribute("shcode");
                    shText = elm.GetAttribute("shtext");

                    if(!String.IsNullOrEmpty(code)) btn.KBCommand.KBKeys = code.Split(' ');
                    if(!String.IsNullOrEmpty(shCode)) btn.KBCommand.KBShKeys = shCode.Split(' ');
                    if(!String.IsNullOrEmpty(shText)) btn.ShiftText = shText;

                    btn.KBCommand.SendString = elm.GetAttribute("string");
                    btn.KBCommand.shSendString = elm.GetAttribute("shstring");

                    btn.PreviewMouseLeftButtonDown += BtnTouch_Down;
                    btn.PreviewMouseLeftButtonUp += BtnTouch_Up;
                    btn.PreviewTouchDown += BtnTouch_Down;
                    btn.PreviewTouchUp += BtnTouch_Up;

                    break;
                //.........................................
                case "menu":
                    ContextMenu menu = new ContextMenu();
                    KeyboardCommand kbCmd;
                    MenuItem mItem;

                    foreach(XmlElement itm in elm.ChildNodes){
                        kbCmd = new KeyboardCommand();
                        title = itm.GetAttribute("text");
                        code = itm.GetAttribute("code");

                        if(!String.IsNullOrEmpty(code)) kbCmd.KBKeys = code.Split(' ');
                        kbCmd.SendString = itm.GetAttribute("string");

                        mItem = new MenuItem() { Header = title, Tag = kbCmd };
                        mItem.Click += OnMenuClick;
                        menu.Items.Add(mItem);
                    }//for

                    btn.ContextMenu = menu;
                    btn.Click += OnMenuButtonPress;
                    break;
            }//switch

            return btn;
        }