Пример #1
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();
        }
Пример #2
0
        void DrawFilledKey(Graphics graphics, int columnIndex, int rowIndex, KeyGroupType keyType, bool isSelected, string keyName, Brush fillBrush)
        {
            Rectangle keyRect = GetKeyRect(columnIndex, rowIndex, keyType);

            graphics.FillRectangle(fillBrush, keyRect);
            DrawKeyName(graphics, columnIndex, rowIndex, keyName, Brushes.White, keyRect);
            DrawSelectionBorder(graphics, isSelected, keyRect);
        }
Пример #3
0
        void DrawBlockedKey(Graphics graphics, int columnIndex, int rowIndex, KeyGroupType keyType, bool isSelected)
        {
            Rectangle keyRect = GetKeyRect(columnIndex, rowIndex, keyType);

            graphics.FillRectangle(Brushes.DimGray, keyRect);
            graphics.DrawRectangle(Pens.Gray, keyRect);
            DrawSelectionBorder(graphics, isSelected, keyRect);
        }
Пример #4
0
        void DrawKeyUp(Graphics graphics, int columnIndex, int rowIndex, KeyGroupType keyType, bool isSelected, string keyName)
        {
            Rectangle keyRect = GetKeyRect(columnIndex, rowIndex, keyType);

            graphics.FillRectangle(Brushes.White, keyRect);
            graphics.DrawRectangle(Pens.LightGray, keyRect);
            DrawKeyName(graphics, columnIndex, rowIndex, keyName, Brushes.Gray, keyRect);
            DrawSelectionBorder(graphics, isSelected, keyRect);
        }
Пример #5
0
 public void SetKeyGroup(int key, KeyGroupType group)
 {
     if (group == KeyGroupType.None)
     {
         keyGroups.Remove(key);
         return;
     }
     keyGroups[key] = (int)group;
 }
Пример #6
0
        public override void Load(DecoupledStorage storage, string section, int index)
        {
            base.Load(storage, section, index);
            Type = (KeyGroupType)storage.ReadEnum <KeyGroupType>(section, "Type" + index, KeyGroupType.Wide);

            int numElements = storage.ReadInt32(section, "GroupCount" + index, 0);

            for (int i = 0; i < numElements; i++)
            {
                keys.Add(KeyBase.CreateAndLoad(storage, String.Format("{0}.Group{1}", section, index), i));
            }
        }
Пример #7
0
        void DrawKeyDown(Graphics graphics, int columnIndex, int rowIndex, KeyGroupType keyType, bool isSelected, string keyName, bool isFocused)
        {
            Brush fillBrush;

            if (isFocused)
            {
                fillBrush = Brushes.Red;
            }
            else
            {
                fillBrush = Brushes.Pink;
            }

            DrawFilledKey(graphics, columnIndex, rowIndex, keyType, isSelected, keyName, fillBrush);
        }
Пример #8
0
        Rectangle GetKeyRect(int columnIndex, int rowIndex, KeyGroupType keyType)
        {
            Point point = AddMargin(GetTopLeft(columnIndex, rowIndex));

            switch (keyType)
            {
            case KeyGroupType.NoGroup:
                return(new Rectangle(point.X, point.Y, keyWidth, keyHeight));

            case KeyGroupType.Tall:
                return(new Rectangle(point.X, point.Y, keyWidth, keyHeight * 2));

            case KeyGroupType.Wide:
                return(new Rectangle(point.X, point.Y, keyWidth * 2, keyHeight));

            case KeyGroupType.Square:
                return(new Rectangle(point.X, point.Y, keyWidth * 2, keyHeight * 2));

            default:
                return(new Rectangle(point.X, point.Y, keyWidth, keyHeight));
            }
        }
Пример #9
0
        void DrawKey(Graphics graphics, int columnIndex, int rowIndex, byte keyCode, int blockedKeyMask, KeyLayout xkeyLayout, KeyGroupType keyType, bool isFocused)
        {
            int mask = (int)Math.Round(Math.Pow(2, rowIndex));

            if (Hardware.Keyboard.IsValidKey(columnIndex, rowIndex))
            {
                bool   isSelected;
                string keyName       = string.Empty;
                bool   blockOverride = false;
                if (xkeyLayout != null)
                {
                    isSelected = xkeyLayout.IsSelected(columnIndex, rowIndex);
                    keyName    = xkeyLayout.GetKeyName(columnIndex, rowIndex);
                    Key key = xkeyLayout.GetKey(columnIndex, rowIndex) as Key;
                    if (key != null)
                    {
                        blockOverride = key.IsBlocked;
                    }
                }
                else
                {
                    isSelected = false;
                }

                if ((mask & keyCode) == mask)
                {
                    if (blockOverride || (mask & blockedKeyMask) == mask)
                    {
                        DrawBlockedKey(graphics, columnIndex, rowIndex, keyType, isSelected);
                    }
                    else
                    {
                        DrawKeyDown(graphics, columnIndex, rowIndex, keyType, isSelected, keyName, isFocused);
                    }
                }
                else if (blockOverride)
                {
                    DrawBlockedKey(graphics, columnIndex, rowIndex, keyType, isSelected);
                }
                else
                {
                    foreach (KeyBase selectedKey in selectedKeys)
                    {
                        if (columnIndex == selectedKey.Column && rowIndex == selectedKey.Row)
                        {
                            DrawSelectedKey(graphics, columnIndex, rowIndex, keyType, isSelected, keyName);
                            return;
                        }
                    }
                    DrawKeyUp(graphics, columnIndex, rowIndex, keyType, isSelected, keyName);
                }
            }
        }
Пример #10
0
 void DrawSelectedKey(Graphics graphics, int columnIndex, int rowIndex, KeyGroupType keyType, bool isSelected, string keyName)
 {
     DrawFilledKey(graphics, columnIndex, rowIndex, keyType, isSelected, keyName, Brushes.MediumBlue);
 }