/// <summary> /// Uninitialize the scan engine /// </summary> protected override void ProcessRecord() { using (new AppDomainAdjuster()) { WriteObject(StopCommand.Execute()); } }
public MidiPlayerViewModel(FileHandler fileHandler) { // De OutputDevice is een midi device of het midikanaal van je PC. // Hierop gaan we audio streamen. // DeviceID 0 is je audio van je PC zelf. _outputDevice = new OutputDevice(0); _sequencer = new Sequencer(); // Wanneer een channelmessage langskomt sturen we deze direct door naar onze audio. // Channelmessages zijn tonen met commands als NoteOn en NoteOff // In midi wordt elke noot gespeeld totdat NoteOff is benoemd. Wanneer dus nooit een NoteOff komt nadat die een NoteOn heeft gehad // zal deze note dus oneindig lang blijven spelen. _sequencer.ChannelMessagePlayed += ChannelMessagePlayed; // Wanneer de sequence klaar is moeten we alles closen en stoppen. _sequencer.PlayingCompleted += (playingSender, playingEvent) => { _sequencer.Stop(); _running = false; }; _fileHandler = fileHandler; _fileHandler.MidiSequenceChanged += (src, args) => { StopCommand.Execute(null); _sequencer.Sequence = args.MidiSequence; UpdateButtons(); }; }
private void UpdatePiece(Piece piece) { StopCommand.Execute(null); _sequencer.Sequence = new MidiConverter(false).Convert(piece); UpdateButtons(); }
public void Execute_InitiallyStoped_SericeIsStopped() { //Ensure the service is stopped var service = new ServiceController(SERVICE_NAME); var timeout = TimeSpan.FromMilliseconds(5000); if (service.Status != ServiceControllerStatus.Stopped) { service.Stop(); } service.WaitForStatus(ServiceControllerStatus.Stopped, timeout); //Mock the args and setup command var args = Mock.Of <IStopCommandArgs>( stop => stop.ServiceName == new LiteralScalarResolver <string>(SERVICE_NAME) && stop.TimeOut == new LiteralScalarResolver <int>("5000") ); var command = new StopCommand(args); //Apply the test command.Execute(); //Assert service.Refresh(); Assert.That(service.Status, Is.EqualTo(ServiceControllerStatus.Stopped)); }
private void StopButton_Click(object sender, RoutedEventArgs e) { Stop(); if (StopCommand != null && StopCommand.CanExecute(EMPTY_PARAMETER)) { StopCommand.Execute(EMPTY_PARAMETER); } }
static void Main(string[] args) { var arguments = ParseCommandLine(args); var loader = new AssemblyLoader(); var dbProvider = loader.CreateTypeFromAssembly <DbProvider>(arguments["dbp.provider"], arguments); var dbCodeFormatter = loader.CreateTypeFromAssembly <DbTraceCodeFormatter>(arguments["tcf.provider"], arguments); var codeHighlighter = loader.CreateTypeFromAssembly <HighlightCodeProvider>(arguments["hcp.provider"], arguments); var outputProvider = loader.CreateTypeFromAssembly <OutputProvider>(arguments["out.provider"], arguments); var command = arguments["app.command"].ToLower().Trim(); // Get trace name from provided, last trace, or generate one. string traceName = null; if (arguments.ContainsKey("app.traceName")) { traceName = arguments["app.traceName"]; } if (traceName == null && command != "start") { traceName = dbProvider.GetLastTraceName(); } else if (traceName == null && command == "start") { traceName = DateTime.Now.ToString("yyyyMMddHHmmss"); } // Get the specific database object name to run against, if specified (mainly used for testing). if (arguments.ContainsKey("test.objectname")) { var objectName = arguments["test.objectname"]; dbProvider.SetSpecificObjectNameForTesting(objectName); } switch (command) { case "generate": var generateCommand = new GenerateOutputCommand(dbProvider, dbCodeFormatter, codeHighlighter, outputProvider, traceName); generateCommand.Execute(); break; case "start": var startCommand = new StartCommand(outputProvider, dbProvider, traceName); startCommand.Execute(); break; case "stop": var stopCommand = new StopCommand(dbProvider, outputProvider, traceName); stopCommand.Execute(); break; case "finish": new GenerateOutputCommand(dbProvider, dbCodeFormatter, codeHighlighter, outputProvider, traceName).Execute(); new StopCommand(dbProvider, outputProvider, traceName).Execute(); break; } }
public async Task <IActionResult> Pause() { var user = await this._userManager.FindByNameAsync(this.User.Identity.Name); var stopCmd = new StopCommand(this._serviceProvider, user.ChatId); await stopCmd.Execute(); return(RedirectToAction("List")); }
private void StopTimer() { Timer.Stop(); Stopped?.Invoke(this, EventArgs.Empty); if (StopCommand?.CanExecute(StopCommandParameter) == true) { StopCommand?.Execute(StopCommandParameter); } }
/// <summary> /// Stops this instance. /// </summary> public void Stop() { if (StopCommand?.CanExecute(null) == true) { StopCommand?.Execute(null); MediaState = MediaState.Stopped; OnMediaStateChanged(); } }
public void HoverCommand_ShouldExecuteClientStop() { // arrange stopCommand = new StopCommand(DroneClientMock.Object); // act stopCommand.Execute(); // assert DroneClientMock.Verify(x => x.Stop(), Times.Once); }
private void OnReleased(object sender, EventArgs e) { if (StopCommand == null) { return; } if (StopCommand.CanExecute(BindingContext)) { StopCommand.Execute(BindingContext); } }
static void Main(string[] args) { var arguments = ParseCommandLine(args); RequiredAttributes(arguments, "databaseProvider", "codeFormatProvider", "codeHighlightProvider", "outputProvider", "action" ); var loader = new AssemblyLoader(); var dbProvider = loader.CreateTypeFromAssembly <DbProvider>(arguments["databaseProvider"], arguments); var dbCodeFormatter = loader.CreateTypeFromAssembly <DbTraceCodeFormatter>(arguments["codeFormatProvider"], arguments); var codeHighlighter = loader.CreateTypeFromAssembly <HighlightCodeProvider>(arguments["codeHighlightProvider"], arguments); var outputProvider = loader.CreateTypeFromAssembly <OutputProvider>(arguments["outputProvider"], arguments); var command = arguments["action"].ToLower().Trim(); var traceName = arguments.ContainsKey("traceFileName") ? arguments["traceFileName"] : null; switch (command) { case "generate": RequiredAttributes(arguments, "traceFileName" ); var generateCommand = new GenerateOutputCommand(dbProvider, dbCodeFormatter, codeHighlighter, outputProvider, traceName); generateCommand.Execute(); break; case "execute": RequiredAttributes(arguments, "target" ); traceName = traceName ?? DateTime.Now.ToString("yyyyMMddHHmmss"); var startCommand = new StartCommand(outputProvider, dbProvider, traceName); startCommand.Execute(); var executeCommand = new ExecuteCommand(arguments["target"], arguments.ContainsKey("targetArgs") ? arguments["targetArgs"] : string.Empty); executeCommand.Execute(); var stopCommand = new StopCommand(dbProvider, outputProvider, traceName); stopCommand.Execute(); break; } }
public async Task Execute() { var log = A.Fake <ILogger>(); var radio = A.Fake <IRadio>(); var command = new StopCommand(log, radio); var result = await command.Execute(new string[0]); A.CallTo(() => radio.Stop()).MustHaveHappened(); Assert.Equal(CommandResult.Exit, result); }
public static void TearDown() { if (session == null) { return; } session.Close(); session.Quit(); session = null; StopCommand.Execute(); }
private void Timer_Elapsed(object sender, ElapsedEventArgs e) { var idleTime = IdleTimeFinder.GetIdleTime(); if (idleTime > Settings.Default.IdleTimeInMinutes * 60 * 1000 && Status == ProcessStatus.Running) { StopCommand.Execute(null); if (Status == ProcessStatus.Stopped) { var result = MessageBox.Show("The StopScript was executed as ilde time was detected! Do you want to run StartScript?", "Idle time - script executed!", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { StartCommand.Execute(null); } } } }
public void Execute_ClearInstanceSucceeds_ReturnsSuccessfulResult() { using (ShimsContext.Create()) { int callsToClearInstance = 0; ShimAutomationSession.ClearInstance = () => { callsToClearInstance++; }; StopCommandResult result = StopCommand.Execute(); Assert.AreEqual(1, callsToClearInstance); Assert.AreEqual(true, result.Completed); Assert.AreEqual(true, result.Succeeded); Assert.IsFalse(string.IsNullOrWhiteSpace(result.SummaryMessage)); } }
public MidiPlayerViewModel() { // De OutputDevice is een midi device of het midikanaal van je PC. // Hierop gaan we audio streamen. // DeviceID 0 is je audio van je PC zelf. _outputDevice = new OutputDevice(0); _sequencer = new Sequencer(); // Wanneer een channelmessage langskomt sturen we deze direct door naar onze audio. // Channelmessages zijn tonen met commands als NoteOn en NoteOff // In midi wordt elke noot gespeeld totdat NoteOff is benoemd. Wanneer dus nooit een NoteOff komt nadat die een NoteOn heeft gehad // zal deze note dus oneindig lang blijven spelen. _sequencer.ChannelMessagePlayed += ChannelMessagePlayed; // Wanneer de sequence klaar is moeten we alles closen en stoppen. _sequencer.PlayingCompleted += (playingSender, playingEvent) => StopCommand.Execute(null); _pieceChangedSubscriptionToken = EventBus.Subscribe(new Action <PieceChangedEvent>(PieceChangedEventHandler)); _pieceLoadedSubscriptionToken = EventBus.Subscribe(new Action <PieceLoadedEvent>(PieceLoadedEventHandler)); }
private void CreateNewPlayground() { Generation = 0; StopCommand.Execute(null); ClearCommand.Execute(null); NewPlaygroundDialog dialog = new NewPlaygroundDialog(); if (dialog.ShowDialog() == true) { int SizeX = dialog.SizeX; int SizeY = dialog.SizeY; CellSize = dialog.CellSize; playground = new Playground(SizeX, SizeY); PlaygroundChanged?.Invoke(playground, CellSize); SoftwareName = string.Format("Conway's Game of Life: Neu {0}x{1}", playground.SizeX, playground.SizeY, filename); } }
public ProxyViewModel(IMainViewModel window = null, IProxyService proxy = null, IInteractionService interactions = null) { this.window = window ?? Locator.Current.GetService <IMainViewModel>(); this.proxy = proxy ?? Locator.Current.GetService <IProxyService>(); this.interactions = interactions ?? Locator.Current.GetService <IInteractionService>(); this.WhenActivated(disposables => { StartCommand = ReactiveCommand.Create(() => { this.proxy.Start(); IsStarted = true; }, this.WhenAnyValue(vm => vm.IsStarted, v => !v)) .DisposeWith(disposables); StopCommand = ReactiveCommand.Create(() => { this.proxy.Stop(); IsStarted = false; }, this.WhenAnyValue(vm => vm.IsStarted)) .DisposeWith(disposables); this .interactions .WindowClosing .RegisterHandler(async intertaction => { if (await StopCommand.CanExecute.FirstAsync()) { await StopCommand.Execute(Unit.Default); } intertaction.SetOutput(Unit.Default); }) .DisposeWith(disposables); }); }
public void Execute_ClearInstanceThrowsAutomationException_ReturnsFailedResult() { const string exceptionMessage = "Hello from your local exception!"; using (ShimsContext.Create()) { int callsToClearInstance = 0; ShimAutomationSession.ClearInstance = () => { callsToClearInstance++; throw new A11yAutomationException(exceptionMessage); }; StopCommandResult result = StopCommand.Execute(); Assert.AreEqual(1, callsToClearInstance); Assert.AreEqual(false, result.Completed); Assert.AreEqual(false, result.Succeeded); Assert.AreEqual(exceptionMessage, result.SummaryMessage); } }
private void DeleteTorrent(object arg) { if (SelectedWrapper != null) { var deleteAction = new Action(async() => { _engine.Unregister(SelectedWrapper.Manager); var torrentHashString = SelectedWrapper.Manager.InfoHash.ToString(); var searchResult = await _unitOfWork.GetRepository <TorrentInfo>().GetSingleOrDefaultAsync(torrentInfo => torrentInfo.InfoHash == torrentHashString); _unitOfWork.GetRepository <TorrentInfo>().Delete(searchResult); await _unitOfWork.SaveChangesAsync(); SelectedWrapper.Manager.Dispose(); SelectedWrapper.DeleteFastResume(); File.Delete(SelectedWrapper.Torrent.TorrentPath); TorrentsList.Remove(SelectedWrapper); }); SelectedWrapper.PretendToDelete = true; if (SelectedWrapper.State == TorrentState.Stopped) { _dispatcher.Invoke(deleteAction); } else { StopCommand.Execute(null); SelectedWrapper.Manager.TorrentStateChanged += delegate(object sender, TorrentStateChangedEventArgs args) { if (args.NewState == TorrentState.Stopped && SelectedWrapper.PretendToDelete) { _dispatcher.Invoke(deleteAction); } }; } } }
private void Update() { if (!_isPaused) { if (Input.GetKey(KeyCode.LeftArrow)) { var command = new MoveLeftCommand(rb, _playerSpeed, commandLagTime); command.Execute(); CommandManager.Instance.AddCommand(command); commandLagTime = 0; } if (Input.GetKeyUp(KeyCode.LeftArrow)) { var command = new StopCommand(rb, commandLagTime); command.Execute(); CommandManager.Instance.AddCommand(command); commandLagTime = 0; } if (Input.GetKey(KeyCode.RightArrow)) { var command = new MoveRightCommand(rb, _playerSpeed, commandLagTime); command.Execute(); CommandManager.Instance.AddCommand(command); commandLagTime = 0; } if (Input.GetKeyUp(KeyCode.RightArrow)) { var command = new StopCommand(rb, commandLagTime); command.Execute(); CommandManager.Instance.AddCommand(command); commandLagTime = 0; } commandLagTime += Time.deltaTime; } }
/// <summary> /// This entry point does not ship, but it makes for a quick and easy way to debug through the /// automation code. One caveat--we intentionally don't build symbols for this app, so while you /// can use it to to debug the automation code, breakpoints set in this class will be ignored. /// </summary> static void Main(string[] args) { Dictionary <string, string> parameters = new Dictionary <string, string>(); string secondaryConfigFile = string.Empty; char[] delimiters = { '=' }; foreach (string arg in args) { string[] pieces = arg.Split(delimiters); if (pieces.Length == 2) { string key = pieces[0].Trim(); string value = pieces[1].Trim(); if (!string.IsNullOrWhiteSpace(key) && !string.IsNullOrWhiteSpace(value)) { // Special case for SecondaryConfigFile if (key.Equals("SecondaryConfigFile", StringComparison.OrdinalIgnoreCase)) { secondaryConfigFile = value; } else { parameters[key] = value; } continue; } } Console.WriteLine("Ignoring malformed input: {0}", arg); } ; Console.WriteLine(StartCommand.Execute(parameters, secondaryConfigFile).ToString()); int autoFileId = 0; while (true) { Console.Write("Enter process ID to capture (blank to exit): "); string input = Console.ReadLine(); if (string.IsNullOrEmpty(input)) { break; } if (!int.TryParse(input, out int processId)) { Console.WriteLine("Not a valid int: " + input); continue; } Dictionary <string, string> snapshotParameters = new Dictionary <string, string> { { CommandConstStrings.TargetProcessId, input }, { CommandConstStrings.OutputFile, autoFileId++.ToString(CultureInfo.InvariantCulture) }, }; Console.WriteLine(SnapshotCommand.Execute(snapshotParameters).ToString()); } Console.WriteLine(StopCommand.Execute().ToString()); }
public void Update() { var keyArray = new Keys[25] { Keys.W, Keys.Up, Keys.A, Keys.Left, Keys.S, Keys.Down, Keys.D, Keys.Right, Keys.Z, Keys.N, Keys.E, Keys.NumPad1, Keys.D1, Keys.NumPad2, Keys.D2, Keys.NumPad3, Keys.D3, Keys.Y, Keys.T, Keys.U, Keys.I, Keys.Q, Keys.R, Keys.O, Keys.P }; var OnceKeyArray = new Keys[15] { Keys.E, Keys.NumPad1, Keys.D1, Keys.NumPad2, Keys.D2, Keys.NumPad3, Keys.D3, Keys.Y, Keys.T, Keys.U, Keys.I, Keys.Q, Keys.R, Keys.O, Keys.P }; var AttackArray = new Keys[2] { Keys.Z, Keys.N }; previousKeyState = currentKeyState; currentKeyState = Keyboard.GetState(); if (OnceKeyArray.Contains <Keys>(lastPressedKey)) { ICommand command = new StopCommand(this.instance.Link); command.Execute(); } else if (AttackArray.Contains <Keys>(lastPressedKey)) { } else if (keyArray.Contains <Keys>(lastPressedKey) && (!currentKeyState.IsKeyDown(lastPressedKey))) { ICommand command = new StopCommand(this.instance.Link); command.Execute(); } foreach (Keys key in keyArray) { //if the keys in the keyArray are pressed, execute corresponding command if (OnceKeyArray.Contains <Keys>(key)) { if (currentKeyState.IsKeyDown(key) && !previousKeyState.IsKeyDown(key)) { controllerMappings[key]?.Execute(); lastPressedKey = key; } } else if (AttackArray.Contains <Keys>(key)) { if (currentKeyState.IsKeyDown(key) && !previousKeyState.IsKeyDown(key)) { controllerMappings[key]?.Execute(); lastPressedKey = key; } } else if (keyArray.Contains <Keys>(key)) { if (currentKeyState.IsKeyDown(key)) { if ((lastPressedKey == key) || ((lastPressedKey != key) && currentKeyState.IsKeyUp(lastPressedKey))) { controllerMappings[key]?.Execute(); lastPressedKey = key; } } } } }
public void Update() { var buttonarray = new Buttons[14] { Buttons.A, Buttons.B, Buttons.Y, Buttons.X, Buttons.DPadUp, Buttons.DPadLeft, Buttons.DPadDown, Buttons.DPadRight, Buttons.Back, Buttons.Start, Buttons.LeftShoulder, Buttons.RightShoulder, Buttons.LeftTrigger, Buttons.RightTrigger }; var attackarray = new Buttons[] { Buttons.A }; var oncearray = new Buttons[] { Buttons.B, Buttons.Y, Buttons.X, Buttons.DPadUp, Buttons.DPadLeft, Buttons.DPadDown, Buttons.DPadRight, Buttons.Back, Buttons.Start, Buttons.LeftShoulder, Buttons.RightShoulder, Buttons.LeftTrigger, Buttons.RightTrigger }; previousState = currentState; currentState = GamePad.GetState(Microsoft.Xna.Framework.PlayerIndex.One); if (oncearray.Contains <Buttons>(lastButtonPressed)) { ICommand command = new StopCommand(this.instance.Link); command.Execute(); } else if (attackarray.Contains <Buttons>(lastButtonPressed)) { } else if (buttonarray.Contains <Buttons>(lastButtonPressed) && (!currentState.IsButtonDown(lastButtonPressed))) { ICommand command = new StopCommand(this.instance.Link); command.Execute(); } foreach (Buttons button in buttonarray) { //if the keys in the keyArray are pressed, execute corresponding command if (oncearray.Contains <Buttons>(button)) { if (currentState.IsButtonDown(button) && !previousState.IsButtonDown(button)) { gamepadMappings[button]?.Execute(); lastButtonPressed = button; } } else if (attackarray.Contains <Buttons>(button)) { if (currentState.IsButtonDown(button) && !previousState.IsButtonDown(button)) { gamepadMappings[button]?.Execute(); lastButtonPressed = button; } } else if (buttonarray.Contains <Buttons>(button)) { if (currentState.IsButtonDown(button)) { if ((lastButtonPressed == button) || ((lastButtonPressed != button) && currentState.IsButtonUp(lastButtonPressed))) { gamepadMappings[button]?.Execute(); lastButtonPressed = button; } } } } }