Esempio n. 1
0
        private void GetButtons()
        {
            if (showAllButtons)
            {
                buttonCount = 8;
                return;
            }

            // Assume there are some normal unmapped keys!
            buttonCount = 1;

            // See what's currently mapped by looking at the current mapping list
            var currentMaps = MappingsManager.GetMappings(MappingFilter.Current);

            foreach (var map in currentMaps)
            {
                if (MappingsManager.IsMappingPending(map, MappingFilter.Boot))
                {
                    // Pending
                    if (MappingsManager.IsDisabledMapping(map))
                    {
                        if (!pendingDisabled)
                        {
                            pendingDisabled = true;
                            buttonCount++;
                        }
                    }
                    else
                    {
                        if (!pendingMapped)
                        {
                            pendingMapped = true;
                            buttonCount++;
                        }
                    }
                }
                else
                {
                    // Actual
                    if (MappingsManager.IsDisabledMapping(map))
                    {
                        if (!disabledKeys)
                        {
                            disabledKeys = true;
                            buttonCount++;
                        }
                    }
                    else
                    {
                        if (!mappedKeys)
                        {
                            mappedKeys = true;
                            buttonCount++;
                        }
                    }
                }
            }

            // Now look at the cleared keys.

            var maps = MappingsManager.ClearedMappings;

            foreach (var map in maps)
            {
                // Has this cleared key been remapped (in which case we ignore it)
                bool remapped = false;
                foreach (var currentmap in MappingsManager.GetMappings(MappingFilter.Current))
                {
                    if (currentmap.From == map.From)
                    {
                        remapped = true;
                        break;
                    }
                }

                if (remapped)
                {
                    continue;
                }

                if (MappingsManager.IsDisabledMapping(map))
                {
                    if (!pendingEnabled)
                    {
                        pendingEnabled = true;
                        buttonCount++;
                    }
                }
                else
                {
                    if (!pendingUnmapped)
                    {
                        pendingUnmapped = true;
                        buttonCount++;
                    }
                }
            }
        }
Esempio n. 2
0
        private void DrawKey()
        {
            int scanCode = this.scanCode;
            int extended = this.extended;

            ButtonEffect effect;

            if (MappingsManager.IsEmptyMapping(Map) == false)
            {
                //  Remapped or disabled?
                if (MappingsManager.IsDisabledMapping(Map))
                {
                    // Disabled
                    if (MappingsManager.IsMappingPending(Map))
                    {
                        effect = ButtonEffect.DisabledPending;
                    }
                    else
                    {
                        effect = ButtonEffect.Disabled;
                    }
                }
                else
                {
                    // Is this key mapped under the current filter?
                    if (MappingsManager.IsMappingPending(Map))
                    {
                        effect = ButtonEffect.MappedPending;
                    }
                    else
                    {
                        effect = ButtonEffect.Mapped;
                    }

                    // Either way, we want the button to show what it is (will be) mapped to:
                    scanCode = Map.To.ScanCode;
                    extended = Map.To.Extended;
                }
            }
            else
            {
                // Not mapped now, but was this key mapped before under the current filter??
                var km = MappingsManager.GetClearedMapping(scanCode, extended);
                if (MappingsManager.IsEmptyMapping(km))
                {
                    effect = ButtonEffect.None;
                }
                else if (MappingsManager.IsDisabledMapping(km))
                {
                    effect = ButtonEffect.EnabledPending;
                }
                else
                {
                    effect = ButtonEffect.UnmappedPending;
                }
            }

            var keybmp = ButtonImages.GetButtonImage(
                scanCode, extended, button, horizontalStretch, verticalStretch, scale, effect);

            SetImage(keybmp);
        }
Esempio n. 3
0
        private void GetButtons()
        {
            if (this._showAllButtons)
            {
                this._buttonCount = 8;
                return;
            }

            // Assume there are some normal unmapped keys!
            this._buttonCount = 1;

            // See what's currently mapped by looking at the current mapping list
            Collection <KeyMapping> currentMaps = MappingsManager.GetMappings(MappingFilter.Current);

            foreach (KeyMapping map in currentMaps)
            {
                if (MappingsManager.IsMappingPending(map, MappingFilter.All))
                {
                    // Pending
                    if (MappingsManager.IsDisabledMapping(map))
                    {
                        if (!this._pendingdisabled)
                        {
                            this._pendingdisabled = true;
                            this._buttonCount++;
                        }
                    }
                    else
                    {
                        if (!this._pendingmapped)
                        {
                            this._pendingmapped = true;
                            this._buttonCount++;
                        }
                    }
                }
                else
                {
                    // Actual
                    if (MappingsManager.IsDisabledMapping(map))
                    {
                        if (!this._disabledkeys)
                        {
                            this._disabledkeys = true;
                            this._buttonCount++;
                        }
                    }
                    else
                    {
                        if (!this._mappedkeys)
                        {
                            this._mappedkeys = true;
                            this._buttonCount++;
                        }
                    }
                }
            }

            // Now look at the cleared keys.

            IEnumerable <KeyMapping> maps = MappingsManager.ClearedMappings;

            foreach (KeyMapping map in maps)
            {
                // Has this cleared key been remapped (in which case we ignore it)
                bool remapped = false;
                foreach (KeyMapping currentmap in MappingsManager.GetMappings(MappingFilter.Current))
                {
                    if (currentmap.From == map.From)
                    {
                        remapped = true;
                        break;
                    }
                }

                if (remapped)
                {
                    continue;
                }

                if (MappingsManager.IsDisabledMapping(map))
                {
                    if (!this._pendingenabled)
                    {
                        this._pendingenabled = true;
                        this._buttonCount++;
                    }
                }
                else
                {
                    if (!this._pendingunmapped)
                    {
                        this._pendingunmapped = true;
                        this._buttonCount++;
                    }
                }
            }
        }