Beispiel #1
0
        private void KeyPictureBoxDragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent("KeyMapper.KeyMapping"))
            {
                var draggedmap = (KeyMapping)e.Data.GetData("KeyMapper.KeyMapping");

                if (MappingsManager.AddMapping(new KeyMapping(Map.From, draggedmap.From)) == false)
                {
                    // Mapping failed. Need to revert our appearance..
                    DrawKey();
                }
            }
        }
Beispiel #2
0
        private void DisableButtonClick(object sender, EventArgs e)
        {
            // Disable or enable, close form anyway.
            if (disabled)
            {
                // Enable
                MappingsManager.DeleteMapping(map);
            }
            else
            {
                // Disable
                map = new KeyMapping(map.From, new Key(0, 0));
                MappingsManager.AddMapping(map);
            }

            Close();
        }
Beispiel #3
0
 private void DisableKey()
 {
     MappingsManager.AddMapping(new KeyMapping(Map.From, new Key(0, 0)));
 }
Beispiel #4
0
        private void MapSelected()
        {
            if (disabled)
            {
                // Nono - Can't map while disabled. Shouldn't be here anyway!
                return;
            }

            if (mapped)
            {
                // Unmap.
                MappingsManager.DeleteMapping(map);
                SetMapToBlankMapping();
                Close();
                return;
            }

            if (capturingToKey)
            {
                // Ah, but have we caught a "to" key yet?
                if (!map.IsValid())
                {
                    return;
                }

                capturingToKey = false;
                StopCapture();
                MappingsManager.AddMapping(map);
                Close();
                return;
            }

            if (selectingFromKeyFromLists)
            {
                Key selectedKey = GetKeyFromListboxValue();

                // Have we been sent a dud??
                if (selectedKey.Scancode == 0)
                {
                    // Something went wrong.
                    map = new KeyMapping();
                }
                else
                {
                    SetMapToBlankMapping(selectedKey.Scancode, selectedKey.Extended);
                    // Need to move panel back to where it was and set the image in the picturebox
                    KeyListsPanel.Location = savedPanelLocation;

                    FromKeyPictureBox.SetImage(ButtonImages.GetButtonImage(map.From.Scancode, map.From.Extended));
                    selectingFromKeyFromLists = false;
                    keyThreshold = 1;
                    SetListOptionsComboIndex();
                    SetupForm();
                    return;
                }
            }

            if (capturingFromKey == false)
            {
                // Not mapped, not capturing From or To keys, so this is mapping from list.
                // Need to call method to create map from name.
                if (CreateMappingFromListboxValue())
                {
                    MappingsManager.AddMapping(map);
                    Close();
                }
                return;
            }
            else
            {
                // Setting the From key. Map has already been created from keypress
                capturingFromKey = false;
                StopCapture();
                direction = FadeDirection.FromBlankToUnmapped;
                SetupForm();
                Transition();
            }
        }