Пример #1
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();
        }
Пример #2
0
        private void grdMappingsCellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex != 3)
            {
                return;
            }

            int row = e.RowIndex;

            if (_clearedKeys.Contains(row))
            {
                return; // Shouldn't happen anyway
            }
            if (row >= 0)
            {
                DataGridViewRow currentRow = grdMappings.Rows[row];

                if (currentRow.Tag != null)
                {
                    MappingsManager.DeleteMapping((KeyMapping)currentRow.Tag);
                }
            }
        }
Пример #3
0
        private void grdMappingsCellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex != 3)
            {
                return;
            }

            int row = e.RowIndex;

            if (this._clearedKeys.Contains(row))
            {
                return;                 // Shouldn't happen anyway
            }
            if (row >= 0)
            {
                DataGridViewRow currentRow = this.grdMappings.Rows[row];

                if (currentRow.Tag != null)
                {
                    MappingFilter filter;
                    if (currentRow.Cells[1].Value.ToString() == "User")
                    {
                        filter = MappingFilter.User;
                    }
                    else if (currentRow.Cells[1].Value.ToString() == "Boot")
                    {
                        filter = MappingFilter.Boot;
                    }
                    else
                    {
                        return;
                    }

                    MappingsManager.DeleteMapping((KeyMapping)currentRow.Tag, filter);
                }
            }
        }
Пример #4
0
 private void DeleteCurrentMapping()
 {
     MappingsManager.DeleteMapping(Map);
 }
Пример #5
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();
            }
        }