예제 #1
0
        public void Draw(Graphics graphics, XkeysDataHandler xkeysDataHandler, KeyLayout xkeyLayout, bool isFocused)
        {
            if (xkeyLayout != null)
            {
                foreach (KeyBase key in xkeyLayout.Keys)
                {
                    int      columnIndex    = key.Column;
                    byte     keyCode        = xkeysDataHandler.LastKeyCode[columnIndex];
                    byte     blockedKeyMask = xkeysDataHandler.BlockedKeysMask[columnIndex];
                    KeyGroup xkeyGroup      = key as KeyGroup;

                    KeyGroupType keyType;
                    if (xkeyGroup != null)
                    {
                        keyType = xkeyGroup.Type;
                    }
                    else
                    {
                        keyType = KeyGroupType.NoGroup;
                    }

                    DrawKey(graphics, columnIndex, key.Row, keyCode, blockedKeyMask, xkeyLayout, keyType, isFocused);
                }
            }
            else
            {
                Draw(graphics, xkeysDataHandler.LastKeyCode, xkeysDataHandler.BlockedKeysMask, xkeyLayout, isFocused);
            }
        }
예제 #2
0
        public void GroupSelection(KeyGroupType keysGroupType)
        {
            XkeySelection selection = GetSelection();

            RemoveSelectedKeys();
            KeyGroup keyGroup = new KeyGroup()
            {
                Type = keysGroupType, Name = selection.GetName()
            };
            int topmostRow     = -1;
            int leftmostColumn = -1;

            foreach (KeyBase selectedKey in selection.SelectedKeys)
            {
                selectedKey.ClearSelection();
                keyGroup.Keys.Add(selectedKey);
                if (topmostRow == -1 || selectedKey.Row < topmostRow)
                {
                    topmostRow = selectedKey.Row;
                }
                if (leftmostColumn == -1 || selectedKey.Column < leftmostColumn)
                {
                    leftmostColumn = selectedKey.Column;
                }
            }
            keyGroup.Selected = true;
            keyGroup.SetPosition(leftmostColumn, topmostRow);
            keys.Add(keyGroup);
            OnSelectionChanged();
        }
예제 #3
0
        public void UngroupSelection()
        {
            XkeySelection selection = GetSelection();

            foreach (KeyBase selectedKey in selection.SelectedKeys)
            {
                KeyGroup keyGroup = selectedKey as KeyGroup;
                if (keyGroup != null)
                {
                    keyGroup.Ungroup(this);
                }
            }
            OnSelectionChanged();
        }
예제 #4
0
        public static KeyBase CreateAndLoad(DecoupledStorage storage, string section, int index)
        {
            KeyBase key = null;

            if (storage.ReadBoolean(section, "IsGroup" + index, false))
            {
                key = new KeyGroup();
            }
            else
            {
                key = new Key();
            }
            key.Load(storage, section, index);
            return(key);
        }
예제 #5
0
        public void MoveSelection(int deltaX, int deltaY, bool addToSelection)
        {
            int selectionColumn = -1;
            int keyWidth        = 1;
            int keyHeight       = 1;
            int selectionRow    = -1;

            for (int i = 0; i < Keys.Count; i++)
            {
                if (Keys[i].Selected)
                {
                    KeyGroup keyGroup = Keys[i] as KeyGroup;
                    if (keyGroup != null)
                    {
                        if (deltaX > 0)
                        {
                            if (keyGroup.Type == KeyGroupType.Wide || keyGroup.Type == KeyGroupType.Square)
                            {
                                keyWidth = 2;
                            }
                        }
                        if (deltaY > 0)
                        {
                            if (keyGroup.Type == KeyGroupType.Tall || keyGroup.Type == KeyGroupType.Square)
                            {
                                keyHeight = 2;
                            }
                        }
                    }
                    selectionColumn = Keys[i].Column;
                    selectionRow    = Keys[i].Row;
                    break;
                }
            }
            if (selectionColumn == -1)
            {
                return;
            }


            int newColumn = selectionColumn + deltaX * keyWidth;
            int newRow    = selectionRow + deltaY * keyHeight;

            if (Hardware.Keyboard.IsValidKey(newColumn, newRow))
            {
                Select(newColumn, newRow, addToSelection, false);
            }
        }
예제 #6
0
        public KeyGroupType GetGroupType()
        {
            if (Count != 1)
            {
                return(KeyGroupType.NoGroup);
            }

            KeyGroup xkeyGroup = selectedKeys[0] as KeyGroup;

            if (xkeyGroup != null)
            {
                return(xkeyGroup.Type);
            }

            return(KeyGroupType.NoGroup);
        }
예제 #7
0
        /// <summary>
        /// Gets the single key at the specified column and row. If a group key
        /// (tall, wide, or square) is at the specified location, then that group
        /// is drilled into to find and return the actual subkey at the column and
        /// row.
        /// </summary>
        public KeyBase GetSingleKey(int column, int row)
        {
            KeyBase  key      = GetKey(column, row);
            KeyGroup keyGroup = key as KeyGroup;

            if (keyGroup == null)
            {
                return(key);
            }

            foreach (KeyBase subkey in keyGroup.Keys)
            {
                if (subkey.IsAt(column, row))
                {
                    return(subkey);
                }
            }

            return(null);
        }