예제 #1
0
        private void OnRightClick(object sender, int id)
        {
            if (id == data.uID && contextMenu != null)
            {
                Point     pt    = Control.MousePosition;
                GDI.POINT point = new GDI.POINT();
                point.x = pt.X;
                point.y = pt.Y;

                // this ensures that if we show the menu and then click on another window the menu will close
                WindowsManagement.SetForegroundWindow(messageSink.Handle);

                if (BeforeShowMenu != null)
                {
                    BeforeShowMenu(this, EventArgs.Empty);
                }
                // call non public member of ContextMenu
                contextMenu.GetType().InvokeMember("OnPopup",
                                                   BindingFlags.NonPublic | BindingFlags.InvokeMethod | BindingFlags.Instance,
                                                   null, contextMenu, new Object[] { System.EventArgs.Empty });
                WindowsManagement.TrackPopupMenuEx(contextMenu.Handle, 64, point.x, point.y, messageSink.Handle, IntPtr.Zero);
                if (AfterShowMenu != null)
                {
                    AfterShowMenu(this, EventArgs.Empty);
                }
            }
        }
예제 #2
0
        public void SelectDvdMenuButtonAtPosition(GDI.POINT point)
        {
            var dvdFilterGraph = _filterGraph as IDvdFilterGraph;

            if (dvdFilterGraph != null && dvdFilterGraph.IsMenuOn)
            {
                dvdFilterGraph.SelectDvdMenuButtonAtPosition(point);
            }
        }
예제 #3
0
            public void HandleMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam)
            {
                switch (msg)
                {
                case (uint)WindowsMessages.WM_LBUTTONDBLCLK:
                    _doubleClick = true;
                    _mwh.RaiseEvent(new RoutedEventArgs(MWDoubleClickEvent));
                    break;

                case (uint)WindowsMessages.WM_CONTEXTMENU:
                {
                    var args = CreateScreenPositionEventArgs();
                    args.RoutedEvent = MWContextMenuEvent;
                    _mwh.RaiseEvent(args);
                }
                break;

                case (uint)WindowsMessages.WM_LBUTTONUP:
                {
                    IMediaWindow mediaWindow = _host.GetMediaWindow();
                    if (mediaWindow != null && mediaWindow.Handle == hWnd && _mwh.MediaEngine.IsMenuOn)
                    {
                        uint mylParam = (uint)lParam;
                        uint x        = mylParam & 0x0000FFFF;
                        uint y        = mylParam & 0xFFFF0000;
                        y >>= 16;

                        GDI.POINT pt = new GDI.POINT();
                        pt.x = (int)x;
                        pt.y = (int)y;
                        _mwh.MediaEngine.ActivateDvdMenuButtonAtPosition(pt);
                    }

                    if (!_mwh.MediaEngine.IsMenuOn && !_doubleClick)
                    {
                        _mwh.RaiseEvent(new RoutedEventArgs(MWClickEvent));
                    }
                    _doubleClick = false;
                }
                break;

                case (uint)WindowsMessages.WM_MOUSEMOVE:
                    if ((uint)lParam != _previousMousePosition)     // mouse was actually moved as its position has changed
                    {
                        _previousMousePosition = (uint)lParam;

                        IMediaWindow mediaWindow = _host.GetMediaWindow();
                        if (mediaWindow != null && mediaWindow.Handle == hWnd && _mwh.MediaEngine.IsMenuOn)
                        {
                            uint mylParam = (uint)lParam;
                            uint x        = mylParam & 0x0000FFFF;
                            uint y        = mylParam & 0xFFFF0000;
                            y >>= 16;

                            GDI.POINT pt = new GDI.POINT();
                            pt.x = (int)x;
                            pt.y = (int)y;
                            _mwh.MediaEngine.SelectDvdMenuButtonAtPosition(pt);
                        }

                        if (!_mouseOnWindow)
                        {
                            WindowsManagement.TRACKMOUSEEVENT tme =
                                new WindowsManagement.TRACKMOUSEEVENT();
                            tme.cbSize      = Marshal.SizeOf(tme);
                            tme.dwFlags     = WindowsManagement.TME_LEAVE;
                            tme.dwHoverTime = WindowsManagement.HOVER_DEFAULT;
                            tme.hwndTrack   = hWnd;

                            WindowsManagement._TrackMouseEvent(ref tme);
                            _mouseOnWindow = true;
                            _mwh.RaiseEvent(new RoutedEventArgs(MWMouseEnterEvent));
                        }

                        var args = CreateScreenPositionEventArgs();
                        args.RoutedEvent = MWMouseMoveEvent;
                        _mwh.RaiseEvent(args);
                    }
                    break;

                case (uint)WindowsMessages.WM_MOUSELEAVE:
                    _mouseOnWindow = false;
                    _mwh.RaiseEvent(new RoutedEventArgs(MWMouseLeaveEvent));
                    break;

                case (uint)WindowsMessages.WM_KEYDOWN:
                    var modifiers = Keyboard.Modifiers;
                    var code      = wParam.ToInt32();
                    var key       = KeyInterop.KeyFromVirtualKey(code);

                    var handled = HandleKey(key);

                    if (!handled)
                    {
                        _mwh.RaiseEvent(new MWKeyEventArgs(MWKeyDownEvent, key, modifiers));
                    }
                    break;

                case (uint)WindowsMessages.WM_MOUSEWHEEL:
                    uint delta = ((uint)wParam) & 0xFFFF0000;
                    delta >>= 16;
                    _mwh.RaiseEvent(new MWMouseWheelEventArgs(MWMouseWheelEvent, (short)delta));     // it's WORD (2 bytes)
                    break;
                }
            }
예제 #4
0
            public void HandleMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam)
            {
                switch (Msg)
                {
                case (uint)WindowsMessages.WM_LBUTTONDBLCLK:
                    _doubleClick = true;
                    if (_mwh.MWDoubleClick != null)
                    {
                        _mwh.MWDoubleClick(_mwh, EventArgs.Empty);
                    }
                    break;

                case (uint)WindowsMessages.WM_CONTEXTMENU:
                    if (!_trackingContextMenu)
                    {
                        _trackingContextMenu = true;
                        if (_mwh.MWContextMenu != null)
                        {
                            _mwh.MWContextMenu(Cursor.Position);
                        }
                    }
                    else
                    {
                        _trackingContextMenu = false;
                    }
                    break;

                case (uint)WindowsMessages.WM_LBUTTONUP:
                {
                    IMediaWindow mediaWindow = _host.GetMediaWindow();
                    if (mediaWindow != null && mediaWindow.Handle == hWnd && _mwh._engine.IsMenuOn)
                    {
                        uint mylParam = (uint)lParam;
                        uint x        = mylParam & 0x0000FFFF;
                        uint y        = mylParam & 0xFFFF0000;
                        y >>= 16;

                        GDI.POINT pt = new GDI.POINT();
                        pt.x = (int)x;
                        pt.y = (int)y;
                        _mwh._engine.ActivateDvdMenuButtonAtPosition(pt);
                    }

                    if (!_mwh._engine.IsMenuOn && !_doubleClick && _mwh.MWClick != null)
                    {
                        _mwh.MWClick(_mwh, EventArgs.Empty);
                    }
                    _doubleClick = false;
                }
                break;

                case (uint)WindowsMessages.WM_MOUSEMOVE:
                    if ((uint)lParam != _previousMousePosition)     // mouse was actually moved as its position has changed
                    {
                        _previousMousePosition = (uint)lParam;

                        IMediaWindow mediaWindow = _host.GetMediaWindow();
                        if (mediaWindow != null && mediaWindow.Handle == hWnd && _mwh._engine.IsMenuOn)
                        {
                            uint mylParam = (uint)lParam;
                            uint x        = mylParam & 0x0000FFFF;
                            uint y        = mylParam & 0xFFFF0000;
                            y >>= 16;

                            GDI.POINT pt = new GDI.POINT();
                            pt.x = (int)x;
                            pt.y = (int)y;
                            _mwh._engine.SelectDvdMenuButtonAtPosition(pt);
                        }

                        if (!_mwh._mouseOnWindow)
                        {
                            WindowsManagement.TRACKMOUSEEVENT tme =
                                new WindowsManagement.TRACKMOUSEEVENT();
                            tme.cbSize      = Marshal.SizeOf(tme);
                            tme.dwFlags     = WindowsManagement.TME_LEAVE;
                            tme.dwHoverTime = WindowsManagement.HOVER_DEFAULT;
                            tme.hwndTrack   = hWnd;

                            WindowsManagement._TrackMouseEvent(ref tme);
                            _mwh._mouseOnWindow = true;
                            if (_mwh.MWMouseEnter != null)
                            {
                                _mwh.MWMouseEnter(_mwh, EventArgs.Empty);
                            }
                        }

                        if (_mwh.MWMouseMove != null)
                        {
                            _mwh.MWMouseMove(_mwh, EventArgs.Empty);
                        }
                    }
                    break;

                case (uint)WindowsMessages.WM_MOUSELEAVE:
                    _mwh._mouseOnWindow = false;
                    if (_mwh.MWMouseLeave != null)
                    {
                        _mwh.MWMouseLeave(_mwh, EventArgs.Empty);
                    }
                    break;
                }
            }