public override bool ProcessIntent(ControlIntent intent, object data) { this.IsPressed = false; bool handled = false; switch (intent) { case ControlIntent.Released: if (ScreenSpace.Contains((Vector2)data)) { PrimaryAction(); handled = true; } break; case ControlIntent.AltReleased: if (ScreenSpace.Contains((Vector2)data)) { SecondaryAction(); handled = true; } break; case ControlIntent.Held: goto case ControlIntent.AltHeld; case ControlIntent.AltHeld: if(ScreenSpace.Contains((Vector2)data)) this.IsPressed = true; break; default: handled = base.ProcessIntent(intent, data); break; } return handled; }
public async Task SendIntentAsync(ControlIntent intent) { switch (intent) { case ControlIntent.Home: case ControlIntent.Back: case ControlIntent.Up: case ControlIntent.Down: case ControlIntent.Left: case ControlIntent.Right: case ControlIntent.Red: case ControlIntent.Blue: case ControlIntent.Yellow: case ControlIntent.Green: await _client.SendButtonAsync((ButtonTypes)Enum.Parse(typeof(ButtonTypes), intent.ToString())); break; case ControlIntent.FastForward: await _client.SendCommandAsync <ControlFastForwardResponse>(new ControlFastForwardCommand()); break; case ControlIntent.Pause: await _client.SendCommandAsync <ControlPauseResponse>(new ControlPauseCommand()); break; case ControlIntent.Play: await _client.SendCommandAsync <ControlPlayResponse>(new ControlPlayCommand()); break; case ControlIntent.Rewind: await _client.SendCommandAsync <ControlRewindResponse>(new ControlRewindCommand()); break; case ControlIntent.Stop: await _client.SendCommandAsync <ControlStopResponse>(new ControlStopCommand()); break; case ControlIntent.PowerOff: await _client.SendCommandAsync <PowerOffResponse>(new PowerOffCommand()); break; } }
public override bool ProcessIntent(ControlIntent intent, object data) { Debug.Assert(HasParent, "A titlebar should always have a parent control!"); bool handled = false; switch (intent) { case ControlIntent.Released: goto default; // See if the close button is interested case ControlIntent.Held: if (_closeButton.ScreenSpace.Contains((Vector2)data)) goto default; else if (ScreenSpace.Contains((Vector2)data)) State = ControlState.Moving; handled = true; break; case ControlIntent.Move: if (State == ControlState.Moving) { Vector2 newPosition = Parent.Position + (Vector2)data; DrawingPoint mouseCorrection = new DrawingPoint(); if (newPosition.X > GameApplication.ScreenSize.Width - Parent.Width) { mouseCorrection.X = (int)((GameApplication.ScreenSize.Width - Parent.Width) - newPosition.X); newPosition.X = GameApplication.ScreenSize.Width - Parent.Width; } else if (newPosition.X < 0) { mouseCorrection.X = (int)-newPosition.X; newPosition.X = 0; } if (newPosition.Y > GameApplication.ScreenSize.Height - Parent.Height) { mouseCorrection.Y = (int)((GameApplication.ScreenSize.Height - Parent.Height) - newPosition.Y); newPosition.Y = GameApplication.ScreenSize.Height - Parent.Height; } else if (newPosition.Y < 0) { mouseCorrection.Y = (int)-newPosition.Y; newPosition.Y = 0; } Cursor.Position = new System.Drawing.Point( Cursor.Position.X + mouseCorrection.X, Cursor.Position.Y + mouseCorrection.Y); Parent.Position = Parent.Position + (Vector2)data; handled = true; } break; default: handled = base.ProcessIntent(intent, data); break; } return handled; }
public abstract bool ProcessIntent(ControlIntent intent, object data);
public override bool ProcessIntent(ControlIntent intent, object data) { bool handled = false; try { for (int i = 0, j = _controls.Count; !handled && i < j; i++) handled = _controls[i].ProcessIntent(intent, data); } catch (IndexOutOfRangeException) { Console.Error.WriteLine("Control list changed while processing intent, discarding"); } return handled; }
public override bool ProcessIntent(ControlIntent intent, object data) { return false; }
public bool ProcessIntent(ControlIntent intent, object data) { return _content.ProcessIntent(intent, data); }