Ejemplo n.º 1
0
        public VirtualKey(VirtualKeyboard keyboard, KeySet keySet, KeySetRow row, Key key)
        {
            _keyboard = keyboard;
            _keySet = keySet;
            _key = key;

            if (row.IndexOf(key) < row.Count/2)
                _popupFlowDirection = FlowDirection.LeftToRight;
            else
                _popupFlowDirection = FlowDirection.RightToLeft;

            PrimaryAction = new VirtualKeyAction(keyboard, keySet, key.DefaultAction, key.Width);
            Loaded += (s, e) =>
            {
                if (AlternativesPopup != null)
                {
                    if (_popupFlowDirection == FlowDirection.LeftToRight)
                    {
                        AlternativesPopup.HorizontalOffset = -ActualWidth;
                        AlternativesPopup.Placement = PlacementMode.Right;
                    }
                    else
                    {
                        AlternativesPopup.HorizontalOffset = ActualWidth;
                        AlternativesPopup.Placement = PlacementMode.Left;
                    }
                }
            };
        }
Ejemplo n.º 2
0
        public VirtualKey(VirtualKeyboard keyboard, KeySet keySet, KeySetRow row, Key key)
        {
            _keyboard = keyboard;
            _keySet   = keySet;
            _key      = key;

            if (row.IndexOf(key) < row.Count / 2)
            {
                _popupFlowDirection = FlowDirection.LeftToRight;
            }
            else
            {
                _popupFlowDirection = FlowDirection.RightToLeft;
            }

            PrimaryAction = new VirtualKeyAction(keyboard, keySet, key.DefaultAction, key.Width);
            Loaded       += (s, e) =>
            {
                if (AlternativesPopup != null)
                {
                    if (_popupFlowDirection == FlowDirection.LeftToRight)
                    {
                        AlternativesPopup.HorizontalOffset = -ActualWidth;
                        AlternativesPopup.Placement        = PlacementMode.Right;
                    }
                    else
                    {
                        AlternativesPopup.HorizontalOffset = ActualWidth;
                        AlternativesPopup.Placement        = PlacementMode.Left;
                    }
                }
            };
        }
Ejemplo n.º 3
0
        private void ToggleAlternativesPopup()
        {
            if (AlternativesPopup.IsOpen)
            {
                AlternativesPopup.IsOpen = false;
            }
            else
            {
                if (!EnableAlternativesPopup || !_key.AlternativeActions.Any())
                {
                    return;
                }

                var defaultKey = new VirtualKeyAction(_keyboard, _keySet, _key.DefaultAction, KeyWidth);
                IEnumerable <VirtualKeyAction> alternativeKeys = _key.AlternativeActions.Select(a => new VirtualKeyAction(_keyboard, _keySet, a, KeyWidth));

                var alternativesSelection = new AlternateKeySelection(defaultKey, alternativeKeys)
                {
                    FlowDirection = _popupFlowDirection
                };

                AlternativesPopup.Child  = alternativesSelection;
                AlternativesPopup.IsOpen = true;
            }
        }
        public AlternateKeySelection(VirtualKeyAction defaultKey, IEnumerable<VirtualKeyAction> alternativeKeys)
        {
            _keys = new List<VirtualKeyAction>();
            _keys.Add(defaultKey);
            _keys.AddRange(alternativeKeys);

            foreach (var key in _keys)
            {
                key.PressedChanged += () =>
                {
                    if (!key.IsPressed)
                        Close();
                };
            }
        }
Ejemplo n.º 5
0
        public AlternateKeySelection(VirtualKeyAction defaultKey, IEnumerable <VirtualKeyAction> alternativeKeys)
        {
            _keys = new List <VirtualKeyAction>();
            _keys.Add(defaultKey);
            _keys.AddRange(alternativeKeys);

            foreach (var key in _keys)
            {
                key.PressedChanged += () =>
                {
                    if (!key.IsPressed)
                    {
                        Close();
                    }
                };
            }
        }
Ejemplo n.º 6
0
        private void ToggleAlternativesPopup()
        {
            if (AlternativesPopup.IsOpen)
                AlternativesPopup.IsOpen = false;
            else
            {
                if (!EnableAlternativesPopup || !_key.AlternativeActions.Any())
                    return;

                var defaultKey = new VirtualKeyAction(_keyboard, _keySet, _key.DefaultAction, KeyWidth);
                IEnumerable<VirtualKeyAction> alternativeKeys = _key.AlternativeActions.Select(a => new VirtualKeyAction(_keyboard, _keySet, a, KeyWidth));

                var alternativesSelection = new AlternateKeySelection(defaultKey, alternativeKeys) {
                    FlowDirection = _popupFlowDirection
                };

                AlternativesPopup.Child = alternativesSelection;
                AlternativesPopup.IsOpen = true;
            }
        }