/// <summary>
        /// Initialize the view model.
        /// </summary>
        public AdcpConfigurationViewModel()
            : base("Adcp Configuration")
        {
            // Initialize values
            _events         = IoC.Get <IEventAggregator>();
            _pm             = IoC.Get <PulseManager>();
            _adcpConnection = IoC.Get <AdcpConnection>();

            SubsystemConfigList = new ReactiveList <AdcpSubsystemConfigurationViewModel>();
            BatteryTypeList     = DeploymentOptions.GetBatteryList();

            // Initialize the values
            InitializeValues();

            // Scan ADCP command
            ScanAdcpCommand = ReactiveCommand.CreateAsyncTask(_ => ScanConfiguration());

            // Add Subsystem Configuration
            AddSubsystemCommand = ReactiveCommand.Create();
            AddSubsystemCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.FrequencyView)));

            // Next command
            NextCommand = ReactiveCommand.Create(this.WhenAny(x => x.IsScanning, x => !x.Value));
            NextCommand.Subscribe(_ => NextPage());

            // Back coommand
            BackCommand = ReactiveCommand.Create();
            BackCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.Back)));

            // Exit coommand
            ExitCommand = ReactiveCommand.Create();
            ExitCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.HomeView)));

            // Compass Cal coommand
            CompassCalCommand = ReactiveCommand.Create();
            CompassCalCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.CompassCalView)));

            // Edit the configuration command
            EditCommand = ReactiveCommand.Create();
            EditCommand.Subscribe(param => OnEditCommand(param));

            // Save the commands to a text file
            SaveCmdsCommand = ReactiveCommand.CreateAsyncTask(_ => SaveCommandsToFile());

            // Get the configuration from the project
            GetConfiguation();

            // Update the deployment duration to include all the new configurations
            // The duration needs to be divided amoung all the configuration
            UpdateDeploymentDuration();

            // Update the properites
            UpdateProperties();
        }
Example #2
0
        public NotesVM()
        {
            NewNotebookCommand = new NewNotebookCommand(this);
            NewNoteCommand     = new NewNoteCommand(this);
            ExitCommand        = new ExitCommand();
            BeginEditCommand   = new BeginEditCommand(this);
            HasEditedCommand   = new HasEditedCommand(this);
            Notebooks          = new ObservableCollection <Notebook>();
            Notes = new ObservableCollection <Note>();

            ReadNotebooks();
        }
        public NotesViewModel()
        {
            EditCommand   = new EditCommand(this);
            DeleteCommand = new DeleteCommand(this);
            AddCommand    = new AddCommand(this);
            SaveCommand   = new SaveCommand(this);
            ExitCommand   = new ExitCommand();
            AboutCommand  = new AboutCommand();

            this.Notes = new ObservableCollection <NoteModel>();
            LoadNotes();
        }
Example #4
0
        public void InvalidArgumentTest()
        {
            ICommand command       = new ExitCommand();
            var      commandResult = command.Execute(new List <string>()
            {
                "Some argument"
            });

            Assert.IsNotNull(commandResult);
            Assert.AreEqual(1, commandResult.Count());
            Assert.AreEqual("Invalid arguments", commandResult.First());
        }
Example #5
0
        public void CallsExit()
        {
            var viewModel = Mock.Of <IViewModel>();
            var command   = new ExitCommand(viewModel)
            {
                Exiter = Mock.Of <IExiter>()
            };

            command.Execute(null);

            Mock.Get(command.Exiter).Verify(x => x.Exit());
        }
Example #6
0
        public string DispatchCommand(string[] commandParameters)
        {
            string command = commandParameters.First().ToLower();

            string[] parameters      = commandParameters.ToArray();
            int      parametersCount = parameters.Length;

            string output = string.Empty;

            switch (command)
            {
            case "addemployee":
                output = AddEmployeeCommand.Execute(parameters);
                break;

            case "setbirthday":
                output = SetBirthdayCommand.Execute(parameters);
                break;

            case "setaddress":
                output = SetAddressCommand.Execute(parameters);
                break;

            case "employeeinfo":
                output = EmployeeInfoCommand.Execute(parameters);
                break;

            case "employeepersonalinfo":
                output = EmployeePersonalInfoCommand.Execute(parameters);
                break;

            case "setmanager":
                output = SetManagerCommand.Execute(parameters);
                break;

            case "managerinfo":
                output = ManagerInfoCommand.Execute(parameters);
                break;

            case "listemployeesolderthan":
                output = ListEmplyeesOlderThan.Execute(parameters);
                break;

            case "exit":
                output = ExitCommand.Execute();
                break;

            default:    throw new InvalidOperationException($"Command {command} not valid!");
                //break;
            }
            return(output);
        }
Example #7
0
        public ExceptionViewModel(Exception exception, IApplicationService applicationService)
        {
            _exception          = exception;
            _applicationService = applicationService;

            OpenLogFolderCommand = ReactiveCommand.Create(Observable.Return(_applicationService.LogFolder != null))
                                   .DisposeWith(this);

            CopyCommand = ReactiveCommand.Create(Observable.Return(exception != null))
                          .DisposeWith(this);

            ContinueCommand = ReactiveCommand.Create()
                              .DisposeWith(this);

            ExitCommand = ReactiveCommand.Create()
                          .DisposeWith(this);

            RestartCommand = ReactiveCommand.Create()
                             .DisposeWith(this);

            OpenLogFolderCommand.ActivateGestures()
            .Subscribe(x => OpenLogFolder())
            .DisposeWith(this);

            CopyCommand.ActivateGestures()
            .Subscribe(x => Copy())
            .DisposeWith(this);

            ContinueCommand.ActivateGestures()
            .Subscribe(x => Continue())
            .DisposeWith(this);

            ExitCommand
            .ActivateGestures()
            .Subscribe(x => Exit())
            .DisposeWith(this);

            RestartCommand
            .ActivateGestures()
            .Subscribe(x => Restart())
            .DisposeWith(this);

            Closed.Take(1)
            .Subscribe(x =>
            {
                // Force all other potential exceptions to be realized
                // from the Finalizer thread to surface to the UI
                GC.Collect(2, GCCollectionMode.Forced);
                GC.WaitForPendingFinalizers();
            })
            .DisposeWith(this);
        }
        public void Execute_CancelsToken()
        {
            var cancellationTokenSource = (CancellationTokenSource)typeof(CommandLoop)
                                          .GetField(
                "cancellationTokenSource",
                BindingFlags.Instance | BindingFlags.NonPublic)
                                          .GetValue(this.commandLoop);
            var exitCommand = new ExitCommand(this.commandLoop);

            exitCommand.Execute(CancellationToken.None);

            Assert.That(cancellationTokenSource.IsCancellationRequested, Is.True);
        }
        public async Task ExitCommandExits()
        {
            using var mock = AutoMock.GetLoose();
            var context = mock.Mock <IUpgradeContext>().Object;

            var exitCalled = false;
            var command    = new ExitCommand(() => exitCalled = true);

            Assert.Equal("Exit", command.CommandText);
            Assert.False(exitCalled);
            Assert.True(await command.ExecuteAsync(context, CancellationToken.None).ConfigureAwait(false));
            Assert.True(exitCalled);
        }
        public void CheckIfMethodExitExecuteReturnsProperString()
        {
            IMatrixField           field      = FieldFactory.Instance.GetField(5);
            IScoreboard            scoreboard = new ScoreboardProxy();
            IRandomNumberGenerator random     = new RandomNumberGenerator();
            IGameEngine            gameEngine = new GameFifteenEngine(field, scoreboard, random);

            ExitCommand exitCommand = new ExitCommand(gameEngine);

            string result = exitCommand.Execute();

            Assert.AreEqual(result, GlobalConstants.ExitMessage);
        }
Example #11
0
        public GameOverViewModel(MainViewModel model, PlayerOptionsViewModel options, PlayerViewModel winner) : base(model)
        {
            this.Options = options;
            this.Winner  = winner;
            Exit         = new ExitCommand(this.viewModel);

            Restart = new EasyCommand(() =>
            {
                WelcomeViewModel newGame = new WelcomeViewModel(this.viewModel);
                newGame.Options          = Options;
                SwitchTo(newGame);
            });
        }
        public string ExecuteCommand(string commandArguments)
        {
            var commandName = commandArguments.Substring(0, commandArguments.IndexOf(' '));

            var commandParameters = new JavaScriptSerializer()
                .Deserialize<Dictionary<string, string>>(
                    commandArguments.Substring(commandArguments.IndexOf(' ') + 1));

            if (commandName != "SetupPark" && this.VehiclePark == null)
            {
                return "The vehicle park has not been set up";
            }

            ICommand command = null;
            switch (commandName)
            {
                case "SetupPark":
                    command = new SetupParkCommand(commandName, commandParameters, this.VehiclePark);
                    break;
                case "Park":
                    command = new ParkCommand(commandName, commandParameters, this.VehiclePark);
                    break;
                case "Exit":
                    command = new ExitCommand(commandName, commandParameters, this.VehiclePark);
                    break;
                case "Status":
                    command = new StatusCommand(commandName, commandParameters, this.VehiclePark);
                    break;
                case "FindVehicle":
                    command = new FindVehicleCommand(commandName, commandParameters, this.VehiclePark);
                    break;
                case "VehiclesByOwner":
                    command = new VehiclesByOwner(commandName, commandParameters, this.VehiclePark);
                    break;
                default:
                    throw new InvalidOperationException("Invalid command.");
            }

            var commandOutput = string.Empty;
            if (commandName == "SetupPark")
            {
                this.VehiclePark = command.Execute() as IVehiclePark;
                commandOutput = "Vehicle park created";
            }
            else
            {
                commandOutput = command.Execute() as string;
            }

            return commandOutput;
        }
Example #13
0
        /// <summary>
        /// Method which process input commands
        /// </summary>
        /// <param name="command">inut command</param>
        public void ExecuteCommand(string command)
        {
            CommandInfo commandInfo    = (CommandInfo)this.commandParser.Parse(command);
            Command     currentCommand = null;

            switch (commandInfo.Name)
            {
            case "start":
                currentCommand = new StartCommand(this, this.matrix, this.player, this.director, this.builder, this.printer);
                break;

            case "turn":
                currentCommand = new TurnCommand(this, this.matrix, this.player, this.printer);
                break;

            case "menu":
                MainMenu.PrintMenu(this);
                break;

            case "exit":
                currentCommand = new ExitCommand(this.matrix, this.player, this.printer);
                break;

            case "save":
                currentCommand = new SaveCommand(this.matrix, this.player, this.printer);
                break;

            case "load":
                currentCommand = new LoadCommand(this.matrix, this.player, this.printer);
                break;

            case "mode":
                currentCommand = new ChangeModeCommand(this, this.matrix, this.player, this.printer);
                break;

            case "highscore":
                currentCommand = new HighScoreCommand(this, this.matrix, this.player, this.printer);
                break;

            default:
                currentCommand = new InvalidCommand(this.matrix, this.player, this.printer);
                currentCommand.Execute(commandInfo);
                this.Start();
                return;
            }

            currentCommand.Execute(commandInfo);
            this.printer.PrintMatrix(this.matrix, this.player);
            this.Start();
        }
        public override async Task Init()
        {
            await Task.Delay(1);

            //auto back page
            Device.StartTimer(TimeSpan.FromSeconds(15), () =>
            {
                if (FuncHelp.CurrentPage() is CustomerFinishPage)
                {
                    ExitCommand.Execute(null);
                }
                return(false); // not repeat
            });
        }
Example #15
0
        public NotifyIcon(
            AppActivatedCommand appActivatedCommand,
            BeginSliceRegionsCommand beginSliceRegionsCommand,
            ShowWindowCommand <Windows.SettingsWindow> showSettingsWindowCommand,
            ExitCommand exitCommand
            )
        {
            AppActivatedCommand       = appActivatedCommand;
            BeginSliceRegionsCommand  = beginSliceRegionsCommand;
            ShowSettingsWindowCommand = showSettingsWindowCommand;
            ExitCommand = exitCommand;

            InitializeComponent();
        }
Example #16
0
        public void Shutdown()
        {
            var application = new Mock<IAbstractApplications>();
            {
                application.Setup(a => a.Shutdown())
                    .Verifiable();
            }

            var command = new ExitCommand(application.Object);
            Assert.IsTrue(command.CanExecute(null));
            command.Execute(null);

            application.Verify(a => a.Shutdown(), Times.Once());
        }
        /// <summary>
        /// Function for creating commands
        /// </summary>
        /// <param name="command">Command name</param>
        /// <returns>New command object</returns>
        public ICommand CreateCommand(string command)
        {
            ICommand resultCommand;

            if (this.commandDictionary.ContainsKey(command))
            {
                return(this.commandDictionary[command]);
            }

            switch (command)
            {
            case "u":
                resultCommand = new MoveUp();
                break;

            case "d":
                resultCommand = new MoveDown();
                break;

            case "l":
                resultCommand = new MoveLeft();
                break;

            case "r":
                resultCommand = new MoveRight();
                break;

            case "restart":
                resultCommand = new RestartCommand();
                break;

            case "top":
                resultCommand = new ScoreCommand();
                break;

            case "exit":
                resultCommand = new ExitCommand();
                break;

            case "undo":
                resultCommand = new UndoCommand();
                break;

            default:
                throw new InvalidCommandException(GlobalErrorMessages.InvalidCommandMessage);
            }

            this.commandDictionary.Add(command, resultCommand);
            return(resultCommand);
        }
            public void PromptsUserBeforeExiting()
            {
                // arrange
                var console = new Mock <IConsole>();

                console.Setup(x => x.ReadLine(message)).Returns("n");
                var executor = new Mock <IRepl>();
                var cmd      = new ExitCommand(console.Object);

                // act
                cmd.Execute(executor.Object, null);

                // assert
                console.Verify(x => x.ReadLine(message));
            }
        private async Task <ExitResult> Execute(string connectionId, ExitCommand _)
        {
            var user = await userService.Leave(connectionId);

            var userList = await userService.GetAllUserFromRoom(user.Room.Name);

            return(new ExitResult
            {
                Messages = userList.Select(itm => new MessageResult
                {
                    Message = $"O usuário {user.Name} saiu na sala.",
                    ConnectionId = itm.ConnectionId
                }).ToList()
            });
        }
Example #20
0
        async void SingInAsync()
        {
            HttpResponseMessage response = await client.GetAsync("Users/SingIn?Name=" + User.Name + "&Password="******"Введены неверные логин или пароль, попробуйте еще раз");
            }
        }
Example #21
0
        public async void ExitCommand_Execute()
        {
            // ARRANGE
            var interaction = new Mock <IInteractionProvider>();

            interaction.SetupGet(_ => _.IsDebugMode).Returns(true);
            var command = new ExitCommand(interaction.Object);

            // ACT
            await command.Execute();

            // ASSERT
            interaction.Verify(_ => _.Warn(It.IsAny <string>()));
            interaction.Verify(_ => _.Exit());
        }
Example #22
0
        public string Dispatch(string input)
        {
            string result = String.Empty;

            string[] args = input.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);

            string cmdName = args.Length >= 0 ? args[0] : string.Empty;

            args = args.Skip(1).ToArray();

            switch (cmdName)
            {
            case "RegisterUser": result = new RegisterUserCommand().Execute(args); break;

            case "Login": result = new LoginCommand().Execute(args); break;

            case "Logout": result = new LogoutCommand().Execute(args); break;

            case "DeleteUser": result = new DeleteUserCommand().Execute(args); break;

            case "CreateEvent": result = new CreateEventCommand().Execute(args); break;

            case "CreateTeam": result = new CreateTeamCommand().Execute(args); break;

            case "InviteToTeam": result = new InviteToTeamCommand().Execute(args); break;

            case "AcceptInvite": result = new AcceptInviteCommand().Execute(args); break;

            case "DeclineInvite": result = new DeclineInviteCommand().Execute(args); break;

            case "KickMember": result = new KickMemberCommand().Execute(args); break;

            case "Disband": result = new DisbandCommand().Execute(args); break;

            case "AddTeamTo": result = new AddTeamToCommand().Execute(args); break;

            case "ShowEvent": result = new ShowEventCommand().Execute(args); break;

            case "ShowTeam": result = new ShowTeamCommand().Execute(args); break;

            case "Exit": result = new ExitCommand().Execute(args); break;

            default:
                throw new NotSupportedException($"Command {cmdName} not supported!");
            }

            return(result);
        }
        public string DispatchCommand(string[] commandParameters)
        {
            string commandName = commandParameters[0];

            commandParameters = commandParameters.Skip(1).ToArray();
            string result = string.Empty;

            EventService eventService = new EventService();

            switch (commandName)
            {
            case "CreateEvent":
                CreateEventCommand createEvent = new CreateEventCommand(eventService);
                result = createEvent.Execute(commandParameters);
                break;

            case "DeleteEvent":
                DeleteEventCommand deleteEvent = new DeleteEventCommand(eventService);
                result = deleteEvent.Execute(commandParameters);
                break;

            case "EditEvent":
                EditEventCommand editEvent = new EditEventCommand(eventService);
                result = editEvent.Execute(commandParameters);
                break;

            case "ListEvents":
                ListEventsCommand listEvents = new ListEventsCommand(eventService);
                result = listEvents.Execute(commandParameters);
                break;

            case "Help":
                HelpCommand help = new HelpCommand();
                result = help.Execute(commandParameters);
                break;

            case "Exit":
                ExitCommand exit = new ExitCommand(eventService);
                result = exit.Execute(commandParameters);
                break;

            default:
                result = $@"Command {commandName} does not exist. Type ""Help"" to check the available commands.";
                break;
            }

            return(result);
        }
            public void ExitsWhenUserAnswersYes()
            {
                // arrange
                var console = new Mock <IConsole>();

                console.Setup(x => x.ReadLine(message)).Returns("y");

                var executor = new Mock <IRepl>();
                var cmd      = new ExitCommand(console.Object);

                // act
                cmd.Execute(executor.Object, null);

                // assert
                executor.Verify(x => x.Terminate());
            }
Example #25
0
        public CommandProvider(
            InputOutputStreams io,
            LogSettings logSettings,
            IUserInput userInput,
            IHostApplicationLifetime lifetime)
        {
            if (lifetime is null)
            {
                throw new ArgumentNullException(nameof(lifetime));
            }

            _io          = io ?? throw new ArgumentNullException(nameof(io));
            _logSettings = logSettings;
            _userInput   = userInput ?? throw new ArgumentNullException(nameof(userInput));
            _exit        = new ExitCommand(lifetime.StopApplication);
        }
        private void EditAuthor(object obj)
        {
            var oldAuthor = _dbContext.Authors.Where(x => String.Equals(x.ID_Author, _transferData.ID_Author)).SingleOrDefault();

            if (oldAuthor != null)
            {
                oldAuthor.Name       = Author.Name;
                oldAuthor.Surname    = Author.Surname;
                oldAuthor.Patronymic = Author.Patronymic;
                oldAuthor.Nickname   = Author.Nickname;

                _dbContext.SaveChanges();

                ExitCommand.Execute();
            }
        }
Example #27
0
 public MainViewModel()
 {
     timer       = ServiceLocator.Current.GetInstance <ITimerService>();
     timer.Tick += Timer_Tick;
     timer.Start(new TimeSpan(0, 0, 0, 0, 001));
     initializeSimulation();
     X = 400;
     Y = 400;
     isRandomPlacement = false;
     this.setXAndY();
     Add             = new AddBoidCommand(this);
     Exit            = new ExitCommand(this);
     Pause           = new PauseCommand(this);
     Sliders         = new SliderHandler(this);
     ChangePlacement = new PlacementCommand(this);
 }
Example #28
0
        private void EditCommand(object obj)
        {
            try
            {
                UpdateEmployeeAsync(Employee);

                logger.Info("Данные сотрудника изменены на " + Employee.FirstName + " " + Employee.LastName);
                MessageBox.Show("Данные сотрудника изменены");
                ExitCommand.Execute();
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
                logger.Error(exc, "Ошибка c изменением данных сотрудника");
            }
        }
Example #29
0
            public void DoesNotExitWhenUserAnswersNo()
            {
                // arrange
                var console = new Mock <IConsole>();

                console.Setup(x => x.ReadLine()).Returns("n");

                var executor = new Mock <IRepl>();
                var cmd      = new ExitCommand(console.Object);

                // act
                cmd.Execute(executor.Object, null);

                // assert
                executor.Verify(x => x.Terminate(), Times.Never);
            }
Example #30
0
            public void PromptsUserBeforeExiting()
            {
                // arrange
                const string message = "Are you sure you wish to exit? (y/n): ";
                var          console = new Mock <IConsole>();

                console.Setup(x => x.ReadLine()).Returns("n");
                var executor = new Mock <IRepl>();
                var cmd      = new ExitCommand(console.Object);

                // act
                cmd.Execute(executor.Object, null);

                // assert
                console.Verify(x => x.Write(message));
            }
Example #31
0
        private void EditCommand(object obj)
        {
            //Material material = new Material()
            //{
            //    MaterialId = Material.MaterialId,
            //    NumberEK = Material.NumberEK,
            //    Story = Material.Story,
            //    DateOfRegistration = Material.DateOfRegistration,
            //    DateOfTerm = Material.DateOfTerm,
            //    Extension = Material.Extension,
            //    Decision = Material.Decision,
            //    ExecutedOrNotExecuted = Material.ExecutedOrNotExecuted,
            //    Perspective = Material.Perspective

            //    //Patronymic = (Author.Patronymic is null) ? "" : Author.Patronymic,
            //    //Nickname = (Author.Nickname is null) ? "" : Author.Nickname
            //};

            try
            {
                var oldMaterial = db.Materials.Where(x => x.MaterialId == Material.MaterialId).SingleOrDefault();
                if (oldMaterial != null)
                {
                    //MaterialId = Material.MaterialId,
                    oldMaterial.NumberEK              = Material.NumberEK;
                    oldMaterial.Story                 = Material.Story;
                    oldMaterial.DateOfRegistration    = Material.DateOfRegistration;
                    oldMaterial.DateOfTerm            = Material.DateOfTerm;
                    oldMaterial.Extension             = Material.Extension;
                    oldMaterial.Decision              = Material.Decision;
                    oldMaterial.ExecutedOrNotExecuted = Material.ExecutedOrNotExecuted;
                    oldMaterial.Perspective           = Material.Perspective;
                }

                //oldMaterial = material;

                db.SaveChanges();
                logger.Info("Материал ЕК№" + oldMaterial.NumberEK + " изменен");
                MessageBox.Show("Материал изменен");
                ExitCommand.Execute();
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
                logger.Error(exc, "Ошибка c изменением данных материала в БД ");
            }
        }
Example #32
0
        public BeamgunViewModel()
        {
            var dictionary      = new RegistryBackedDictionary();
            var beamgunSettings = new BeamgunSettings(dictionary);

            BeamgunState = new BeamgunState(beamgunSettings)
            {
                MainWindowVisibility = Visibility.Hidden
            };
            // TODO: This bi-directional relationship feels bad.
            dictionary.BadCastReport += BeamgunState.AppendToAlert;
            BeamgunState.Disabler     = new Disabler(BeamgunState);
            BeamgunState.Disabler.Enable();
            DisableCommand     = new DisableCommand(this, beamgunSettings);
            TrayIconCommand    = new TrayIconCommand(this);
            LoseFocusCommand   = new DeactivatedCommand(this);
            ResetCommand       = new ResetCommand(this);
            ExitCommand        = new ExitCommand(this);
            ClearAlertsCommand = new ClearAlertsCommand(this);
            _keystrokeHooker   = InstallKeystrokeHooker();
            _usbStorageGuard   = InstallUsbStorageGuard(beamgunSettings);
            _alarm             = InstallAlarm(beamgunSettings);
            _networkWatcher    = new NetworkWatcher(beamgunSettings,
                                                    new NetworkAdapterDisabler(),
                                                    x => BeamgunState.AppendToAlert(x),
                                                    x =>
            {
                _alarm.Trigger(x);
                BeamgunState.SetGraphicsLanAlert();
            },
                                                    () => BeamgunState.Disabler.IsDisabled);
            _keyboardWatcher = new KeyboardWatcher(beamgunSettings,
                                                   new WorkstationLocker(),
                                                   x => BeamgunState.AppendToAlert(x),
                                                   x =>
            {
                _alarm.Trigger(x);
                BeamgunState.SetGraphicsKeyboardAlert();
            },
                                                   () => BeamgunState.Disabler.IsDisabled);
            var checker = new VersionChecker();

            _updateTimer = new VersionCheckerTimer(beamgunSettings,
                                                   checker,
                                                   x => BeamgunState.AppendToAlert(x));
        }
Example #33
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ShellWindow"/> class.
        /// </summary>
        /// <param name="exitCommand">The command used to exit the application.</param>
        /// <param name="progressReporter">The object that reports progress for all of the application.</param>
        /// <exception cref="ArgumentNullException">
        /// Thrown if <paramref name="exitCommand"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="progressReporter"/> is <see langword="null" />.
        /// </exception>
        public ShellWindow(ExitCommand exitCommand, ICollectProgressReports progressReporter)
            : this()
        {
            {
                Enforce.Argument(() => exitCommand);
                Enforce.Argument(() => progressReporter);
            }

            m_ExitCommand = exitCommand;

            // Handle the start progress event.
            {
                progressReporter.OnStartProgress +=
                    (s, e) =>
                    {
                        Action action = () => taskbarItemInfo.ProgressState = TaskbarItemProgressState.Indeterminate;
                        Dispatcher.Invoke(action);
                    };
            }

            // Handle the progress event.
            {
                Action<int, bool> action =
                    (progress, hasErrors) =>
                    {
                        taskbarItemInfo.ProgressState = hasErrors ? TaskbarItemProgressState.Error : TaskbarItemProgressState.Normal;
                        taskbarItemInfo.ProgressValue = progress / 100.0;
                    };
                progressReporter.OnProgress +=
                    (s, e) =>
                    {
                        Dispatcher.Invoke(action, e.Progress, e.HasErrors);
                    };
            }

            // Handle the stop progress event.
            {
                progressReporter.OnStopProgress +=
                    (s, e) =>
                    {
                        Action action = () => taskbarItemInfo.ProgressState = TaskbarItemProgressState.None;
                        Dispatcher.Invoke(action);
                    };
            }
        }
 static DemoManager()
 {
     DefaultStyleKeyProperty.OverrideMetadata(typeof(DemoManager), new FrameworkPropertyMetadata(typeof(DemoManager)));
     Exit = new ExitCommand();
 }
Example #35
0
 private static void On(ExitCommand command)
 {
     quit = true;
 }
Example #36
0
 public void CanShutdownWithNullApplication()
 {
     var command = new ExitCommand(null);
     Assert.IsFalse(command.CanExecute(null));
 }
Example #37
0
 public override bool TryBuildCommand(string[] args, out object command)
 {
     command = new ExitCommand();
     return true;
 }
Example #38
0
 public void ExecuteExitCommand()
 {
     ExitCommand cmd = new ExitCommand();
     cmd.Execute(null);
 }