예제 #1
0
        public override UIHandleResult OnMouseUp(MouseEventArgs args)
        {
            if (!_control.EnabledEx)
            {
                return(UIHandleResult.Pass);
            }

            if (args.Button == MouseButtons.Right || args.Button == MouseButtons.Middle)
            {
                ITerminalEmulatorOptions opt = TerminalEmulatorPlugin.Instance.TerminalEmulatorOptions;
                MouseButtonAction        act = args.Button == MouseButtons.Right? opt.RightButtonAction : opt.MiddleButtonAction;
                if (act != MouseButtonAction.None)
                {
                    if (Control.ModifierKeys == Keys.Shift ^ act == MouseButtonAction.ContextMenu)                //シフトキーで動作反転
                    {
                        ShowContextMenu(new Point(args.X, args.Y));
                    }
                    else                       //Paste
                    {
                        IGeneralViewCommands vc = (IGeneralViewCommands)_control.GetAdapter(typeof(IGeneralViewCommands));
                        TerminalEmulatorPlugin.Instance.GetCommandManager().Execute(vc.Paste, (ICommandTarget)vc.GetAdapter(typeof(ICommandTarget)));
                        //ペースト後はフォーカス
                        if (!_control.Focused)
                        {
                            _control.Focus();
                        }
                    }

                    return(UIHandleResult.Stop);
                }
            }

            return(UIHandleResult.Pass);
        }
예제 #2
0
        /// <summary>
        /// Add a new listener to the specific action passed in.
        /// </summary>
        /// <param name="action">The action to listen for.</param>
        /// <param name="listener">The listener to alert.</param>
        public void AddListener(MouseButtonAction action, MouseButtonListener listener)
        {
            switch (action)
            {
            case MouseButtonAction.Down:
                if (downListeners == null)
                {
                    downListeners = new List <MouseButtonListener>();
                }

                downListeners.Add(listener);
                break;

            case MouseButtonAction.Pressed:
                if (pressedListeners == null)
                {
                    pressedListeners = new List <MouseButtonListener>();
                }

                pressedListeners.Add(listener);
                break;

            case MouseButtonAction.Up:
                if (upListeners == null)
                {
                    upListeners = new List <MouseButtonListener>();
                }

                upListeners.Add(listener);
                break;
            }
        }
예제 #3
0
        public MapMouseButtonForm(PadTieForm main, Controller cc, MouseButtonAction editing) :
            this(main, cc)
        {
            this.editing = editing;

            mouseButton.SelectedIndex = (int)editing.Button;
            slotCapture.SetInput(editing.SlotDescription, true);
        }
예제 #4
0
 public override void OnMouseButtonAction(Point point, MouseButtonAction type)
 {
     Point subItemPoint;
     GridItemBase subItem = CurrentItem(point, out subItemPoint);
     if (subItem != null)
         subItem.OnMouseButtonAction(subItemPoint, type);
     else
         base.OnMouseButtonAction(point, type);
 }
예제 #5
0
 /// <summary>
 /// Remove very single listener from a button
 /// and action of it.
 /// </summary>
 /// <param name="button">The button to remove listeners from.</param>
 /// <param name="action">The action to clear listeners of.</param>
 public void RemoveAllListeners(MouseButton button, MouseButtonAction action)
 {
     for (int i = 0, keyCount = buttonHandlers.Count; i < keyCount; i++)
     {
         if (buttonHandlers[i].Button == button)
         {
             buttonHandlers[i].RemoveAllListeners(action);
             break;
         }
     }
 }
예제 #6
0
        private void okBtn_Click(object sender, EventArgs e)
        {
            MouseButtonAction.Buttons b = MouseButtonAction.Buttons.Left;

            if (mouseButton.Text == "Left")
            {
                b = MouseButtonAction.Buttons.Left;
            }
            else if (mouseButton.Text == "Middle")
            {
                b = MouseButtonAction.Buttons.Middle;
            }
            else if (mouseButton.Text == "Right")
            {
                b = MouseButtonAction.Buttons.Right;
            }
            else if (mouseButton.Text.StartsWith("Extra 1"))
            {
                b = MouseButtonAction.Buttons.Back;
            }
            else if (mouseButton.Text.StartsWith("Extra 2"))
            {
                b = MouseButtonAction.Buttons.Forward;
            }

            if (slotCapture.Value == null)
            {
                MessageBox.Show("Please click Capture and press a button or axis direction on the gamepad.");
                return;
            }

            var         input = slotCapture.Value;
            InputAction action;

            if (editing != null)
            {
                editing.Button = b;

                if (input != editing.SlotDescription)
                {
                    MapUtil.Map(MainForm, Controller.Virtual, editing.SlotDescription, null);
                }
                action = editing;
            }
            else
            {
                action = new MouseButtonAction(Controller.Core, b);
            }
            MapUtil.Map(MainForm, Controller.Virtual, input, action);

            DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }
예제 #7
0
        public override void OnMouseButtonAction(Point point, MouseButtonAction type)
        {
            Point        subItemPoint;
            GridItemBase subItem = CurrentItem(point, out subItemPoint);

            if (subItem != null)
            {
                subItem.OnMouseButtonAction(subItemPoint, type);
            }
            else
            {
                base.OnMouseButtonAction(point, type);
            }
        }
예제 #8
0
 /// <summary>
 /// Remove an existing listener from it's key and action.
 /// </summary>
 /// <param name="button">The button to remove a listener from.</param>
 /// <param name="action">The action to stop listening to.</param>
 /// <param name="listener">The listener to remove.</param>
 public void RemoveListener(MouseButton button, MouseButtonAction action, MouseButtonListener listener)
 {
     if (buttonHandlers != null)
     {
         for (int i = 0, keyHandlerCount = buttonHandlers.Count; i < keyHandlerCount; i++)
         {
             if (buttonHandlers[i].Button == button)
             {
                 buttonHandlers[i].RemoveListener(action, listener);
                 return;
             }
         }
     }
 }
예제 #9
0
        /// <summary>
        /// Remove a specific listener from the action.
        /// </summary>
        /// <param name="action">The action to remove a listener of.</param>
        /// <param name="listener">The listener to remove.</param>
        public void RemoveListener(MouseButtonAction action, MouseButtonListener listener)
        {
            switch (action)
            {
            case MouseButtonAction.Down:
                if (downListeners != null)
                {
                    for (int i = 0, downCount = downListeners.Count; i < downCount; i++)
                    {
                        if (downListeners[i] == listener)
                        {
                            downListeners.RemoveAt(i);
                            break;
                        }
                    }
                }
                break;

            case MouseButtonAction.Pressed:
                if (pressedListeners != null)
                {
                    for (int i = 0, pressedCount = pressedListeners.Count; i < pressedCount; i++)
                    {
                        if (pressedListeners[i] == listener)
                        {
                            pressedListeners.RemoveAt(i);
                            break;
                        }
                    }
                }
                break;

            case MouseButtonAction.Up:
                if (upListeners != null)
                {
                    for (int i = 0, upCount = upListeners.Count; i < upCount; i++)
                    {
                        if (upListeners[i] == listener)
                        {
                            upListeners.RemoveAt(i);
                            break;
                        }
                    }
                }
                break;
            }
        }
예제 #10
0
        /// <summary>
        /// Remove all listeners from a specific action of the mouse
        /// button handler.
        /// </summary>
        /// <param name="action">The action to remove all listeners from.</param>
        public void RemoveAllListeners(MouseButtonAction action)
        {
            switch (action)
            {
            case MouseButtonAction.Down:
                downListeners = null;
                break;

            case MouseButtonAction.Pressed:
                pressedListeners = null;
                break;

            case MouseButtonAction.Up:
                upListeners = null;
                break;
            }
        }
예제 #11
0
        internal void OnMouseButtonAction(Point point, MouseButtonAction type)
        {
            if (HasLeftExpander)
            {
                Image     image = Expanded ? ExpandedImage : ShrunkenImage;
                Size      s     = new Size(image.Width * 3, image.Height * 3);
                Rectangle r     = new Rectangle(new Point(), s);

                if (r.Contains(point))
                {
                    if (type == MouseButtonAction.MouseDown)
                    {
                        Expanded = !Expanded;
                        GridView.Refresh();
                    }
                    else
                    {
                        return;
                    }
                }
            }

            if (point.Y < RowHeight) // user has clicked on the row
            {
                Point        p;
                GridItemBase item = FindItemFromPoint(point, out p);
                if (item == null)
                {
                    return;
                }
                item.OnMouseButtonAction(p, type);
                return;
            }
            else // user has clicked on a sub row of the row
            {
                Point   p;
                GridRow row = FindRowFromPoint(point, out p);
                if (row == null)
                {
                    return;
                }
                row.OnMouseButtonAction(p, type);
            }
        }
예제 #12
0
        protected virtual void OnMouseButtonAction(MouseEventArgs e, MouseButtonAction type)
        {
            if (HeaderRow == null)
            {
                return;
            }

            if (!DraggingColumns && !ResizingColumns)
            {
                this.Focus();
                Point   p;
                GridRow row = FindRowFromPoint(e.Location, out p);
                if (row == null)
                {
                    return;
                }

                if (e.Button == MouseButtons.Right && row is GridHeaderRow)
                {
                    OpenChooseColumnsMenu(e.Location);
                }
                else if (e.Button == MouseButtons.Left)
                {
                    if (Cursor == Cursors.SizeWE)
                    {
                        if (type == MouseButtonAction.DoubleClick)
                        {
                            FitColumnWidthToHeaderAndContents(row, p);
                        }
                    }
                    else
                    {
                        row.OnMouseButtonAction(p, type);
                    }
                }
                else if (type == MouseButtonAction.SingleRightClick)
                {
                    row.OnMouseButtonAction(p, type);
                }
            }
        }
예제 #13
0
        /// <summary>
        /// Add a new event listener to the specific mouse button,
        /// and action.
        /// </summary>
        /// <param name="button">The button to listen for.</param>
        /// <param name="action">It's life cycle event to listen for.</param>
        /// <param name="listener">The listener to invoke.</param>
        public void AddListener(MouseButton button, MouseButtonAction action, MouseButtonListener listener)
        {
            if (buttonHandlers != null)
            {
                for (int i = 0, keyHandlerCount = buttonHandlers.Count; i < keyHandlerCount; i++)
                {
                    if (buttonHandlers[i].Button == button)
                    {
                        buttonHandlers[i].AddListener(action, listener);
                        return;
                    }
                }
            }
            else
            {
                buttonHandlers = new List <MouseButtonHandler>();
            }

            MouseButtonHandler buttonHandler = new MouseButtonHandler(button);

            buttonHandler.AddListener(action, listener);
            buttonHandlers.Add(buttonHandler);
        }
예제 #14
0
 public virtual void OnMouseButtonAction(Point point, MouseButtonAction type)
 {
     if (type == MouseButtonAction.DoubleClick)
     {
         OnDoubleClick(point);
     }
     else if (type == MouseButtonAction.SingleClick)
     {
         OnClick(point);
     }
     else if (type == MouseButtonAction.StartDrag)
     {
         OnStartDrag(point);
     }
     else if (type == MouseButtonAction.SingleRightClick)
     {
         OnRightClick(point);
     }
     else
     {
         OnMouseDown(point);
     }
 }
예제 #15
0
파일: GridView.cs 프로젝트: huizh/xenadmin
        protected virtual void OnMouseButtonAction(MouseEventArgs e, MouseButtonAction type)
        {
            if (HeaderRow == null)
                return;

            if (!DraggingColumns && !ResizingColumns)
            {
                this.Focus();
                Point p;
                GridRow row = FindRowFromPoint(e.Location, out p);
                if (row == null)
                    return;

                if (e.Button == MouseButtons.Right && row is GridHeaderRow)
                {
                    OpenChooseColumnsMenu(e.Location);
                }
                else if (e.Button == MouseButtons.Left)
                {
                    if (Cursor == Cursors.SizeWE)
                    {
                        if (type == MouseButtonAction.DoubleClick)
                            FitColumnWidthToHeaderAndContents(row, p);
                    }
                    else
                    {
                        row.OnMouseButtonAction(p, type);
                    }
                }
                else if (type == MouseButtonAction.SingleRightClick)
                {
                    row.OnMouseButtonAction(p, type);
                }
            }
        }
예제 #16
0
 internal NativeMouseButtonEventArgs(int w)
 {
     Button = (MouseButton)(w & 0xF);
     Action = (MouseButtonAction)(w >> 16);
 }
예제 #17
0
 internal MouseButtonHook(MouseButtonAction buttonAction, Action<MouseButton> hookMethod)
 {
     ButtonAction = buttonAction;
     HookMethod = hookMethod;
 }
예제 #18
0
 public MouseButtonAssignment(MouseButtons button, MouseButtonAction action, MouseButtonActionType actionType)
 {
     _button = button;
     _action = action;
     _actionType = actionType;
 }
        public static IntPtr NcHitTest([NotNull] this Form form, Point mouseLocation, MouseButtonAction action, int horizontalMargin, int verticalMargin, int captionMargin)
        {
            if (action == MouseButtonAction.None)
            {
                return(IntPtr.Zero);
            }

            try {
                NativeMethods.ReleaseCapture();

                int ncAction;

                switch (action)
                {
                case MouseButtonAction.LeftButtonDown:
                    ncAction = NativeConstants.WM_NCLBUTTONDOWN;
                    break;

                case MouseButtonAction.LeftButtonUp:
                    ncAction = NativeConstants.WM_NCLBUTTONUP;
                    break;

                case MouseButtonAction.LeftButtonDoubleClick:
                    ncAction = NativeConstants.WM_NCLBUTTONDBLCLK;
                    break;

                case MouseButtonAction.RightButtonDown:
                    ncAction = NativeConstants.WM_NCRBUTTONDOWN;
                    break;

                case MouseButtonAction.RightButtonUp:
                    ncAction = NativeConstants.WM_NCRBUTTONUP;
                    break;

                case MouseButtonAction.RightButtonDoubleClick:
                    ncAction = NativeConstants.WM_NCRBUTTONDBLCLK;
                    break;

                case MouseButtonAction.MouseMove:
                    ncAction = NativeConstants.WM_NCMOUSEMOVE;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(action), action, null);
                }

                int    ncLocation;
                Cursor formCursor;
                var    size        = form.Size;
                var    isMaximized = form.WindowState == FormWindowState.Maximized;

                if (mouseLocation.X <= horizontalMargin)
                {
                    if (!isMaximized)
                    {
                        if (mouseLocation.Y <= verticalMargin)
                        {
                            formCursor = Cursors.SizeNWSE;
                            ncLocation = NativeConstants.HTTOPLEFT;
                        }
                        else if (mouseLocation.Y >= size.Height - verticalMargin)
                        {
                            formCursor = Cursors.SizeNESW;
                            ncLocation = NativeConstants.HTBOTTOMLEFT;
                        }
                        else
                        {
                            formCursor = Cursors.SizeWE;
                            ncLocation = NativeConstants.HTLEFT;
                        }
                    }
                    else
                    {
                        formCursor = Cursors.Default;
                        ncLocation = NativeConstants.HTCLIENT;
                    }
                }
                else if (mouseLocation.X >= size.Width - horizontalMargin)
                {
                    if (!isMaximized)
                    {
                        if (mouseLocation.Y <= verticalMargin)
                        {
                            formCursor = Cursors.SizeNESW;
                            ncLocation = NativeConstants.HTTOPRIGHT;
                        }
                        else if (mouseLocation.Y >= size.Height - verticalMargin)
                        {
                            formCursor = Cursors.SizeNWSE;
                            ncLocation = NativeConstants.HTBOTTOMRIGHT;
                        }
                        else
                        {
                            formCursor = Cursors.SizeWE;
                            ncLocation = NativeConstants.HTRIGHT;
                        }
                    }
                    else
                    {
                        formCursor = Cursors.Default;
                        ncLocation = NativeConstants.HTCLIENT;
                    }
                }
                else
                {
                    if (mouseLocation.Y <= verticalMargin)
                    {
                        if (!isMaximized)
                        {
                            formCursor = Cursors.SizeNS;
                            ncLocation = NativeConstants.HTTOP;
                        }
                        else
                        {
                            formCursor = Cursors.Default;
                            ncLocation = NativeConstants.HTCLIENT;
                        }
                    }
                    else if (mouseLocation.Y <= captionMargin)
                    {
                        formCursor = Cursors.Default;
                        ncLocation = NativeConstants.HTCAPTION;

                        if (action == MouseButtonAction.LeftButtonDoubleClick)
                        {
                            form.Cursor      = formCursor;
                            form.WindowState = form.WindowState == FormWindowState.Maximized ? FormWindowState.Normal : FormWindowState.Maximized;

                            return(IntPtr.Zero);
                        }
                    }
                    else if (mouseLocation.Y >= size.Height - verticalMargin)
                    {
                        if (!isMaximized)
                        {
                            formCursor = Cursors.SizeNS;
                            ncLocation = NativeConstants.HTBOTTOM;
                        }
                        else
                        {
                            formCursor = Cursors.Default;
                            ncLocation = NativeConstants.HTCLIENT;
                        }
                    }
                    else
                    {
                        formCursor = Cursors.Default;
                        ncLocation = NativeConstants.HTCLIENT;
                    }
                }

                form.Cursor = formCursor;

                return(NativeMethods.SendMessage(form.Handle, ncAction, (IntPtr)ncLocation, IntPtr.Zero));
            } catch (Win32Exception ex) {
                Debug.Print(ex.ToString());
            }

            return(IntPtr.Zero);
        }