private void CheckMessage(object?sender, WindowMessageEventArgs e)
 {
     if ((int)e.WParam == deviceNodesChanged)
     {
         DeviceArrived?.Invoke(sender, e);
     }
 }
Пример #2
0
 void FilterCore_WindowMessage(object sender, WindowMessageEventArgs e)
 {
     try
     {
         fastQuit.FilterCore_WindowMessage(sender, e);
     }
     catch (Exception ex) { Debug.LogException(ex); }
 }
		void Current_WindowMessage(object sender, WindowMessageEventArgs e)
		{
			try
			{
				if (e.Msg == WM_LBUTTONDOWN)
					lastLeftClick = DateTime.Now;
			}
			catch (Exception ex) { Debug.LogException(ex); }
		}
 void Current_WindowMessage(object sender, WindowMessageEventArgs e)
 {
     try
     {
         if (e.Msg == WM_LBUTTONDOWN)
         {
             lastLeftClick = DateTime.UtcNow;
         }
     }
     catch (Exception ex) { Debug.LogException(ex); }
 }
Пример #5
0
        private IntPtr HookMethod(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam, ref bool handled)
        {
            if (!registrations.TryGetValue(msg, out var handler))
            {
                return(IntPtr.Zero);
            }

            var args = new WindowMessageEventArgs(hwnd, msg, wparam, lparam, handled);

            handler.Invoke(args);
            handled = args.Handled;
            return(args.ReturnValue);
        }
        public void DispatchWindowMessage(object sender, WindowMessageEventArgs e)
        {
            try
            {
                if (e.Msg >= WM_MOUSEFIRST && e.Msg <= WM_MOUSELAST && !Disposed)
                {
                    if (e.Msg == WM_MOUSEMOVE)
                    {
                        mMousePos = new Point(e.LParam);
                    }
                    // Don't handle mouse events when the mouse is on the view
                    else if (DefaultViewActive &&
                             (e.Msg == WM_LBUTTONDOWN || e.Msg == WM_MBUTTONDOWN ||
                              e.Msg == WM_RBUTTONDOWN || e.Msg == WM_MOUSEWHEEL) &&
                             DefaultView.Position.Contains(new Point(e.LParam)))
                    {
                        return;
                    }

                    // Make a copy of the list in case it is modified while
                    // processing the message (like if one of the mouse event
                    // handlers calls BringToFront()).
                    UpdateHudsListCopy();
                    bool origEat = e.Eat;
                    if (!e.Eat)
                    {
                        foreach (IManagedHud hud in mHudsListCopy)
                        {
                            // It's possible for the hud to be disposed if a
                            // mouse event handler for another one disposes it.
                            if (!hud.Disposed)
                            {
                                hud.WindowMessage(e);
                                if (e.Eat)
                                {
                                    break;
                                }
                            }
                        }

                        // Don't let huds eat mouse moves
                        if (e.Eat != origEat && e.Msg == WM_MOUSEMOVE)
                        {
                            e.Eat = origEat;
                        }
                    }
                }
            }
            catch (Exception ex) { HandleException(ex); }
        }
Пример #7
0
        private void DeviceStatusChanged(object?sender, WindowMessageEventArgs e)
        {
            // may eventually be able to detect "USB card in reader
            //http://stackoverflow.com/questions/14607564/detect-sd-card-insertion-from-a-windows-service

            switch ((int)e.WParam)
            {
            case VolumeArrived:
                NotifyVolumeChange(e.LParam, Attached);
                break;

            case VolumeLeft:
                NotifyVolumeChange(e.LParam, Removed);
                break;
            }
        }
Пример #8
0
		public void FilterCore_WindowMessage(object sender, WindowMessageEventArgs e)
		{
			if (String.IsNullOrEmpty(CoreManager.Current.CharacterFilter.Name) || CoreManager.Current.CharacterFilter.Name == "LoginNotComplete")
			{
				/*
				message 0100 WM_KEYDOWN
				wParam 0000001B
				lParam 00010001
				*/
				if (e.Msg == 0x0100 && e.WParam == 0x0000001B && e.LParam == 0x00010001) // Esc Key
				{
					// Click the Yes button
					Mag.Shared.PostMessageTools.ClickYes();
				}
			}
		}
Пример #9
0
 public void FilterCore_WindowMessage(object sender, WindowMessageEventArgs e)
 {
     if (String.IsNullOrEmpty(CoreManager.Current.CharacterFilter.Name) || CoreManager.Current.CharacterFilter.Name == "LoginNotComplete")
     {
         /*
          * message 0100 WM_KEYDOWN
          * wParam 0000001B
          * lParam 00010001
          */
         if (e.Msg == 0x0100 && e.WParam == 0x0000001B && e.LParam == 0x00010001)                 // Esc Key
         {
             // Click the Yes button
             Filter.Shared.PostMessageTools.ClickYes();
         }
     }
 }
Пример #10
0
		void Current_WindowMessage(object sender, WindowMessageEventArgs e)
		{
			try
			{
				if (Settings.SettingsManager.Misc.NoFocusFPS.Value == Settings.SettingsManager.Misc.NoFocusFPS.DefaultValue)
				{
					Throttling = false;
					return;
				}

				if (e.Msg == User32.WM_KILLFOCUS)
					Throttling = true;

				if (e.Msg == 7 && e.LParam == 0 && e.WParam == 0)
					Throttling = false;
			}
			catch (Exception ex) { Debug.LogException(ex); }
		}
        private void WindowMessage(object sender, WindowMessageEventArgs e)
        {
            if (e.Message == NativeMethods.WM_APPCOMMAND)
            {
                int cmd = NativeMethods.GET_APPCOMMAND_LPARAM(e.lParam);
                switch (cmd)
                {
                case NativeMethods.APPCOMMAND_MEDIA_PLAY:
                    ResumeSlideShow();
                    break;

                case NativeMethods.APPCOMMAND_MEDIA_PAUSE:
                    PauseSlideShow();
                    break;

                case NativeMethods.APPCOMMAND_MEDIA_PLAY_PAUSE:
                    PlayPauseSlideShow();
                    break;
                }
            }
        }
Пример #12
0
        void Current_WindowMessage(object sender, WindowMessageEventArgs e)
        {
            try
            {
                if (Settings.SettingsManager.Misc.NoFocusFPS.Value <= Settings.SettingsManager.Misc.NoFocusFPS.DefaultValue)
                {
                    ToggleNonFocusFPSBoost(false);
                    return;
                }

                if (e.Msg == User32.WM_KILLFOCUS)
                {
                    ToggleNonFocusFPSBoost(true);
                }
                else if (e.Msg == User32.WM_SETFOCUS && e.LParam == 0 && e.WParam == 0)
                {
                    ToggleNonFocusFPSBoost(false);
                }
            }
            catch (Exception ex) { Debug.LogException(ex); }
        }
Пример #13
0
        void Current_WindowMessage(object sender, WindowMessageEventArgs e)
        {
            try
            {
                if (Settings.SettingsManager.Misc.NoFocusFPS.Value == Settings.SettingsManager.Misc.NoFocusFPS.DefaultValue)
                {
                    Throttling = false;
                    return;
                }

                if (e.Msg == User32.WM_KILLFOCUS)
                {
                    Throttling = true;
                }

                if (e.Msg == 7 && e.LParam == 0 && e.WParam == 0)
                {
                    Throttling = false;
                }
            }
            catch (Exception ex) { Debug.LogException(ex); }
        }
Пример #14
0
 private void a(object A_0, WindowMessageEventArgs A_1)
 {
     try
     {
         if ((A_1.get_Msg() == 0x100) && ((A_1.get_LParam() & 0x40000000) == 0))
         {
             u u = (u)A_1.get_WParam();
             if (((u == this.a(c6.a)) || (u == this.a(c6.b))) || (u == this.a(c6.c)))
             {
                 int num = -1;
                 for (int i = 0; i < this.l.Count; i++)
                 {
                     TimeSpan span = (TimeSpan)(DateTimeOffset.Now - this.l[i]);
                     if (span.TotalSeconds <= 2.0)
                     {
                         break;
                     }
                     num = i;
                 }
                 if (num >= 0)
                 {
                     this.l.RemoveRange(0, num + 1);
                 }
                 if (this.l.Count > 0)
                 {
                     this.l.RemoveAt(0);
                 }
                 else
                 {
                     this.k = false;
                 }
             }
         }
     }
     catch (Exception exception)
     {
         ad.a(exception);
     }
 }
Пример #15
0
        void IManagedHud.WindowMessage(WindowMessageEventArgs e)
        {
            const short WM_MOUSEMOVE   = 0x200;
            const short WM_LBUTTONDOWN = 0x201;
            const short WM_LBUTTONUP   = 0x202;
            // A hack to reduce the number of checks for every windows message
            const short HANDLED_MESSAGES = WM_MOUSEMOVE | WM_LBUTTONDOWN | WM_LBUTTONUP;

            try
            {
                if ((e.Msg & HANDLED_MESSAGES) != 0 && IsHudVisible())
                {
                    mMousePos = new Point(e.LParam);

                    switch (e.Msg)
                    {
                    case WM_MOUSEMOVE:
                        if (mMouseMovingHud)
                        {
                            Location = new Point(mMousePos.X - mMouseHudOffset.X, mMousePos.Y - mMouseHudOffset.Y);
                            if (HudMoving != null)
                            {
                                HudMoving(this, EventArgs.Empty);
                            }
                        }
                        break;

                    case WM_LBUTTONDOWN:
                        if (HasRoute)
                        {
                            if (mRouteNextRect.Contains(mMousePos))
                            {
                                RouteIndex++;
                                e.Eat = true;
                            }
                            else if (mRoutePrevRect.Contains(mMousePos))
                            {
                                RouteIndex--;
                                e.Eat = true;
                            }
                        }

                        if (IsMouseHovering())
                        {
                            Rectangle absCloseBoxRect = new Rectangle(Location.X + mCloseBoxRect.X,
                                                                      Location.Y + mCloseBoxRect.Y, mCloseBoxRect.Width, mCloseBoxRect.Height);

                            if (absCloseBoxRect.Contains(mMousePos))
                            {
                                Visible = false;
                            }
                            else
                            {
                                mMouseMovingHud   = true;
                                mMouseHudOffset.X = mMousePos.X - mLocation.X;
                                mMouseHudOffset.Y = mMousePos.Y - mLocation.Y;
                            }
                            e.Eat = true;
                        }
                        break;

                    case WM_LBUTTONUP:
                        if (mMouseMovingHud)
                        {
                            mMouseMovingHud = false;
                            if (HudMoveComplete != null)
                            {
                                HudMoveComplete(this, EventArgs.Empty);
                            }
                            e.Eat = true;
                        }
                        break;
                    }
                }
            }
            catch (Exception ex) { Util.HandleException(ex); }
        }
Пример #16
0
 public void Invoke(WindowMessageEventArgs args) => MessageReceived?.Invoke(this, args);
Пример #17
0
		void IManagedHud.WindowMessage(WindowMessageEventArgs e)
		{
			const short WM_MOUSEMOVE = 0x200;
			const short WM_LBUTTONDOWN = 0x201;
			const short WM_LBUTTONUP = 0x202;
			// A hack to reduce the number of checks for every windows message
			const short HANDLED_MESSAGES = WM_MOUSEMOVE | WM_LBUTTONDOWN | WM_LBUTTONUP;

			try
			{
				if ((e.Msg & HANDLED_MESSAGES) != 0 && IsHudVisible())
				{

					mMousePos = new Point(e.LParam);

					switch (e.Msg)
					{
						case WM_MOUSEMOVE:
							if (mMouseMovingHud)
							{
								Location = new Point(mMousePos.X - mMouseHudOffset.X, mMousePos.Y - mMouseHudOffset.Y);
								if (HudMoving != null)
									HudMoving(this, EventArgs.Empty);
							}
							break;

						case WM_LBUTTONDOWN:
							if (HasRoute)
							{
								if (mRouteNextRect.Contains(mMousePos))
								{
									RouteIndex++;
									e.Eat = true;
								}
								else if (mRoutePrevRect.Contains(mMousePos))
								{
									RouteIndex--;
									e.Eat = true;
								}
							}

							if (IsMouseHovering())
							{
								Rectangle absCloseBoxRect = new Rectangle(Location.X + mCloseBoxRect.X,
									Location.Y + mCloseBoxRect.Y, mCloseBoxRect.Width, mCloseBoxRect.Height);

								if (absCloseBoxRect.Contains(mMousePos))
								{
									Visible = false;
								}
								else
								{
									mMouseMovingHud = true;
									mMouseHudOffset.X = mMousePos.X - mLocation.X;
									mMouseHudOffset.Y = mMousePos.Y - mLocation.Y;
								}
								e.Eat = true;
							}
							break;

						case WM_LBUTTONUP:
							if (mMouseMovingHud)
							{
								mMouseMovingHud = false;
								if (HudMoveComplete != null)
									HudMoveComplete(this, EventArgs.Empty);
								e.Eat = true;
							}
							break;
					}
				}
			}
			catch (Exception ex) { Util.HandleException(ex); }
		}
Пример #18
0
 private void TryConnect(object?sender, WindowMessageEventArgs e) => TryConnect();
Пример #19
0
		void FilterCore_WindowMessage(object sender, WindowMessageEventArgs e)
		{
			try
			{
				fastQuit.FilterCore_WindowMessage(sender, e);
			}
			catch (Exception ex) { Debug.LogException(ex); }
		}
Пример #20
0
		void IManagedHud.WindowMessage(WindowMessageEventArgs e)
		{
			if (WindowMessage != null)
				WindowMessage(this, e);

			// Only process mouse messages when the window is visible
			if (!Visible || e.Msg < WM_MOUSEFIRST || e.Msg > WM_MOUSELAST)
				return;

			Point prevLocation = mMouseLocation;
			bool prevOnWindow = mMouseOnWindow;
			bool prevOnClient = mMouseOnClient;

			mMouseLocation = new Point(e.LParam);
			if (e.Msg == WM_MOUSEWHEEL)
			{
				// WM_MOUSEWHEEL messages are apparently absolute on the screen, 
				// not relative to the AC window; fix with ScreenToClient
				ScreenToClient(Host.Decal.Hwnd, ref mMouseLocation);
			}
			mMouseOnWindow = CalcMouseOnWindow();
			mMouseOnWindow = mMouseOnWindow && Manager.MouseHoveringOnHud(this);
			mMouseOnClient = CalcMouseOnClient();

			// Calculate relative coordinates
			int wX = mMouseLocation.X - mRegion.X;
			int wY = mMouseLocation.Y - mRegion.Y;
			int cX = mMouseLocation.X - mClientRegion.X;
			int cY = mMouseLocation.Y - mClientRegion.Y;

			short fwKeys = (short)(e.WParam & 0xFFFF);
			MouseButtons button = MouseButtons.None;
			if (e.Msg == WM_MOUSEMOVE) { }
			else if (e.Msg == WM_LBUTTONDOWN || e.Msg == WM_LBUTTONUP)
				button = MouseButtons.Left;
			else if (e.Msg == WM_RBUTTONDOWN || e.Msg == WM_RBUTTONUP)
				button = MouseButtons.Right;
			else if (e.Msg == WM_MBUTTONDOWN || e.Msg == WM_MBUTTONUP)
				button = MouseButtons.Middle;


			bool dblClick = false;
			if (e.Msg == WM_LBUTTONDOWN || e.Msg == WM_RBUTTONDOWN || e.Msg == WM_MBUTTONDOWN)
			{
				dblClick = (mMouseLastClickButton == button)
					&& Math.Abs(mMouseLocation.X - mMouseLastClickLocation.X) <= msDblClickRect.Width
					&& Math.Abs(mMouseLocation.Y - mMouseLastClickLocation.Y) <= msDblClickRect.Height
					&& Math.Abs(DateTime.Now.Ticks - mMouseLastClickTicks) <= msDblClickTicks;

				mMouseLastClickTicks = dblClick ? long.MinValue : DateTime.Now.Ticks;
				mMouseLastClickLocation = mMouseLocation;
				mMouseLastClickButton = button;
			}

			#region Handle Moving, Resizing, and Control Button Clicks
			if (e.Msg == WM_MOUSEMOVE)
			{
				// Handle moving the window
				if (IsMoving)
				{
					mRegion.X = mOriginalRegion.X + mMouseLocation.X - mMouseDownLocation.X;
					mRegion.Y = mOriginalRegion.Y + mMouseLocation.Y - mMouseDownLocation.Y;
					mRegion = ConstrainRegion(mRegion);
					mClientRegion = CalculateClientRegion(mRegion);

					// Recalculate whether the mouse is on the window and
					// client, since the regions have changed
					mMouseOnWindow = CalcMouseOnWindow();
					mMouseOnClient = CalcMouseOnClient();

					if (HudsAreCreated)
					{
						mHud.Region = new Rectangle(mRegion.Location, mHud.Region.Size);
					}
					if (Moving != null)
					{
						Moving(this, EventArgs.Empty);
					}
				}
				// Handle resizing the window
				else if (IsResizing)
				{
					if ((mMoveResizeMode & MoveResizeMode.ResizeN) != 0)
					{
						int oldBottom = mRegion.Bottom;
						mRegion.Y = mOriginalRegion.Y + mMouseLocation.Y - mMouseDownLocation.Y;
						mRegion.Height = oldBottom - mRegion.Y;
						if (mRegion.Height < MinHeight)
						{
							mRegion.Y = oldBottom - MinHeight;
							mRegion.Height = MinHeight;
						}
						else if (mRegion.Height > MaxHeight)
						{
							mRegion.Y = oldBottom - MaxHeight;
							mRegion.Height = MaxHeight;
						}
					}
					else if ((mMoveResizeMode & MoveResizeMode.ResizeS) != 0)
					{
						mRegion.Height = mOriginalRegion.Height + mMouseLocation.Y - mMouseDownLocation.Y;
					}

					if ((mMoveResizeMode & MoveResizeMode.ResizeW) != 0)
					{
						int oldRight = mRegion.Right;
						mRegion.X = mOriginalRegion.X + mMouseLocation.X - mMouseDownLocation.X;
						mRegion.Width = oldRight - mRegion.X;
						if (mRegion.Width < MinWidth)
						{
							mRegion.X = oldRight - MinWidth;
							mRegion.Width = MinWidth;
						}
						else if (mRegion.Width > MaxWidth)
						{
							mRegion.X = oldRight - MaxWidth;
							mRegion.Width = MaxWidth;
						}
					}
					else if ((mMoveResizeMode & MoveResizeMode.ResizeE) != 0)
					{
						mRegion.Width = mOriginalRegion.Width + mMouseLocation.X - mMouseDownLocation.X;
					}

					mRegion = ConstrainRegion(mRegion);
					mClientRegion = CalculateClientRegion(mRegion);

					// Recalculate whether the mouse is on the window and
					// client, since the regions have changed
					mMouseOnWindow = CalcMouseOnWindow();
					mMouseOnClient = CalcMouseOnClient();

					if (Resizing != null)
					{
						Resizing(this, EventArgs.Empty);
					}

					RepaintWindow();
					if (ResizeDrawMode == HudResizeDrawMode.Repaint)
						Repaint();
				}

				CalculateHighlightedBorder();

				// Handle the mouse entering/leaving the control boxes
				if (mMouseOnClose || mMouseOnMinRestore || mMouseOnSticky)
				{
					DrawControlBoxes(false);
				}
			} // if (e.Msg == WM_MOUSEMOVE)

			else if (e.Msg == WM_LBUTTONDOWN && mMouseOnWindow)
			{
				// Put this window on top of other windows
				Manager.BringToFront(this, false);

				if (CloseBoxRect.Contains(mMouseLocation))
				{
					mMouseOnClose = true;
					DrawControlBoxes(false);
					e.Eat = true;
				}
				else if (MinRestoreBoxRect.Contains(mMouseLocation))
				{
					mMouseOnMinRestore = true;
					DrawControlBoxes(false);
					e.Eat = true;
				}
				else if (AlphaFadingEnabled && StickyBoxRect.Contains(mMouseLocation))
				{
					mMouseOnSticky = true;
					DrawControlBoxes(false);
					e.Eat = true;
				}
				else if (TitleBarRect.Contains(mMouseLocation))
				{
					if (dblClick)
					{
						Minimized = !Minimized;
					}
					else
					{
						mMoveResizeMode = MoveResizeMode.Moving;
						mMouseDownLocation = mMouseLocation;
						mOriginalRegion = mRegion;
					}
					e.Eat = true;
				}
				else
				{
					mMoveResizeMode = MoveResizeMode.Idle;

					if (!Minimized)
					{
						if (mMouseLocation.X <= mRegion.Left + BorderPaddedWidth)
							mMoveResizeMode |= MoveResizeMode.ResizeW;
						else if (mMouseLocation.X >= mRegion.Right - BorderPaddedWidth)
							mMoveResizeMode |= MoveResizeMode.ResizeE;

						if (mMouseLocation.Y <= mRegion.Top + BorderPaddedWidth)
							mMoveResizeMode |= MoveResizeMode.ResizeN;
						else if (mMouseLocation.Y >= mRegion.Bottom - BorderPaddedWidth)
							mMoveResizeMode |= MoveResizeMode.ResizeS;

						if (mMoveResizeMode != MoveResizeMode.Idle)
						{
							mMouseDownLocation = mMouseLocation;
							mOriginalRegion = mRegion;
							e.Eat = true;
						}
					}
				}
			} // else if (e.Msg == WM_LBUTTONDOWN && mMouseOnWindow)

			else if (e.Msg == WM_LBUTTONUP)
			{
				if (MoveEnd != null && mMoveResizeMode == MoveResizeMode.Moving)
				{
					MoveEnd(this, EventArgs.Empty);
				}
				else if ((mMoveResizeMode & MoveResizeMode.Resizing) != 0)
				{
					if (ResizeEnd != null)
					{
						ResizeEnd(this, EventArgs.Empty);
					}
					// If the ResizeDrawMode is something other than Repaint, 
					// we need to repaint it now that we're done resizing.
					if (ResizeDrawMode != HudResizeDrawMode.Repaint)
					{
						Repaint();
					}
					if (!mMouseOnWindow)
					{
						MouseEvent(MouseLeave, e, mMouseButtons, 0, wX, wY, 0, fwKeys);
					}
				}
				mMoveResizeMode = MoveResizeMode.Idle;

				if (mMouseOnClose || mMouseOnMinRestore || mMouseOnSticky)
				{
					if (mMouseOnClose && CloseBoxRect.Contains(mMouseLocation))
					{
						Visible = false;
					}
					else if (mMouseOnMinRestore && MinRestoreBoxRect.Contains(mMouseLocation))
					{
						Minimized = !Minimized;
					}
					else if (mMouseOnSticky && StickyBoxRect.Contains(mMouseLocation))
					{
						Sticky = !Sticky;
					}
					mMouseOnClose = false;
					mMouseOnMinRestore = false;
					mMouseOnSticky = false;
					DrawControlBoxes(false);
				}
			} // else if (e.Msg == WM_LBUTTONUP)
			#endregion

			#region Generate Mouse Events
			if (mMouseOnWindow)
			{

				switch (e.Msg)
				{
					case WM_MOUSEMOVE:
						MouseEvent(MouseMove, e, mMouseButtons, 0, wX, wY, 0, fwKeys);

						if (mMouseOnClient)
						{
							MouseEvent(ClientMouseMove, e, mClientMouseButtons, 0, cX, cY, 0, fwKeys);
						}
						break;

					case WM_LBUTTONDOWN:
					case WM_RBUTTONDOWN:
					case WM_MBUTTONDOWN:
						mMouseButtons |= button;

						if (dblClick)
						{
							MouseEvent(MouseDoubleClick, e, button, 2, wX, wY, 0, fwKeys);
						}
						else
						{
							MouseEvent(MouseDown, e, button, 1, wX, wY, 0, fwKeys);
						}

						if (mMouseOnClient)
						{
							if (mClientMouseButtons == MouseButtons.None)
							{
								mMouseDownLocation = mMouseLocation;
							}
							mClientMouseButtons |= button;

							if (dblClick)
							{
								MouseEvent(ClientMouseDoubleClick, e, button, 2, cX, cY, 0, fwKeys);
							}
							else
							{
								MouseEvent(ClientMouseDown, e, button, 1, cX, cY, 0, fwKeys);
							}
						}
						break;

					case WM_LBUTTONUP:
					case WM_RBUTTONUP:
					case WM_MBUTTONUP:
						MouseEvent(MouseUp, e, button, 1, wX, wY, 0, fwKeys, false);

						if (mMouseOnClient)
						{
							MouseEvent(ClientMouseUp, e, button, 1, cX, cY, 0, fwKeys, false);
						}
						break;

					case WM_MOUSEWHEEL:
						int zDelta = e.WParam >> 16;
						MouseEvent(MouseWheel, e, button, 0, wX, wY, zDelta, fwKeys);

						if (mMouseOnClient)
						{
							MouseEvent(ClientMouseWheel, e, button, 0, cX, cY, zDelta, fwKeys);
						}
						break;

				} // switch (e.Msg)
			} // if (mMouseOnWindow)

			// Additional WM_MOUSEMOVE messages that don't require the mouse to be on the window
			if (e.Msg == WM_MOUSEMOVE)
			{
				// Alert the client about dragging
				if (ClientMouseDrag != null && mClientMouseButtons != MouseButtons.None)
				{
					int x = mMouseLocation.X - mClientRegion.X;
					int y = mMouseLocation.Y - mClientRegion.Y;
					int dX = mMouseLocation.X - prevLocation.X;
					int dY = mMouseLocation.Y - prevLocation.Y;
					HudMouseDragEventArgs args = new HudMouseDragEventArgs(mClientMouseButtons,
						0, x, y, 0, fwKeys, mMouseDownLocation.X, mMouseDownLocation.Y, dX, dY);
					ClientMouseDrag(this, args);
					if (args.Eat)
						e.Eat = true;
				}

				// Handle mouse entering/leaving the window or client
				// This must be done after moving/resizing

				if (!IsResizing)
				{
					// Mouse enter window
					if (mMouseOnWindow && !prevOnWindow)
					{
						MouseEvent(MouseEnter, e, mMouseButtons, 0, wX, wY, 0, fwKeys);
					}
					// Mouse leave window
					else if (!mMouseOnWindow && prevOnWindow)
					{
						MouseEvent(MouseLeave, e, mMouseButtons, 0, wX, wY, 0, fwKeys);
					}
				}

				// Mouse enter client
				if (mMouseOnClient && !prevOnClient)
				{
					MouseEvent(ClientMouseEnter, e, mClientMouseButtons, 0, cX, cY, 0, fwKeys);
				}
				// Mouse leave client
				else if (!mMouseOnClient && prevOnClient)
				{
					MouseEvent(ClientMouseLeave, e, mClientMouseButtons, 0, cX, cY, 0, fwKeys);
				}
			}
			#endregion

			if (e.Eat && (e.Msg == WM_LBUTTONDOWN || e.Msg == WM_RBUTTONDOWN || e.Msg == WM_MBUTTONDOWN))
			{
				mMouseDownEaten |= button;
			}

			// Update which buttons are on the window and client
			// This must be done after mouse events are generated
			if (e.Msg == WM_LBUTTONUP || e.Msg == WM_RBUTTONUP || e.Msg == WM_MBUTTONUP)
			{
				mMouseButtons &= ~button;
				mClientMouseButtons &= ~button;
				if ((mMouseDownEaten & button) != 0) { e.Eat = true; }
				mMouseDownEaten &= ~button;
			}
		}
Пример #21
0
		private void MouseEvent(EventHandler<HudMouseEventArgs> EventToFire, WindowMessageEventArgs e,
				MouseButtons button, int clicks, int x, int y, int delta, short fwKeys)
		{
			MouseEvent(EventToFire, e, button, clicks, x, y, delta, fwKeys, true);
		}
Пример #22
0
		private void MapHud_WindowMessage(object sender, WindowMessageEventArgs e)
		{
			const short WM_MOUSEMOVE = 0x0200;
			const short WM_LBUTTONDOWN = 0x0201;
			const short WM_LBUTTONUP = 0x0202;
			const short WM_RBUTTONDOWN = 0x0204;
			const short WM_RBUTTONUP = 0x0205;
			const short WM_MBUTTONDOWN = 0x0207;
			const short WM_MBUTTONUP = 0x0208;

			if (mContextMenu != null && (
					e.Msg == WM_LBUTTONDOWN || e.Msg == WM_LBUTTONUP ||
					e.Msg == WM_MBUTTONDOWN || e.Msg == WM_MBUTTONUP ||
					e.Msg == WM_RBUTTONDOWN || e.Msg == WM_RBUTTONUP))
			{
				CloseContextMenu();
			}

			if (e.Msg == WM_MOUSEMOVE && mIsDragging && (ClientMouseButtons & DragButton) == 0)
			{
				mIsDragging = false;
				RepaintAll();
			}
		}
Пример #23
0
		private void MouseEvent(EventHandler<HudMouseEventArgs> EventToFire, WindowMessageEventArgs e,
				MouseButtons button, int clicks, int x, int y, int delta, short fwKeys, bool allowEat)
		{
			if (EventToFire != null)
			{
				HudMouseEventArgs args = new HudMouseEventArgs(button, clicks, x, y, delta, fwKeys);
				EventToFire(this, args);
				if (allowEat && args.Eat)
					e.Eat = true;
			}
		}
 private void WindowMessage(object sender, WindowMessageEventArgs e)
 {
     if (e.Message == NativeMethods.WM_APPCOMMAND)
     {
         int cmd = NativeMethods.GET_APPCOMMAND_LPARAM(e.lParam);
         switch (cmd)
         {
             case NativeMethods.APPCOMMAND_MEDIA_PLAY:
                 ResumeSlideShow();
                 break;
             case NativeMethods.APPCOMMAND_MEDIA_PAUSE:
                 PauseSlideShow();
                 break;
             case NativeMethods.APPCOMMAND_MEDIA_PLAY_PAUSE:
                 PlayPauseSlideShow();
                 break;
         }
     }
 }
Пример #25
0
		public void DispatchWindowMessage(object sender, WindowMessageEventArgs e)
		{
			try
			{
				if (e.Msg >= WM_MOUSEFIRST && e.Msg <= WM_MOUSELAST && !Disposed)
				{
					if (e.Msg == WM_MOUSEMOVE)
					{
						mMousePos = new Point(e.LParam);
					}
					// Don't handle mouse events when the mouse is on the view
					else if (DefaultViewActive &&
						(e.Msg == WM_LBUTTONDOWN || e.Msg == WM_MBUTTONDOWN ||
						 e.Msg == WM_RBUTTONDOWN || e.Msg == WM_MOUSEWHEEL)
						&& DefaultView.Position.Contains(new Point(e.LParam)))
					{
						return;
					}

					// Make a copy of the list in case it is modified while 
					// processing the message (like if one of the mouse event
					// handlers calls BringToFront()).
					UpdateHudsListCopy();
					bool origEat = e.Eat;
					if (!e.Eat)
					{
						foreach (IManagedHud hud in mHudsListCopy)
						{
							// It's possible for the hud to be disposed if a 
							// mouse event handler for another one disposes it.
							if (!hud.Disposed)
							{
								hud.WindowMessage(e);
								if (e.Eat)
									break;
							}
						}

						// Don't let huds eat mouse moves
						if (e.Eat != origEat && e.Msg == WM_MOUSEMOVE)
						{
							e.Eat = origEat;
						}
					}
				}
			}
			catch (Exception ex) { HandleException(ex); }
		}
 private void OnClipboardUpdate(object?sender, WindowMessageEventArgs e) =>
 ClipboardUpdate?.Invoke(this, EventArgs.Empty);