public void TestAddCommandWithDuplicateIdThrows( ) { Command cmd = new Command( "cmd0", "", "" ); CommandRegistry registry = new CommandRegistry( ); registry.Register( cmd ); registry.Register( cmd ); }
static SphereCameraController( ) { Commands = new CommandGroup( "sphereCameraCommands", "Spherical Camera Commands", CommandRegistry.Instance ); Rotate = Commands.NewCommand( "rotate", "Rotate", "Rotates the camera" ); Pan = Commands.NewCommand( "pan", "Pan", "Pans the camera" ); Zoom = Commands.NewCommand( "zoom", "Zoom", "Zooms the camera in and out" ); }
public void TestFindCommand( ) { Command cmd = new Command( "cmd0", "", "" ); CommandRegistry registry = new CommandRegistry( ); registry.Register( cmd ); Assert.AreEqual( cmd, registry.FindById( cmd.Id ) ); }
/// <summary> /// Checks if a command already exists /// </summary> private void CheckCommandIdDoesNotExist( Command cmd ) { Command existingCmd; if ( m_Commands.TryGetValue( cmd.Id, out existingCmd ) ) { throw new ArgumentException( string.Format( "Command \"{0}\" has the same ID as command \"{1}\" - change name or description in either", cmd.NameId, existingCmd.NameId ), "cmd" ); } }
static TrackingCameraCommands( ) { Commands = new CommandGroup( "trackingCamera", "Tracking Camera Commands", CommandRegistry.Instance ); Zoom = Commands.NewCommand( "zoom", "Zoom", "Zooms the camera in and out" ); ZoomIn = Commands.NewCommand( "zoomIn", "Zoom In", "Zooms the camera in" ); ZoomOut = Commands.NewCommand( "zoomOut", "Zoom Out", "Zooms the camera out" ); Pan = Commands.NewCommand( "pan", "Pan", "Pans the camera" ); Rotate = Commands.NewCommand( "rotate", "Rotate", "Rotates the camera" ); }
/// <summary> /// Initializes test data /// </summary> public TestCommandTriggerDataSerialization( ) { m_Formatter = new BinaryFormatter( null, CommandSerializationContext.ToStreamingContext( m_UserRegistry, m_CommandRegistry ) ); m_Commands = new CommandGroup( "testCommands", "", m_CommandRegistry ); m_Command0 = m_Commands.NewCommand( "cmd0", "", "" ); m_UserRegistry.Register( m_User ); }
/// <summary> /// Registers a command /// </summary> /// <param name="cmd">Command to register</param> public void Register( Command cmd ) { Arguments.CheckNotNull( cmd, "cmd" ); InteractionLog.Info( "Registering command \"{0}\" ({1})", cmd.NameId, cmd.Id ); CheckCommandIdDoesNotExist( cmd ); m_Commands[ cmd.Id ] = cmd; }
/// <summary> /// Deserialization constructor /// </summary> public CommandTriggerData( SerializationInfo info, StreamingContext context ) { CommandSerializationContext commandContext = context.Context as CommandSerializationContext; if ( commandContext == null ) { throw new System.IO.IOException( "CommandTriggerData must be deserialized with a CommandSerializationContext present" ); } m_User = commandContext.Users.FindById( ( int )info.GetValue( "u", typeof( int ) ) ); m_Command = commandContext.Commands.FindById( ( int )info.GetValue( "c", typeof( int ) ) ); m_InputState = ( ICommandInputState )info.GetValue( "s", typeof( ICommandInputState ) ); }
/// <summary> /// Executes a command /// </summary> /// <param name="command">Command to execute</param> /// <param name="parameters">Command parameters</param> public void Execute( Command command, CommandParameters parameters ) { m_Log.InfoFormat( "Executing command \"{0}\"", command ); foreach ( ICommandExecutor executor in m_CommandExecutors.Executors ) { if ( executor.Execute( this, command, parameters ) == CommandExecutionResult.StopExecutingCommand ) { m_Log.InfoFormat( "Executing of command \"{0}\" was stopped by executor \"{1}\"", command, executor ); return; } } }
static FirstPersonCameraCommands( ) { Commands = new CommandGroup( "fpCamCommands", "First Person Camera Commands", CommandRegistry.Instance ); Forwards = Commands.NewCommand( "forwards", "Forwards", "Moves forwards" ); Backwards = Commands.NewCommand( "backwards", "Backwards", "Moves backwards" ); PitchUp = Commands.NewCommand( "pitchUp", "Pitch up", "Pitches the camera up" ); PitchDown = Commands.NewCommand( "pitchDown", "Pitch down", "Pitches the camera down" ); RollClockwise = Commands.NewCommand( "rollClockwise", "Roll clockwise", "Rolls the camera clockwise" ); RollAnticlockwise = Commands.NewCommand( "rollAnticlockwise", "Roll anticlockwise", "Rolls the camera anti-clockwise" ); ; YawLeft = Commands.NewCommand( "yawLeft", "Yaw left", "Yaws the camera left" ); YawRight = Commands.NewCommand( "yawRight", "Yaw right", "Yaws the camera right" ); SlipLeft = Commands.NewCommand( "slipLeft", "Slip left", "Slips the camera left" ); SlipRight = Commands.NewCommand( "slipRight", "Slip right", "Slips the camera right" ); Turn = Commands.NewCommand( "turn", "Turn", "Turns the camera" ); }
/// <summary> /// Setup constructor with explicit show command /// </summary> public DockingViewInfo( string name, CreateViewDelegate createView, Command showCommand ) : this(name, createView, showCommand, DockState.Float) { }
/// <summary> /// Creates a <see cref="WorkspaceCommandTriggerData"/> object /// </summary> public CommandTriggerData Create( ICommandUser user, Command command, ICommandInputState inputState ) { return new WorkspaceCommandTriggerData( m_Workspace, user, command, inputState ); }
/// <summary> /// Setup constructor /// </summary> /// <param name="workspace">Workspace that the command was triggered in</param> /// <param name="user">User that triggered the command</param> /// <param name="command">Command that was triggered</param> /// <param name="inputState">Command input state</param> public WorkspaceCommandTriggerData( IWorkspace workspace, ICommandUser user, Command command, ICommandInputState inputState ) : base(user, command, inputState) { Arguments.CheckNotNull( workspace, "workspace" ); m_Workspace = workspace; }
/// <summary> /// Creates a CommandTriggerData object /// </summary> public CommandTriggerData Create( ICommandUser user, Command command, ICommandInputState inputState ) { return new CommandTriggerData( user, command, inputState ); }
/// <summary> /// Returns true if a specified command's monitor is active for any user /// </summary> public bool IsCommandTriggered( Command cmd ) { return IsCommandActive( cmd, m_AllMonitors ); }
/// <summary> /// Returns true if a specified command's monitor is active for a specified user /// </summary> public bool IsCommandTriggered( Command cmd, ICommandUser user ) { return IsCommandActive( cmd, GetSafeMonitorList( user ) ); }
/// <summary> /// Sets the command to bind /// </summary> /// <param name="command">Command to bind</param> public CommandInputBinding( Command command ) { m_Command = command; }
/// <summary> /// /// </summary> /// <param name="command"></param> /// <returns></returns> public Command AddCommand( Command command ) { Arguments.CheckNotNull( command, "command" ); if ( m_Commands.Contains( command ) ) { throw new ArgumentException( string.Format( "Command \"{0}\" already exists in group \"{1}\"", command.NameId, NameId ) ); } m_Commands.Add( command ); command.Group = this; m_Registry.Register( command ); return command; }
/// <summary> /// Setup constructor /// </summary> /// <param name="command">Command</param> /// <param name="text">Menu item text. Use an amperand to designate the hot-key.</param> /// <param name="ordinal">Ordinal value for this item</param> public MenuItemInfo( Command command, string text, int ordinal ) : this(text.Replace( "&", "" ), command, text, ordinal) { }
/// <summary> /// Setup constructor. Menu text is the command name, prefixed with '&' /// </summary> /// <param name="command">Command</param> /// <param name="ordinal">Ordinal value for this item</param> public MenuItemInfo( Command command, int ordinal ) : this(command, command.NameUi, ordinal) { }
/// <summary> /// Setup constructor /// </summary> /// <param name="user">User that triggered the command</param> /// <param name="command">Command that was triggered</param> /// <param name="inputState">Command input state</param> public CommandTriggerData( ICommandUser user, Command command, ICommandInputState inputState ) { m_User = user; m_Command = command; m_InputState = inputState; }
/// <summary> /// Setup constructor with explicit dock state and show command /// </summary> public DockingViewInfo( string name, CreateViewDelegate createView, Command showCommand, DockState defaultDockState ) : base(name, createView, showCommand) { m_DefaultDockState = defaultDockState; }
private static bool IsCommandActive( Command cmd, IEnumerable<ICommandInputBindingMonitor> monitors ) { foreach ( ICommandInputBindingMonitor monitor in monitors ) { if ( ( monitor.Binding.Command == cmd ) && ( monitor.IsActive ) ) { return true; } } return false; }
/// <summary> /// Setup constructor /// </summary> /// <param name="name">Menu item name</param> /// <param name="command">Command triggered by the menu item.</param> /// <param name="text">Menu item text. Use an amperand to designate the hot-key.</param> /// <param name="ordinal">Ordinal value for this item</param> public MenuItemInfo( string name, Command command, string text, int ordinal ) : base(name, text, ordinal) { Arguments.CheckNotNull( command, "command" ); m_Command = command; }
/// <summary> /// Setup constructor with show command /// </summary> public HostedViewInfo( string name, CreateViewDelegate createView, Command showCommand ) : base(name, createView, showCommand) { }