コード例 #1
0
ファイル: CamView.cs プロジェクト: Scottyaim/duality
		private bool FocusHookFilter(InputEventMessageRedirector.MessageType type, EventArgs e)
		{
			// Don't capture when the sandbox is active. Input is likely to be needed in the current Game View.
			if (Sandbox.State == SandboxState.Playing) return false;

			// Capture mouse wheel for camera navigation
			if (type == InputEventMessageRedirector.MessageType.MouseWheel)
			{
				return true;
			}
			// Capture space key for alternative camera navigation
			else if (type == InputEventMessageRedirector.MessageType.KeyDown)
			{
				KeyEventArgs keyArgs = e as KeyEventArgs;
				if (keyArgs == null) return false;
				if (keyArgs.KeyCode == Keys.Space)
				{
					// Only capture the space key when we had recent movement and no other input keys.
					// The user might be typing something with the mouse cursor accidentally hovering here.
					if ((DateTime.Now - this.globalInputLastOtherKey).TotalMilliseconds > 1000 &&
						(DateTime.Now - this.lastLocalMouseMove).TotalMilliseconds < 1000)
					{
						return true;
					}
				}
				else
				{
					this.globalInputLastOtherKey = DateTime.Now;
				}
			}
			
			return false;
		}
コード例 #2
0
ファイル: CamView.cs プロジェクト: Scottyaim/duality
		private void InstallFocusHook()
		{
			if (this.graphicsControl.Control.Focused) return;

			// Hook global message filter
			if (this.globalInputFilter == null)
			{
				this.globalInputFilter = new InputEventMessageRedirector(
					this.graphicsControl.Control, 
					this.FocusHookFilter, 
					InputEventMessageRedirector.MessageType.MouseWheel,
					InputEventMessageRedirector.MessageType.KeyDown);
				Application.AddMessageFilter(this.globalInputFilter);
			}
		}
コード例 #3
0
ファイル: CamView.cs プロジェクト: Scottyaim/duality
		private void RemoveFocusHook()
		{
			// Remove global message filter
			if (this.globalInputFilter != null)
			{
				Application.RemoveMessageFilter(this.globalInputFilter);
				this.globalInputFilter = null;
			}
		}
コード例 #4
0
ファイル: CamView.cs プロジェクト: arajar/duality
		private bool FocusHookFilter(InputEventMessageRedirector.MessageType type, EventArgs e)
		{
			// Capture the mouse wheel - except in sandbox mode. Input is likely to be needed in the current Game View
			return Sandbox.State != SandboxState.Playing;
		}