예제 #1
0
        /// <summary>
        ///     Filtert eine Meldung, bevor sie gesendet wird.
        /// </summary>
        /// <param name="m">Die zu sendende Meldung. Diese Meldung kann nicht geändert werden.</param>
        /// <returns>
        ///     true, um die Meldung zu filtern und das Senden zu verhindern. false, um das Senden der Meldung bis zum nächsten Filter oder Steuerelement zu ermöglichen.
        /// </returns>
        public bool PreFilterMessage(ref Message m)
        {
            Point mousePosition = Control.MousePosition;
            var   args          = new MouseFilterEventArgs(MouseButtons.Left, 0, mousePosition.X, mousePosition.Y, 0);

            switch (m.Msg)
            {
            case WM_MOUSEMOVE:
                if (MouseFilterMove != null)
                {
                    MouseFilterMove(Control.FromHandle(m.HWnd), args);
                }
                break;

            case WM_LBUTTONDOWN:
                if (MouseFilterDown != null)
                {
                    MouseFilterDown(Control.FromHandle(m.HWnd), args);
                }
                break;

            case WM_LBUTTONUP:
                if (MouseFilterUp != null)
                {
                    MouseFilterUp(Control.FromHandle(m.HWnd), args);
                }
                break;
            }

            // Always allow message to continue to the next filter control
            return(args.Handled);
        }
예제 #2
0
 /// <summary>
 ///     Handles the MouseFilterDown event of the mouseFilter control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">
 ///     The <see cref="MouseFilterEventArgs" /> instance containing the event data.
 /// </param>
 private void mouseFilter_MouseFilterDown(object sender, MouseFilterEventArgs e)
 {
     //  if(this.)
     if (!_doTouchScroll && e.Button == MouseButtons.Left)
     {
         _mouseStartPoint = new Point(e.X, e.Y);
         _panelStartPoint = new Point(-AutoScrollPosition.X,
                                      -AutoScrollPosition.Y);
     }
 }
예제 #3
0
 /// <summary>
 ///     Handles the MouseFilterUp event of the mouseFilter control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">
 ///     The <see cref="MouseFilterEventArgs" /> instance containing the event data.
 /// </param>
 private void mouseFilter_MouseFilterUp(object sender, MouseFilterEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         if (_doTouchScroll && !AutoScrollPosition.Equals(_panelStartPoint) &&
             !_panelStartPoint.Equals(Point.Empty))
         {
             // don't fire Click-Event
             e.Handled = true;
         }
         _doTouchScroll   = false;
         _mouseStartPoint = Point.Empty;
         _panelStartPoint = Point.Empty;
     }
 }
예제 #4
0
        /// <summary>
        ///     Handles the MouseFilterMove event of the mouseFilter control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">
        ///     The <see cref="MouseFilterEventArgs" /> instance containing the event data.
        /// </param>
        private void mouseFilter_MouseFilterMove(object sender, MouseFilterEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (!_mouseStartPoint.Equals(Point.Empty))
                {
                    int dx = (e.X - _mouseStartPoint.X);
                    int dy = (e.Y - _mouseStartPoint.Y);

                    if (_doTouchScroll)
                    {
                        AutoScrollPosition = new Point(_panelStartPoint.X - dx,
                                                       _panelStartPoint.Y - dy);
                    }
                    else if (Math.Abs(dx) > 10 || Math.Abs(dy) > 10)
                    {
                        _doTouchScroll = true;
                    }
                }
            }
        }