Пример #1
0
    public void Configure(List <string> arguments)
    {
        try
        {
            if (arguments.Count < 1)
            {
                string message = "The command '<color=" + ConsoleConfiguration.HighlightColour + ">configure default-maze</color>' needs an additional argument with the name of the level that should be the new default.json";

                message += ConfigureCommand.GetConfigurableArguments();
                throw new NotEnoughArgumentsConsoleException(message);
            }

            string sanatisedLevelName = arguments[0].ToLower().Replace(" ", "-");

            bool levelExists = MazeLevelLoader.MazeLevelExists(sanatisedLevelName);

            if (!levelExists)
            {
                string message = $"Could not find a maze level with the name {sanatisedLevelName}.";
                throw new CouldNotFindMazeLevelConsoleException(message);
            }

            MazeLevelLoader.ReplaceMazeLevel(sanatisedLevelName, "default");

            Console.Instance.PrintToReportText($"{sanatisedLevelName} is now the default maze level.");
        }
        catch (System.Exception)
        {
            throw;
        }
    }
Пример #2
0
    public void Configure(List <string> arguments)
    {
        try
        {
            if (arguments.Count < 2)
            {
                string message = "The command '<color=" + ConsoleConfiguration.HighlightColour + ">configure maze</color>' needs additional arguments. \nMake sure that the 2nd argument has the name of the level that needs to be changed, and the 3rd argument says what needs to be configured.\n For example 'configure maze first-level playable true'.\n";
                Logger.Warning(message);

                message += ConfigureCommand.GetConfigurableArguments();
                throw new NotEnoughArgumentsConsoleException(message);
            }

            string levelName = arguments[0];

            switch (arguments[1])
            {
            case "playable":
                arguments.RemoveAt(1);
                arguments.RemoveAt(0);
                ToggleLevelPlayability(levelName, arguments);
                break;

            default:
                string message = $"{arguments[1]} Is an unknown argument to configure.";
                message += ConfigureCommand.GetConfigurableArguments();
                throw new UnknownArgumentConsoleException(message);
            }
        }
        catch (System.Exception)
        {
            throw;
        }
    }
Пример #3
0
        public void ConfigureCommand_CanExecuteAsync(string argString, bool expected)
        {
            var command = new ConfigureCommand(Mock.Of <IConfigurationService>());

            bool result = command.CanExecute(argString?.Split(null));

            Assert.Equal(expected, result);
        }
Пример #4
0
 /// <summary>
 /// Initialization of the package; this method is called right after the package is sited, so this is the place
 /// where you can put all the initialization code that rely on services provided by VisualStudio.
 /// </summary>
 protected override void Initialize()
 {
     base.Initialize();
     ConfigureCommand.Initialize(this);
     ValidateCommand.Initialize(this);
     PackageCommand.Initialize(this);
     TestCommand.Initialize(this);
     PushCommand.Initialize(this);
 }
Пример #5
0
        public Command CreateCommand(CommandType commandType)
        {
            Command command = null;

            switch (commandType)
            {
            case CommandType.Start:
                command = new StartCommand(drone);
                break;

            case CommandType.Stop:
                command = new StopCommand(drone);
                break;

            case CommandType.Configure:
                command = new ConfigureCommand(drone);
                break;

            case CommandType.MoveBackward:
                command = new MoveBackwardCommand(drone);
                break;

            case CommandType.MoveDown:
                command = new MoveDownCommand(drone);
                break;

            case CommandType.MoveForward:
                command = new MoveForwardCommand(drone);
                break;

            case CommandType.MoveLeft:
                command = new MoveLeftCommand(drone);
                break;

            case CommandType.MoveRight:
                command = new MoveRightCommand(drone);
                break;

            case CommandType.MoveUp:
                command = new MoveUpCommand(drone);
                break;

            case CommandType.Hover:
                command = new HoverCommand(drone);
                break;

            default:
                throw new ArgumentException("Invalid command type");
            }
            return(command);
        }
Пример #6
0
        public void ConfigureCommand_ShouldExecuteClientConfigure()
        {
            // arrange
            var droneConfiguration = new DroneConfiguration.DroneConfiguration();

            configureCommand = new ConfigureCommand(DroneClientMock.Object);

            // act
            configureCommand.SetConfiguration(droneConfiguration);
            configureCommand.Execute();

            // assert
            DroneClientMock.Verify(x => x.Configure(droneConfiguration), Times.Once);
        }
Пример #7
0
        public async Task ConfigureCommand_ExecuteAsync_System_InvokesConfigurationServiceConfigureSystem()
        {
            var configService = new Mock <IConfigurationService>();

            configService.Setup(x => x.ConfigureAsync(It.IsAny <ConfigurationTarget>()))
            .Returns(Task.CompletedTask)
            .Verifiable();

            var context = new TestCommandContext();
            var command = new ConfigureCommand(context, configService.Object);

            await command.ExecuteAsync(true);

            configService.Verify(x => x.ConfigureAsync(ConfigurationTarget.System), Times.Once);
        }
Пример #8
0
        public async Task ConfigureCommand_ExecuteAsync_User_InvokesConfigurationServiceConfigureUser()
        {
            var configService = new Mock <IConfigurationService>();

            configService.Setup(x => x.ConfigureAsync(It.IsAny <ConfigurationTarget>()))
            .Returns(Task.CompletedTask)
            .Verifiable();

            var context = new TestCommandContext();

            string[] cmdArgs = { "configure" };
            var      command = new ConfigureCommand(configService.Object);

            await command.ExecuteAsync(context, cmdArgs);

            configService.Verify(x => x.ConfigureAsync(ConfigurationTarget.User), Times.Once);
        }
Пример #9
0
        public ProjectViewModel(SolutionViewModel solutionViewModel, IProject model)
            : base(model)
        {
            shell = IoC.Get <IShell>();

            Items = new ObservableCollection <ProjectItemViewModel>();

            Items.BindCollections(model.Items, p => { return(ProjectItemViewModel.Create(p)); }, (pivm, p) => pivm.Model == p);

            ConfigureCommand = ReactiveCommand.Create();

            ConfigureCommand.Subscribe(o =>
            {
                if (configuration == null)
                {
                    configuration = new ProjectConfigurationDialogViewModel(model, () =>
                    {
                        configuration = null;
                    });

                    shell.AddDocument(configuration);
                }
                else
                {
                    shell.SelectedDocument = configuration;
                }
                //shell.ModalDialog.ShowDialog();
            });

            DebugCommand = ReactiveCommand.Create();
            DebugCommand.Subscribe(_ =>
            {
                //shell.Debug(model);
            });

            BuildCommand = ReactiveCommand.Create();
            BuildCommand.Subscribe(o => { shell.Build(model); });

            CleanCommand = ReactiveCommand.Create();

            CleanCommand.Subscribe(o => { shell.Clean(model); });

            ManageReferencesCommand = ReactiveCommand.Create();

            ManageReferencesCommand.Subscribe(o => { });

            SetProjectCommand = ReactiveCommand.Create();

            SetProjectCommand.Subscribe(o =>
            {
                model.Solution.StartupProject = model;
                model.Solution.Save();

                shell.InvalidateCodeAnalysis();

                foreach (var project in solutionViewModel.Projects)
                {
                    project.Invalidate();
                }
            });

            OpenInExplorerCommand = ReactiveCommand.Create();
            OpenInExplorerCommand.Subscribe(o => { Process.Start(Model.CurrentDirectory); });

            NewItemCommand = ReactiveCommand.Create();
            NewItemCommand.Subscribe(_ =>
            {
                shell.ModalDialog = new NewItemDialogViewModel(model);
                shell.ModalDialog.ShowDialog();
            });

            RemoveCommand = ReactiveCommand.Create();
            RemoveCommand.Subscribe(async o =>
            {
                await shell.CloseDocumentsForProjectAsync(Model);
                Model.Solution.RemoveProject(Model);
                Model.Solution.Save();
            });
        }
Пример #10
0
        /// <summary>
        /// Initalize values.
        /// </summary>
        public NavBarViewModel()
            : base("Nav")
        {
            _pm          = IoC.Get <PulseManager>();
            _events      = IoC.Get <IEventAggregator>();
            _adcpConn    = IoC.Get <AdcpConnection>();
            _IsRecording = false;
            this.NotifyOfPropertyChange(() => this.IsRecording);

            // Set the record image
            SetRecorderImage();

            // Warning timer
            _recorderTimer           = new System.Timers.Timer();
            _recorderTimer.Interval  = 2000;               // 2 seconds.
            _recorderTimer.Elapsed  += _recorderTimer_Elapsed;
            _recorderTimer.AutoReset = true;
            _recorderTimer.Start();

            // Command to go back a view
            BackCommand = ReactiveCommand.Create();
            BackCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.Back)));

            // Command to go to Home View
            HomeCommand = ReactiveCommand.Create();
            HomeCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.HomeView)));

            // Command to go to SmartPage View
            ConfigureCommand = ReactiveCommand.Create();
            ConfigureCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.SmartPageView)));

            // Command to go to ViewData View
            ViewDataCommand = ReactiveCommand.Create();
            ViewDataCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.ViewDataView)));

            //// Command to go to Playback data
            //PlaybackCommand = ReactiveCommand.Create();
            //PlaybackCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.SelectPlaybackView)));

            // Select a file to playback
            PlaybackCommand = ReactiveCommand.Create();
            PlaybackCommand.Subscribe(_ => PlaybackFile());

            // Command to go to ScreenData View
            ScreenDataCommand = ReactiveCommand.Create();
            ScreenDataCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.ScreenDataView)));

            // Command to go to Project View
            ProjectCommand = ReactiveCommand.Create();
            ProjectCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.ProjectView)));

            // Command to go to VesselMount Options View
            VmOptionsCommand = ReactiveCommand.Create();
            VmOptionsCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.VesselMountOptionsView)));

            // Command to go to Data Format View
            DataFormatCommand = ReactiveCommand.Create();
            DataFormatCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.DataFormatView)));

            // Command to go to VesselMount Options View
            AveragingCommand = ReactiveCommand.Create();
            AveragingCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.AveragingView)));

            // Set the Clock time to Local System time on the ADCP
            StartTestingCommand = ReactiveCommand.CreateAsyncTask(this.WhenAny(x => x.IsTesting, x => !x.Value),
                                                                  _ => Task.Run(() => On_StartTesting()));

            // Create a command to stop testing
            StopTestingCommand = ReactiveCommand.CreateAsyncTask(this.WhenAny(x => x.IsTesting, x => x.Value),
                                                                 _ => Task.Run(() => On_StopTesting()));
        }
Пример #11
0
 public void Handle(ConfigureCommand cmd)
 {
     throw new NotImplementedException();
 }
Пример #12
0
 // methods ////////////////////////////////////////////////////////////////////////////////
 public void AddConfigureCommand(ConfigureCommand command)
 {
     Commands.Push(command);
 }