예제 #1
0
        private List <VirtualKey> GetVirtualKeys(ExtraButtons scrollAction)
        {
            List <VirtualKey> foundVirtualKeys = new List <VirtualKey>();

            if (ExtraButtons.Unknown != scrollAction)
            {
                UserSettings settings = UserSettings.GetInstance();
                if (settings.Mappings != null)
                {
                    foreach (VirtualKey virtualKey in settings.Mappings.Keys)
                    {
                        if (settings.Mappings[virtualKey].PhysicalKeys != null)
                        {
                            foreach (PhysicalKey physicalKey in settings.Mappings[virtualKey].PhysicalKeys)
                            {
                                if (physicalKey.ExtraValue == scrollAction && !foundVirtualKeys.Contains(virtualKey))
                                {
                                    foundVirtualKeys.Add(virtualKey);
                                }
                            }
                        }
                    }
                }
            }

            return(foundVirtualKeys);
        }
예제 #2
0
        private void Handler_AddMapping_OnMouseScroll(object sender, RoutedEventArgs e)
        {
            Log.Debug("Handler_AddMapping_OnMouseScroll");
            Log.Debug(DateTime.Now.ToString());

            System.Windows.Input.MouseWheelEventArgs mwea = (System.Windows.Input.MouseWheelEventArgs)e;
            ExtraButtons scrollAction = MouseWheelScrollProcessor.GetScrollAction(mwea);

            Handler_AddMapping_GenericKeyDown(scrollAction, Keyboard.Key.Unknown, MouseButton.Unknown);
        }
예제 #3
0
        public void Process(DualShockState state)
        {
            if (MouseButtonHoldTimer.ElapsedMilliseconds > UserSettings.GetInstance().MouseWheelScrollHoldDuration)
            {
                LastVirtualKeys = null;
            }

            if (LastVirtualKeys == null)
            {
                // Queue.Count because "Dequeue" and "Peek" will block/wait until there is an event in the queue
                if (MouseWheelQueue.Count > 0)
                {
                    MouseEventArgs e            = MouseWheelQueue.Dequeue();
                    ExtraButtons   scrollAction = MouseWheelScrollProcessor.GetScrollAction(e);
                    LastVirtualKeys = GetVirtualKeys(scrollAction);
                    MouseButtonHoldTimer.Restart();
                }
            }

            HandleVirtualKeys(state, LastVirtualKeys);
        }
예제 #4
0
        private void Handler_AddMapping_GenericKeyDown(ExtraButtons extraValue, Keyboard.Key keyboardValue, MouseButton mouseValue)
        {
            if (lastClickedButton != null && lastClickedButton.Parent != null)
            {
                StackPanel parentStackPanel = (StackPanel)lastClickedButton.Parent;
                if (parentStackPanel.Tag != null)
                {
                    if (keyboardValue != Keyboard.Key.Escape)
                    {
                        VirtualKey vk = (VirtualKey)parentStackPanel.Tag;

                        int         index    = (int)lastClickedButton.Tag;
                        PhysicalKey valueOld = null;

                        if (Settings.MappingsContainsKey(vk))
                        {
                            if (index < Settings.Mappings[vk].PhysicalKeys.Count)
                            {
                                valueOld = Settings.Mappings[vk].PhysicalKeys[index];
                            }
                        }

                        PhysicalKey valueNew = new PhysicalKey();
                        valueNew.ExtraValue    = extraValue;
                        valueNew.KeyboardValue = keyboardValue;
                        valueNew.MouseValue    = mouseValue;

                        UserSettings.SetMapping(vk, valueOld, valueNew);
                    }

                    lastClickedButton = null;
                    ((MainViewModel)DataContext).RefreshData();
                    WaitingForKeyPress_Hide();
                }
            }
        }
예제 #5
0
 public string ExtraButtonToString(ExtraButtons key)
 {
     return(key.ToString());
 }
예제 #6
0
        private void DrawControl()
        {
            Controls.Clear();

            var treeList   = AssociatedList as YamuiFilteredTypeTreeList;
            var thisHeight = Height - Padding.Top - Padding.Bottom;

            // draw buttons on the left of the filter textbox
            var xLeftPos = Padding.Left;

            if (ExtraButtons != null && ExtraButtons.Count > 0)
            {
                ExtraButtonsList = new List <YamuiButtonImage>();
                foreach (var button in ExtraButtons.Where(button => button.Image != null))
                {
                    var extraButton = new YamuiButtonImage {
                        BackGrndImage = button.Image,
                        Size          = button.Image.Size,
                        Location      = new Point(xLeftPos, Padding.Top + (thisHeight - button.Image.Height) / 2),
                        Anchor        = AnchorStyles.Top | AnchorStyles.Left,
                        TabStop       = false
                    };
                    var button1 = button;
                    extraButton.ButtonPressed += (sender, args) => button1.OnClic((YamuiButtonImage)sender, args);
                    Controls.Add(extraButton);
                    ExtraButtonsList.Add(extraButton);
                    if (button.ToolTip != null)
                    {
                        _tooltip.SetToolTip(extraButton, button.ToolTip);
                    }
                    xLeftPos += button.Image.Width;
                }
                xLeftPos += 5;
            }

            // draw the default buttons on the right of the filter textbox
            var xRightPos = Width - Padding.Right;

            // filter mode for tree list
            if (treeList != null)
            {
                var img = treeList.SearchMode == YamuiFilteredTypeTreeList.SearchModeOption.SearchSortWithNoParent ? SearchButtonImage : FilterButtonImage;
                xRightPos -= img.Width;
                var modeButton = new YamuiButtonImage {
                    BackGrndImage = img,
                    Size          = img.Size,
                    Location      = new Point(xRightPos, Padding.Top + (thisHeight - img.Height) / 2),
                    Anchor        = AnchorStyles.Top | AnchorStyles.Right,
                    TabStop       = false
                };
                modeButton.ButtonPressed += OnClickMode;
                Controls.Add(modeButton);
                _tooltip.SetToolTip(modeButton, treeList.SearchMode == YamuiFilteredTypeTreeList.SearchModeOption.SearchSortWithNoParent ? ModeButtonSearchTooltip : ModeButtonFilterTooltip);
            }
            // eraser
            xRightPos -= EraserButtonImage.Width;
            var eraserButton = new YamuiButtonImage {
                BackGrndImage = EraserButtonImage,
                Size          = EraserButtonImage.Size,
                Location      = new Point(xRightPos, Padding.Top + (thisHeight - EraserButtonImage.Height) / 2),
                Anchor        = AnchorStyles.Top | AnchorStyles.Right,
                TabStop       = false
            };

            eraserButton.ButtonPressed += OnClickEraser;
            Controls.Add(eraserButton);
            _tooltip.SetToolTip(eraserButton, EraserButtonTooltip);
            xRightPos -= 5;

            // textbox
            _filterBox.SelectAllTextOnActivate = false;
            _filterBox.Anchor    = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left;
            _filterBox.Location  = new Point(xLeftPos, Padding.Top);
            _filterBox.Size      = new Size(xRightPos - xLeftPos, thisHeight);
            _filterBox.WaterMark = treeList == null || treeList.SearchMode == YamuiFilteredTypeTreeList.SearchModeOption.SearchSortWithNoParent ? WatermarkSearchText : WatermarkFilterText;
            _filterBox.Text      = AssociatedList.FilterString ?? string.Empty;
            Controls.Add(_filterBox);
            _tooltip.SetToolTip(_filterBox, TextBoxTooltip);
        }