private void RefreshCommandExecuteStatus() { ConnectCommand.RaiseCanExecuteChanged(); ClearAlarmCommand.RaiseCanExecuteChanged(); SendGCodeFileCommand.RaiseCanExecuteChanged(); StartProbeCommand.RaiseCanExecuteChanged(); StartProbeHeightMapCommand.RaiseCanExecuteChanged(); StopCommand.RaiseCanExecuteChanged(); PauseCommand.RaiseCanExecuteChanged(); SoftResetCommand.RaiseCanExecuteChanged(); HomingCycleCommand.RaiseCanExecuteChanged(); FeedHoldCommand.RaiseCanExecuteChanged(); CycleStartCommand.RaiseCanExecuteChanged(); EmergencyStopCommand.RaiseCanExecuteChanged(); LaserOnCommand.RaiseCanExecuteChanged(); LaserOffCommand.RaiseCanExecuteChanged(); SpindleOnCommand.RaiseCanExecuteChanged(); SpindleOffCommand.RaiseCanExecuteChanged(); GotoFavorite1Command.RaiseCanExecuteChanged(); GotoFavorite2Command.RaiseCanExecuteChanged(); SetFavorite1Command.RaiseCanExecuteChanged(); SetFavorite2Command.RaiseCanExecuteChanged(); GotoWorkspaceHomeCommand.RaiseCanExecuteChanged(); SetWorkspaceHomeCommand.RaiseCanExecuteChanged(); }
private async Task StartService(ServiceViewModel service, bool start) { try { var svc = service.Service; IsBusy = true; if (start) { svc.Start(); } else { svc.Stop(); } await Task.Run(() => { svc.WaitForStatus(start ? ServiceControllerStatus.Running : ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(10)); }); } catch (System.ServiceProcess.TimeoutException) { UI.MessageBoxService.ShowMessage("Operation timed out.", Constants.AppName); } catch (Exception ex) { UI.MessageBoxService.ShowMessage($"Error: {ex.Message}", Constants.AppName); } finally { IsBusy = false; service.Refresh(); StartCommand.RaiseCanExecuteChanged(); StopCommand.RaiseCanExecuteChanged(); } }
public MainWindowViewModel(IStopwatchService service) { this.service = service; Ellapsed = this.service.ObserveProperty(x => x.Ellapsed) .ToReadOnlyReactiveProperty() .AddTo(CompositeDisposable); LapTimes = this.service.LapTimes ?.ToReadOnlyReactiveCollection(t => new LapTimeViewModel(this.service.LapTimes.Count, t)); StartCommand = this.service.ObserveProperty(x => x.IsRunning) .Inverse() .ToReactiveCommand() .AddTo(CompositeDisposable); StartCommand.Subscribe(() => this.service.Start()).AddTo(CompositeDisposable); StopCommand = this.service.ObserveProperty(x => x.IsRunning) .ToReactiveCommand() .AddTo(CompositeDisposable); StopCommand.Subscribe(() => this.service.Stop()).AddTo(CompositeDisposable); ResetCommand = new ReactiveCommand().AddTo(CompositeDisposable); ResetCommand.Subscribe(() => this.service.Reset()).AddTo(CompositeDisposable); LapCommand = this.service.ObserveProperty(x => x.IsRunning) .ToReactiveCommand() .AddTo(CompositeDisposable); LapCommand.Subscribe(() => this.service.Lap()).AddTo(CompositeDisposable); }
/// <summary> /// /// </summary> /// <returns></returns> public ViewInfrastructure Create( ) { // Initialize the commands. this.eraseDelegateCommand = new EraseDelegateCommand( ); this.saveDelegateCommand = new SaveDelegateCommand( ); this.findReplaceCommand = new FindReplaceCommand( ); this.updateCommand = new UpdateCommand( ); this.stopCommand = new StopCommand( ); // Initialize Common Properties. MyCommons.LogProcess = new StringBuilder( ); // Initilaize new Model. Model model = new Model( ); // Initialize new ViewModel. ViewModel viewModel = new ViewModel(model, this.saveDelegateCommand.Command, this.eraseDelegateCommand.Command, this.findReplaceCommand.Command, this.updateCommand.Command, this.stopCommand.Command); // Initialize mainview. EditProfiles.MainWindow view = new EditProfiles.MainWindow( ); // Here setting Commands ViewModel so the commands can access to the viewModel, // otherwise ViewModel would be null and act weirdly. // Will use one viewModel and share for all commands. MyCommons.MyViewModel = viewModel; return(new ViewInfrastructure(view, viewModel, model)); }
private void StopwatchStateChanged() { StartCommand.RaiseCanExecuteChanged(); StopCommand.RaiseCanExecuteChanged(); ResetCommand.RaiseCanExecuteChanged(); LapCommand.RaiseCanExecuteChanged(); }
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 RaiseButtonsCommandsCanExecuteChanged() { RaisePropertyChanged(nameof(AreButtonsEnabled)); PlayCommand.RaiseCanExecuteChanged(); PauseCommand.RaiseCanExecuteChanged(); StopCommand.RaiseCanExecuteChanged(); }
private async Task CalibrationMinimumLight(IContext context) { if (context.Message is StopCommand stopCommand) { // Ignore previous commands if we receive any if (stopCommand[MessageProperties.Context] == "MAX") { return; } Become(StandardMode); ForwardToPowerAdapter(TurnOffCommand.Default); ResetStateValues(); TryCalculateSpectrum(); Logger.LogInformation($"Calibration of {Uid} : calibration finished with MIN: {_Minimum}, MAX: {_Maximum}, RANGE: {_Range}"); await Task.Delay(WAIT_AFTER_CHANGE).ConfigureAwait(false); ForwardToPowerAdapter(TurnOnCommand.Create(CHANGE_POWER_STATE_TIME)); } else if (context.Message is PropertyChangedEvent minimumState) { await MessageBroker.SendAfterDelay(ActorMessageContext.Create(Self, StopCommand.Create("MIN")), TimeSpan.FromMilliseconds(1500)).ConfigureAwait(false); _Minimum = minimumState.AsDouble(MessageProperties.NewValue); } else { await StandardMode(context).ConfigureAwait(false); } }
public async Task UserIsAdmin_Should_ChangeChatConfig_And_ReplyMessage() { // Arrange var chatConfigurationServiceMock = new Mock <IChatConfigurationService>(); var telegramBotClientMock = new Mock <ITelegramBotClientWrapper>(); var command = new StopCommand(chatConfigurationServiceMock.Object, telegramBotClientMock.Object); const string replyMessage = "Bot stopped"; var chatConfig = new ChatConfiguration { IsBotStopped = false }; var message = new Message { Text = TelegramBotCommands.Stop, From = new User { Id = 2 }, Chat = new Chat { Id = 1, Type = ChatType.Group } }; telegramBotClientMock.Setup(v => v.GetChatAdministratorsAsync(message.Chat.Id, default)) .ReturnsAsync(new[] { new ChatMemberMember { User = new() { Id = message.From.Id } } });
/// <summary> /// Uninitialize the scan engine /// </summary> protected override void ProcessRecord() { using (new AppDomainAdjuster()) { WriteObject(StopCommand.Execute()); } }
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 DisableCommands() { BuildCommand.Disable(); RebuildCommand.Disable(); CleanCommand.Disable(); StopCommand.Enable(); }
protected SoundPlayerViewModelBase(string displayName, string groupName) { DisplayName = displayName; GroupName = groupName; IsWave = groupName == SoundMachineViewModel.GenWaveGroup; var isPlayingChanged = this.WhenAnyValue(x => x.IsPlaying); var canPlay = isPlayingChanged.Select(isPlaying => !isPlaying); var canStop = isPlayingChanged.Select(IsPlaying => IsPlaying); canPlay.ToProperty(this, nameof(IsLoopedEnabled), out _isLoopedEnabled) .DisposeWith(Disposables); PlayCommand = ReactiveCommand.Create(ExecutePlay, canPlay); StopCommand = ReactiveCommand.Create(ExecuteStop, canStop); PlayCommand.ObserveOn(RxApp.MainThreadScheduler) .Do(_ => IsPlaying = true) .Subscribe(); StopCommand.ObserveOn(RxApp.MainThreadScheduler) .Do(_ => IsPlaying = false) .Subscribe(); this.WhenAnyValue(x => x.Duration, x => x.IsPlaying, x => x.IsLooped, (duration, isPlaying, isLooped) => (duration, isPlaying, isLooped)) .Where(x => x.duration > 0 && x.isPlaying && !x.isLooped) .Select(x => Observable.Timer(TimeSpan.FromSeconds(x.duration))) .Switch() .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(_ => IsPlaying = false) .DisposeWith(Disposables); }
private void UpdatePiece(Piece piece) { StopCommand.Execute(null); _sequencer.Sequence = new MidiConverter(false).Convert(piece); UpdateButtons(); }
public async Task UserIsAdmin_Should_ChangeChatConfig_And_ReplyMessage() { // Arrange var channelConfigurationServiceMock = new Mock <IDiscordChannelConfigService>(); var command = new StopCommand(channelConfigurationServiceMock.Object); const string replyMessage = "Bot stopped"; var chatConfig = new DiscordChannelConfig { IsBotStopped = false }; var channelMock = new Mock <IMessageChannel>(); var user = new Mock <IGuildUser>(); user.Setup(v => v.GuildPermissions).Returns(GuildPermissions.All); var message = new Mock <IMessage>(); message.Setup(v => v.Author).Returns(user.Object); message.Setup(v => v.Channel).Returns(channelMock.Object); channelConfigurationServiceMock.Setup(v => v.GetConfigurationByChannelId(message.Object.Channel.Id)) .ReturnsAsync(chatConfig); // Act await command.Handle(message.Object); // Assert // Verify SendMessageAsync was called with the reply message "Bot stopped" channelMock.Verify(v => v.SendMessageAsync(null, false, It.Is <Embed>(e => e.Description.Contains(replyMessage)), null, null, null, null, null, null, MessageFlags.None)); Assert.True(chatConfig.IsBotStopped); }
public async Task UserNotAdmin_Should_ReplyMessage() { // Arrange var channelConfigurationServiceMock = new Mock <IDiscordChannelConfigService>(); var command = new StopCommand(channelConfigurationServiceMock.Object); const string replyMessage = "Only admins can use this command."; var chatConfig = new DiscordChannelConfig { IsBotStopped = false }; var channelMock = new Mock <IMessageChannel>(); var user = new Mock <IGuildUser>(); user.Setup(v => v.GuildPermissions).Returns(GuildPermissions.None); var message = new Mock <IMessage>(); message.Setup(v => v.Author).Returns(user.Object); message.Setup(v => v.Channel).Returns(channelMock.Object); channelConfigurationServiceMock.Setup(v => v.GetConfigurationByChannelId(message.Object.Channel.Id)) .ReturnsAsync(chatConfig); // Act await command.Handle(message.Object); // Assert // Verify SendMessageAsync was called with the reply message "Only admins can use this command" channelMock.Verify(v => v.SendMessageAsync(replyMessage, false, null, null, null, It.Is <MessageReference>(m => m.MessageId.Value == message.Object.Id), null, null, null, MessageFlags.None)); Assert.False(chatConfig.IsBotStopped); // Make sure IsBotStopped is still false }
private void RefreshCamCommands() { ScanCommand.RaiseCanExecuteChanged(); StartCommand.RaiseCanExecuteChanged(); StopCommand.RaiseCanExecuteChanged(); RefreshCommand.RaiseCanExecuteChanged(); }
void StatusUpdate() { StartCommand.RaiseCanExecuteChanged(); StopCommand.RaiseCanExecuteChanged(); Time = _connectionController.TimeSeconds; Amount = _connectionController.Amount; Status = _connectionController.Status; }
private void pingable_PingStatsUpdated(object sender, EventArgs e) { Application.Current.Dispatcher.Invoke(() => { StartCommand.RaiseCanExecuteChanged(); StopCommand.RaiseCanExecuteChanged(); }); }
private void UpdateCommands() { PlayCommand.OnCanExecuteChanged(); PauseCommand.OnCanExecuteChanged(); StopCommand.OnCanExecuteChanged(); RestartCommand.OnCanExecuteChanged(); CaptureImageCommand.OnCanExecuteChanged(); }
private void StopButton_Click(object sender, RoutedEventArgs e) { Stop(); if (StopCommand != null && StopCommand.CanExecute(EMPTY_PARAMETER)) { StopCommand.Execute(EMPTY_PARAMETER); } }
public ControlBarVM(FGM m) : base(m) { PauseTheFlight = new PauseCommand(PauseThread); PlayTheFlight = new PlayCommand(ContinueRunning); IncreaseTheSpeed = new PlusCommand(IncreaseSpeed); DecreaseTheSpeed = new MinusCommand(DecreaseSpeed); StopTheFlight = new StopCommand(StopFlight); }
private void RaiseCanExecuteChanged() { StartCommand.RaiseCanExecuteChanged(); StopCommand.RaiseCanExecuteChanged(); SettingsCommand.RaiseCanExecuteChanged(); RaiseCanExecuteIncrDecrChanged(); }
public void Handle(CoreProjectionManagementMessage.Stop message) { var command = new StopCommand { Id = message.ProjectionId.ToString("N") }; _commandWriter.PublishResponse("$stop", message.WorkerId, command); }
private void EnableCommands() { _requestStopOperation = false; BuildCommand.Enable(); RebuildCommand.Enable(); CleanCommand.Enable(); StopCommand.Disable(); }
private void RaiseCanExecute() { StartCommand.RaiseCanExecuteChanged(); RestoreCommand.RaiseCanExecuteChanged(); StopCommand.RaiseCanExecuteChanged(); SuspendCommand.RaiseCanExecuteChanged(); ResumeCommand.RaiseCanExecuteChanged(); }
public void Start() { tickTimer.Start(); MainButtonCommand = new StopCommand(this); NotifyPropertyChanged("MainButtonCommand"); ProgressState = TaskbarItemProgressState.Normal; UpdatePropeties(); }
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 InitializeCommandsAsync(AsyncPackage aAsyncPackage) { if (CompileCommand.Instance == null) { await CompileCommand.InitializeAsync(this, aAsyncPackage, mCommandSet, CommandIds.kCompileId); await CompileCommand.InitializeAsync(this, aAsyncPackage, mCommandSet, CommandIds.kCompileToolbarId); } if (TidyCommand.Instance == null) { await TidyCommand.InitializeAsync(this, aAsyncPackage, mCommandSet, CommandIds.kTidyId); await TidyCommand.InitializeAsync(this, aAsyncPackage, mCommandSet, CommandIds.kTidyToolbarId); await TidyCommand.InitializeAsync(this, aAsyncPackage, mCommandSet, CommandIds.kTidyFixId); await TidyCommand.InitializeAsync(this, aAsyncPackage, mCommandSet, CommandIds.kTidyFixToolbarId); } if (FormatCommand.Instance == null) { await FormatCommand.InitializeAsync(this, aAsyncPackage, mCommandSet, CommandIds.kClangFormat); await FormatCommand.InitializeAsync(this, aAsyncPackage, mCommandSet, CommandIds.kClangFormatToolbarId); } if (IgnoreFormatCommand.Instance == null) { await IgnoreFormatCommand.InitializeAsync(this, aAsyncPackage, mCommandSet, CommandIds.kIgnoreFormatId); } if (IgnoreCompileCommand.Instance == null) { await IgnoreCompileCommand.InitializeAsync(this, aAsyncPackage, mCommandSet, CommandIds.kIgnoreCompileId); } if (StopCommand.Instance == null) { await StopCommand.InitializeAsync(this, aAsyncPackage, mCommandSet, CommandIds.kStopClang); } if (SettingsCommand.Instance == null) { await SettingsCommand.InitializeAsync(this, aAsyncPackage, mCommandSet, CommandIds.kSettingsId); } if (TidyConfigCommand.Instance == null) { await TidyConfigCommand.InitializeAsync(this, aAsyncPackage, mCommandSet, CommandIds.kITidyExportConfigId); } if (Logout.Instance == null) { await Logout.InitializeAsync(this, aAsyncPackage, mCommandSet, CommandIds.kLogoutId); } }
private void StopTimer() { Timer.Stop(); Stopped?.Invoke(this, EventArgs.Empty); if (StopCommand?.CanExecute(StopCommandParameter) == true) { StopCommand?.Execute(StopCommandParameter); } }
public static void Main() { engine.AddCommand(new DelayedTyper(100, '1')); engine.AddCommand(new DelayedTyper(300, '3')); engine.AddCommand(new DelayedTyper(400, '5')); engine.AddCommand(new DelayedTyper(700, '7')); ICommand stopCommand = new StopCommand(); engine.AddCommand(new SleepCommand(10000, engine, stopCommand)); engine.Run(); }