Exemplo n.º 1
0
        public IActionResult RenderLayerIcon(string deviceId, string layerId, int keyId)
        {
            Bitmap icon;

            try
            {
                DeviceModel device = _deviceManager.GetDevice(deviceId);
                KeyMap      keyMap = device.Layers.GetLayerById(layerId).Keys;


                if (keyMap.ContainsKey(keyId))
                {
                    KeyModel key = keyMap[keyId];
                    icon = _deviceManager.GenerateKeyIcon(key, deviceId);
                }
                else
                {
                    icon = IconHelpers.DrawBlankKeyIcon(244, 244);
                }
            }
            catch (Exception e)
            {
                icon = IconHelpers.DrawBlankKeyIcon(244, 244);
            }

            return(File(icon.ToMemoryStream(), "image/png", "key.png"));
        }
Exemplo n.º 2
0
        protected void UnregisterShortcut(Keys key)
        {
            if (!KeyMap.ContainsKey(key))
            {
                throw new InvalidOperationException("The shortcut key is not registered.");
            }
            string command = KeyMap[key];

            KeyMap.Remove(key);
            CommandMap[command].Remove(key);
        }
Exemplo n.º 3
0
        public void HoldKey(VirtualKeys key)
        {
            BotUtils.HoldKey(XMemory.Process.MainWindowHandle, new IntPtr((int)key));

            if (KeyMap.ContainsKey(key))
            {
                KeyMap[key] = false;
            }
            else
            {
                KeyMap.Add(key, false);
            }
        }
Exemplo n.º 4
0
 protected void RegisterShortcut(string command, Keys key)
 {
     // キーの重複を確認。コマンドは重複してもよい(異なるキーから同じコマンドを呼び出しても問題ない)
     if (KeyMap.ContainsKey(key))
     {
         throw new InvalidOperationException("The shortcut key has already been registered.");
     }
     KeyMap.Add(key, command);
     if (!CommandMap.ContainsKey(command))
     {
         CommandMap.Add(command, new HashSet <Keys>());
     }
     CommandMap[command].Add(key);
 }
Exemplo n.º 5
0
        private void ListenForStateChange()
        {
            JoystickState?state = null;

            while (true)
            {
                if (!_listenWaitHadle.WaitOne())
                {
                    return;
                }

                if (!_isListening)
                {
                    return;
                }

                var newState = _joystick.GetCurrentState();

                for (int i = 0; i < newState.Buttons.Length; i++)
                {
                    if (newState.Buttons[i] != state?.Buttons[i] &&
                        KeyMap.ContainsKey(i))
                    {
                        State.Buttons[KeyMap[i]] = newState.Buttons[i];
                        StateChanged?.Invoke(this, EventArgs.Empty);
                    }
                }

                state = newState;

                var x = (state.X - 32767) / 5000;
                var y = (state.Y - 32767) / 5000;
                if (x != State.PointerX || y != State.PointerY)
                {
                    State.PointerX = x;
                    State.PointerY = y;
                    StateChanged?.Invoke(this, EventArgs.Empty);
                }

                var scrollX = (state.Z - 32767) / -1000;
                var scrollY = (state.RotationZ - 32767) / 1000;
                if (scrollX != State.ScrollX || scrollY != State.ScrollY)
                {
                    State.ScrollX = scrollX;
                    State.ScrollY = scrollY;
                    StateChanged?.Invoke(this, EventArgs.Empty);
                }
            }
        }
Exemplo n.º 6
0
 void OnKeyUp(object sender, KeyRoutedEventArgs e)
 {
     UpdateCursorType();
     if (!IsEditing)
     {
         bool       flag;
         bool       flag2;
         VirtualKey keyCode = e.Key;
         KeyboardHelper.GetMetaKeyState(out flag, out flag2);
         VirtualKeyModifiers none = VirtualKeyModifiers.None;
         if (flag2)
         {
             none |= VirtualKeyModifiers.Control;
         }
         if (flag)
         {
             none |= VirtualKeyModifiers.None | VirtualKeyModifiers.Shift;
         }
         KeyStroke stroke = new KeyStroke(keyCode, none, true);
         if (KeyMap.ContainsKey(stroke))
         {
             SpreadAction action = KeyMap[stroke];
             if (action != null)
             {
                 ActionEventArgs args = new ActionEventArgs();
                 action(this, args);
                 if (args.Handled)
                 {
                     e.Handled = true;
                 }
             }
         }
     }
     if (IsDragDropping)
     {
         SwitchDragDropIndicator();
     }
 }
Exemplo n.º 7
0
        void OnKeyDown(object sender, KeyRoutedEventArgs e)
        {
            if ((_tabStrip != null) && _tabStrip.IsEditing)
            {
                if ((e.Key == (VirtualKey)13) || (e.Key == (VirtualKey)9))
                {
                    _tabStrip.StopTabEditing(false);
                    e.Handled = true;
                }
                else if (e.Key == (VirtualKey)0x1b)
                {
                    _tabStrip.StopTabEditing(true);
                }
                return;
            }

            bool flag2;
            bool flag3;
            bool flag4;
            bool flag = AllowEnterEditing(e);

            if (InputDeviceType == InputDeviceType.Touch)
            {
                RefreshSelection();
            }
            InputDeviceType = InputDeviceType.Keyboard;
            UpdateCursorType();
            VirtualKey keyCode = e.Key;

            if (keyCode == VirtualKey.Enter)
            {
                Worksheet activeSheet = ActiveSheet;
                if (EditorInfo.Sheet != activeSheet)
                {
                    int index = activeSheet.Workbook.Sheets.IndexOf(EditorInfo.Sheet);
                    activeSheet.Workbook.ActiveSheetIndex = index;
                    StopCellEditing(false);
                    e.Handled = true;
                    return;
                }
            }
            KeyboardHelper.GetMetaKeyState(out flag3, out flag2, out flag4);
            VirtualKeyModifiers none = VirtualKeyModifiers.None;

            if (flag2)
            {
                none |= VirtualKeyModifiers.Control;
            }
            if (flag3)
            {
                none |= VirtualKeyModifiers.None | VirtualKeyModifiers.Shift;
            }
            if (flag4)
            {
                none |= VirtualKeyModifiers.Menu;
            }
            KeyStroke ks = new KeyStroke(keyCode, none, false);

            if (ProcessKeyDownOnFloatingObjectSelected(ks))
            {
                e.Handled = true;
            }
            else
            {
                if (KeyMap.ContainsKey(ks))
                {
                    SpreadAction action = KeyMap[ks];
                    if (action != null)
                    {
                        CloseDragFillPopup();
                        ActionEventArgs args = new ActionEventArgs();
                        action(this, args);
                        if (args.Handled)
                        {
                            e.Handled = true;
                        }
                    }
                }
                if (IsDragDropping)
                {
                    SwitchDragDropIndicator();
                }
                else
                {
                    if (!IsEditing && flag)
                    {
                        // Enter状态表示因键盘输入触发,Edit状态表示双击触发
                        StartCellEditing(true, null, EditorStatus.Enter);
                    }
                    if (!IsEditing)
                    {
                        FocusInternal();
                    }
                }
            }
        }