コード例 #1
0
        private void AddMouseAction(MouseChord chord, MouseTarget target)
        {
            MouseChord button = chord & ~(MouseChord.Alt | MouseChord.Ctrl | MouseChord.Shift);

            if (!MouseTargetButtons[target].Contains(button))
            {
                var dict = QTUtility.TextResourcesDic["Options_Page07_Mouse"];
                MessageBox.Show(
                    dict[18] + Environment.NewLine +
                    dict[19] + Environment.NewLine +
                    MouseTargetButtons[target].Select(k => "  " + dict[MouseButtonResx[k]])
                    .StringJoin(Environment.NewLine),
                    dict[20], MessageBoxButton.OK, MessageBoxImage.Hand);
                return;
            }
            MouseEntry entry = MouseBindings.FirstOrDefault(e => e.Chord == chord && e.Target == target);

            if (entry == null)
            {
                entry = new MouseEntry(target, chord, BindAction.Nothing);
                MouseBindings.Add(entry);
            }
            entry.IsSelected = true;
            lvwMouseBindings.UpdateLayout();
            lvwMouseBindings.ScrollIntoView(entry);
            // Need to wait for ScrollIntoView to finish, or the dropdown will open in the wrong place.
            Dispatcher.BeginInvoke(DispatcherPriority.Input, new Action(() => { entry.IsEditing = true; }));
        }
コード例 #2
0
        private void rctAddMouseAction_MouseDown(object sender, MouseButtonEventArgs e)
        {
            FrameworkElement control = ((FrameworkElement)sender);
            MouseChord       chord   = MouseChord.None;

            if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
            {
                chord |= MouseChord.Shift;
            }
            if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
            {
                chord |= MouseChord.Ctrl;
            }
            if ((Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt)
            {
                chord |= MouseChord.Alt;
            }
            // ugh.  wish there was a better way to do this, but I don't think there is one...
            MouseTarget target = MouseTargetResx.First(kv => kv.Value == (int)control.Tag).Key;

            // watch out for double clicks
            if (e.ChangedButton == MouseButton.Left)
            {
                if (mouseTimer == null || mouseTimer.Tag != control.Tag)
                {
                    mouseTimer = new DispatcherTimer {
                        Tag      = control.Tag,
                        Interval = TimeSpan.FromMilliseconds(
                            System.Windows.Forms.SystemInformation.DoubleClickTime)
                    };
                    mouseTimer.Tick += (sender2, e2) => {
                        mouseTimer.IsEnabled = false;
                        mouseTimer           = null;
                        chord |= MouseChord.Left;
                        AddMouseAction(chord, target);
                    };
                    mouseTimer.IsEnabled = true;
                }
                else
                {
                    mouseTimer.IsEnabled = false;
                    mouseTimer           = null;
                    chord |= MouseChord.Double;
                    AddMouseAction(chord, target);
                }
            }
            else
            {
                if (mouseTimer != null)
                {
                    mouseTimer.IsEnabled = false;
                    mouseTimer           = null;
                }
                chord |= MouseButtonMappings[e.ChangedButton];
                AddMouseAction(chord, target);
            }
        }
コード例 #3
0
 public MouseEntry(MouseTarget target, MouseChord chord, BindAction action)
 {
     Target = target;
     Action = action;
     Chord  = chord;
 }
コード例 #4
0
 public MouseEntry(MouseTarget target, MouseChord chord, BindAction action) {
     Target = target;
     Action = action;
     Chord = chord;
 }
コード例 #5
0
 private void AddMouseAction(MouseChord chord, MouseTarget target) {
     MouseChord button = chord & ~(MouseChord.Alt | MouseChord.Ctrl | MouseChord.Shift);
     if(!MouseTargetButtons[target].Contains(button)) {
         var dict = QTUtility.TextResourcesDic["Options_Page07_Mouse"];
         MessageBox.Show(
                 dict[18] + Environment.NewLine +
                 dict[19] + Environment.NewLine +
                 MouseTargetButtons[target].Select(k => "  " + dict[MouseButtonResx[k]])
                     .StringJoin(Environment.NewLine),
                 dict[20], MessageBoxButton.OK, MessageBoxImage.Hand);
         return;
     }
     MouseEntry entry = MouseBindings.FirstOrDefault(e => e.Chord == chord && e.Target == target);
     if(entry == null) {
         entry = new MouseEntry(target, chord, BindAction.Nothing);
         MouseBindings.Add(entry);
     }
     entry.IsSelected = true;
     lvwMouseBindings.UpdateLayout();
     lvwMouseBindings.ScrollIntoView(entry);
     // Need to wait for ScrollIntoView to finish, or the dropdown will open in the wrong place.
     Dispatcher.BeginInvoke(DispatcherPriority.Input, new Action(() => { entry.IsEditing = true; }));
 }