public CommandLineArgumentInterpreter(ICommandProvider commandProvider, ICommandNameMatcher commandNameMatcher, ICommandArgumentParser commandArgumentParser, ICommandArgumentNameMatcher commandArgumentNameMatcher)
 {
     this.commandProvider = commandProvider;
     this.commandNameMatcher = commandNameMatcher;
     this.commandArgumentParser = commandArgumentParser;
     this.commandArgumentNameMatcher = commandArgumentNameMatcher;
 }
示例#2
0
        public CommandInputForm(ICommandProvider commandProvider, ICommandHistory history)
        {
            InitializeComponent();
            Width = Screen.PrimaryScreen.Bounds.Width;
            Font = new Font(Gentium.FontFamily, 30, FontStyle.Regular);

            DoubleBuffered = true;
            SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);

            _commandProvider = commandProvider;
            _commandHistory = history;
            _historicCommand = _commandHistory.GetEnumerator();

            _backBrush = new SolidBrush(BackColor);
            _foreBrush = new SolidBrush(Color.FromArgb(255, 10, 40));

            _dropDownForm = new DropDownForm();
            _dropDownForm.Font = Font;
            _dropDownForm.Top = Bottom;

            _mouseHook = new MouseHook();
            _mouseHook.MouseMove += new MouseMoveEventHandler(OnMouseMove);
            _mouseHook.MouseClick += new MouseClickEventHandler(Cancel);

            _inputTextBox.TextChanged += delegate { OnInputChanged(); };
            _inputTextBox.SelectionChanged += delegate { OnInputChanged(); };

            MakeForeground();
        }
示例#3
0
 protected DataAdapter(IDbConnection Connection, ICommandProvider CommandProvider)
 {
     this.Connection = Connection;
     if(string.IsNullOrEmpty(Connection.ConnectionString))
         Connection.ConnectionString = GetConnectionString(this.GetType());
     this.CommandProvider = CommandProvider;
 }
        public DefaultCommandsEditor(ICommandProvider commandProvider, IFeatureRegistry registry, FeaturedCommandCollection defaults)
        {
            CommandProvider = commandProvider;
            DefaultCommands = registry.RegisteredFeatures.Select((features) => new DefaultCommandItemThing(registry, features, defaults));

            InitializeComponent();
        }
示例#5
0
 public UIElement GetEditor(ICommandProvider commandProvider)
 {
     return new AboutEditor {
         DataContext = new {
             PatchingEnvironment = PatchingEnvironment.GetCurrent(),
         }
     };
 }
 public void PopulateCommand(ICommand command, ICommandProvider commandProvider)
 {
     var uploader = (ClipboardUploaderCommand) command;
     uploader.ImageUploader = commandProvider.GetDefaultCommand(CommandFeatures.ImageUploader);
     uploader.UrlShortener = commandProvider.GetDefaultCommand(CommandFeatures.UrlShortener);
     uploader.TextUploader = commandProvider.GetDefaultCommand(CommandFeatures.TextUploader);
     uploader.FileUploader = commandProvider.GetDefaultCommand(CommandFeatures.FileUploader);
 }
示例#7
0
        /// <inheritdoc />
        public override T ToUIElement(ICommandProvider commandProvider = null, IList <StyleModel> styleModels = null)
        {
            T element = base.ToUIElement(commandProvider, styleModels);

            BindProperties(element);

            BindCommands(element, commandProvider);

            return(element);
        }
        public NuGetDocumentViewModel(NuGetViewModel nuGetViewModel, ICommandProvider commands, ITelemetryProvider telemetryProvider)
        {
            _nuGetViewModel    = nuGetViewModel;
            _telemetryProvider = telemetryProvider;
            _restoreLock       = new SemaphoreSlim(1, 1);

            InstallPackageCommand = commands.Create <PackageData>(InstallPackage);

            Initialize();
        }
示例#9
0
        public void ThrowArgumentNullException_WhenPassedCommandProviderIsNull()
        {
            // arrange
            var reader = new Mock <IReaderProvider>();
            var writer = new Mock <IWriterProvider>();
            ICommandProvider commandProvider = null;

            // act and assert
            Assert.Throws <ArgumentNullException>(() => new Engine(reader.Object, writer.Object, commandProvider));
        }
示例#10
0
 public MainViewModel(
     ISettings settings,
     ICommandProvider commandProvider,
     ILogger logger)
     : base(settings.IterationDelay, commandProvider, logger)
 {
     settings.ThrowIfNull(nameof(settings));
     Settings  = settings;
     CellWidth = Settings.CellWidth;
 }
示例#11
0
        private Task ProcessWithHelp(IInput input, IHostContext context, ICommandProvider commandProvider)
        {
            string helpCommand = null;

            if (input.Options.TryGetValue("command", out object commandOption))
            {
                if (commandOption is string)
                {
                    helpCommand = (string)commandOption;
                }
                else if (commandOption is IEnumerable <string> commandEnum)
                {
                    helpCommand = commandEnum.FirstOrDefault();
                }
            }
            if (helpCommand == null)
            {
                foreach (object arg in input.Arguments)
                {
                    if (arg is string)
                    {
                        helpCommand = (string)arg;
                        break;
                    }
                    else if (arg is IEnumerable <string> argEnum)
                    {
                        helpCommand = argEnum.FirstOrDefault();
                        if (helpCommand != null)
                        {
                            break;
                        }
                    }
                }
            }
            if (helpCommand == null)
            {
                context.SetResult(GetCommandsList(commandProvider));
            }
            else
            {
                CommandRecord commandRecord = commandProvider.MatchCommandByName(helpCommand);
                if (commandRecord == null)
                {
                    Exception error = new Exception($"command not found: {helpCommand}");
                    context.Exception = error;
                }
                else
                {
                    string     commandName = commandRecord.Command;
                    MethodInfo entryMethod = commandRecord.CommandEntry;
                    context.SetResult(CommandInfo.GetInfo(commandName, entryMethod));
                }
            }
            return(Task.CompletedTask);
        }
示例#12
0
        public static int Run(string[] args, ICommandProvider commandProvider)
        {
            var parser = new Parser(commandProvider);

            parser.Parse(args);

            var onOptionsParsedExitCode = commandProvider.OnOptionsParsed(parser);

            if (onOptionsParsedExitCode != null)
            {
                return(onOptionsParsedExitCode.Value);
            }

            try
            {
                var result = parser.Run().Result;
                foreach (var i in result)
                {
                    Console.WriteLine(i);
                }
            }
            catch (AggregateException aex)
            {
                int exitCode = ExitCode.Success;

                aex.Handle(exception =>
                {
                    if (exception is NoDefaultCommandException)
                    {
                        Help.PrintHelpMessage(Console.Out, commandProvider);
                        exitCode = ExitCode.HelpDisplayed;
                        return(true);
                    }
                    if (exception is CommandLineException cex)
                    {
                        Console.Error.WriteLine($@"{cex.ErrorMessage}

See {Help.Name} --help"
                                                );
                        exitCode = ExitCode.CommandLineError;
                        return(true);
                    }
                    else
                    {
                        Console.Error.WriteLine(exception);
                        exitCode = ExitCode.UnknownError;
                        return(true);
                    }
                });

                return(exitCode);
            }

            return(ExitCode.Success);
        }
示例#13
0
        private IAssertProvider BuildAssertProvider(ICommandProvider commandProvider)
        {
            var assertProvider = new AssertProvider(commandProvider);

            if (this.ThrowExceptions)
            {
                return(assertProvider.EnableExceptions());
            }

            return(assertProvider);
        }
示例#14
0
        static void AssertCommands(ICommandProvider p)
        {
            Assert.That(p.Commands.Count(), Is.EqualTo(1));
            var c = p.Commands.First();

            Assert.That(c.Name, Is.EqualTo("command"));
            Assert.That(p.Options.Count(), Is.EqualTo(1));
            var o = p.Options.First();

            Assert.That(o.Long, Is.EqualTo("option"));
            Assert.That(o.Short, Is.EqualTo("o"));
        }
示例#15
0
        public MainForm()
        {
            InitializeComponent();

            DirectionManager directionManager = new DirectionManager();

            directionProvider = directionManager;
            commandProvider   = new CommandProvider(directionManager, timerProvider, this);
            borderCollider    = new BorderCollider(borderProvider, directionManager);

            timerProvider.Timer.Tick += Timer_Tick;
        }
示例#16
0
        private List <string> GetCommandsList(ICommandProvider commandProvider)
        {
            List <string> helps = new List <string>();
            string        content;

            foreach (var pair in commandProvider.Commands)
            {
                content = string.Format("{0}\t{1}.{2}", pair.Key, pair.Value.InstanceType.Name, pair.Value.CommandEntry.Name);
                helps.Add(content);
            }
            return(helps);
        }
        public DeveloperConsoleUI(ICommandProvider provider)
        {
            this.provider = provider;
            for (int i = 0; i < visibleLogLines; i++)
            {
                WriteLine("");
            }
            Hide();

            textarea.BackgroundColor = new Color4(0.5f, 0.5f, 0.5f, 0.5f);
            textarea.Size            = new Vector2(TW.Graphics.Form.Form.ClientSize.Width, 200);
        }
示例#18
0
        protected DynamicGridViewModel(
            int iterationDelay,
            ICommandProvider commandProvider,
            ILogger logger)
        {
            logger.ThrowIfNull(nameof(logger));
            Logger = logger;

            commandProvider.ThrowIfNull(nameof(commandProvider));

            this.SetDefaultValues();

            _resizeTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(100),
            };
            _resizeTimer.Tick += ResizeTimerTick;

            IterationDelay = iterationDelay;
            _iterateTimer  = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(IterationDelay),
            };
            _iterateTimer.Tick += IterateTimerTick;

            // create commands
            IterateCommand = new DelegateCommand(Iterate, () => CanIterate)
            {
                IsActive = IsActive
            };
            StartIteratingCommand = new DelegateCommand(StartTimer, () => CanStartIterating)
            {
                IsActive = IsActive
            };
            StopIteratingCommand = new DelegateCommand(StopTimer, () => CanStopIterating)
            {
                IsActive = IsActive
            };
            RestartCommand = new DelegateCommand(Restart, () => CanRestart)
            {
                IsActive = IsActive
            };

            // register command in composite commands
            commandProvider.IterateCommand.RegisterCommand(IterateCommand);
            commandProvider.StartIteratingCommand.RegisterCommand(StartIteratingCommand);
            commandProvider.StopIteratingCommand.RegisterCommand(StopIteratingCommand);
            commandProvider.RestartCommand.RegisterCommand(RestartCommand);

            SetCommandProviderMode(CommandProviderMode.None);
            Logger.Log("DynamicGridViewModel constructor is completed");
        }
示例#19
0
#pragma warning disable CS8618 // Non-nullable field is uninitialized.
        public NuGetDocumentViewModel(NuGetViewModel nuGetViewModel, ICommandProvider commands, ITelemetryProvider telemetryProvider)
#pragma warning restore CS8618 // Non-nullable field is uninitialized.
        {
            _nuGetViewModel    = nuGetViewModel;
            _telemetryProvider = telemetryProvider;
            _restoreLock       = new SemaphoreSlim(1, 1);
            _libraries         = new HashSet <LibraryRef>();
            _packages          = Array.Empty <PackageData>();
            LocalLibraryPaths  = ImmutableArray <string> .Empty;
            RestoreTask        = Task.CompletedTask;

            InstallPackageCommand = commands.Create <PackageData>(InstallPackage);
        }
示例#20
0
        /// <inheritdoc />
        public new void BindProperties(T element, ICommandProvider commandProvider = null,
                                       IList <StyleModel> styleModels = null)
        {
            if (element is null)
            {
                throw new UIException(nameof(element));
            }

            if (!string.IsNullOrWhiteSpace(Source))
            {
                element.Source = new BitmapImage(PathsHelper.GetUriFromRelativePath(Source));
            }
        }
示例#21
0
        public ProgramFeatureRegistry(FeaturedCommandCollection defaultCommands, ICommandProvider commandProvider)
        {
            if (defaultCommands == null) {
                throw new ArgumentNullException("defaultCommands");
            }

            if (commandProvider == null) {
                throw new ArgumentNullException("commandProvider");
            }

            this.defaultCommands = defaultCommands;
            this.commandProvider = commandProvider;
        }
示例#22
0
        /// <inheritdoc />
        public new void BindProperties(T element, ICommandProvider commandProvider = null,
                                       IList <StyleModel> styleModels = null)
        {
            if (element is null)
            {
                throw new UIException(nameof(element));
            }

            //element.BindingGroup = default;
            //element.ContextMenu = default;
            //element.Cursor = default;
            //element.DataContext =
            bool isParsed = Enum.TryParse(FlowDirection, out FlowDirection flowDirection);

            element.FlowDirection = isParsed ? flowDirection : default;

            //Bind focus visual style
            element.FocusVisualStyle = StyleModel.TryGetStyle <Style>(styleModels, FocusVisualStyleId);

            element.ForceCursor         = ForceCursor;
            element.Height              = Height;
            isParsed                    = Enum.TryParse(HorizontalAlignment, out HorizontalAlignment horizontalAlignment);
            element.HorizontalAlignment = isParsed ? horizontalAlignment : default;
            //element.InputScope
            if (!string.IsNullOrWhiteSpace(Language))
            {
                element.Language = XmlLanguage.GetLanguage(Language);
            }
            if (!string.IsNullOrWhiteSpace(LayoutTransform))
            {
                element.LayoutTransform = Transform.Parse(LayoutTransform);
            }
            element.Margin                = new Thickness(Margin);
            element.MaxHeight             = MaxHeight;
            element.MaxWidth              = MaxWidth;
            element.MinHeight             = MinHeight;
            element.MinWidth              = MinWidth;
            element.Name                  = Name;
            element.OverridesDefaultStyle = OverridesDefaultStyle;
            //element.Resources;

            //Bind style
            element.Style = StyleModel.TryGetStyle <Style>(styleModels, StyleId);

            //element.Tag;
            //element.ToolTip;
            element.UseLayoutRounding = UseLayoutRounding;
            isParsed = Enum.TryParse(VerticalAlignment, out VerticalAlignment verticalAlignment);
            element.VerticalAlignment = isParsed ? verticalAlignment : default;
            element.Width             = Width;
        }
示例#23
0
        protected virtual IEnumerable <string> GetTabCompletionCommands(HttpContext context)
        {
            ICommandProvider             commands    = context.RequestServices.GetRequiredService <ICommandProvider>();
            ICommandExecutionEnvironment environment = context.RequestServices.GetRequiredService <ICommandExecutionEnvironment>();

            foreach (ICommand cmd in commands.All(context))
            {
                if (environment.IsTabCompletionEnabled(cmd, context))
                {
                    CommandInfo info = cmd.GetType().GetCommandInfo();
                    yield return(info.Name);
                }
            }
        }
示例#24
0
        /// <summary>
        /// Create the command buttons and set command provider.
        /// </summary>
        /// <param name="cmdProvider">The command provider.</param>
        public void SetCommandProvider(ICommandProvider cmdProvider)
        {
            try
            {
                // Is it another provider one than before?
                if (this.commandProvider != cmdProvider)
                {
                    // If we had already a provider, then unregister from events.
                    if (this.commandProvider != null)
                    {
                        this.commandProvider.CommandAdded   -= this.OnCommandAdded;
                        this.commandProvider.CommandRemoved -= this.OnCommandRemoved;
                    }

                    // No or new provider, so remove all child buttons.
                    foreach (var buttonItem in this.ButtonItems)
                    {
                        buttonItem.Dispose();
                    }

                    this.ButtonItems.Clear();

                    // Set new provider.
                    this.commandProvider = cmdProvider;

                    // New provider?
                    if (this.commandProvider != null)
                    {
                        // Register to events of new provider.
                        this.commandProvider.CommandAdded   += this.OnCommandAdded;
                        this.commandProvider.CommandRemoved += this.OnCommandRemoved;

                        // Add new buttons according to commands of new provider.
                        foreach (var commandItem in this.commandProvider.Commands)
                        {
                            this.ButtonItems.Add(new CommandItemVm(commandItem));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (Logger.IsErrorEnabled)
                {
                    Logger.Error(Resources.CreationOfCommandButtonListFailed, ex);
                }

                throw;
            }
        }
示例#25
0
        /// <summary>
        /// Gets the command for a given unique identifier from a specific command provider.
        /// </summary>
        /// <param name="commandProvider">The command provider to search for the unique identifier.</param>
        /// <param name="uniqueIdentifier">The unique identifier to locate.</param>
        /// <returns>The command, or <c>null</c> if none is found.</returns>
        public static ICommand GetCommandForUniqueIdentifier(this ICommandProvider commandProvider, string uniqueIdentifier)
        {
            ICommand command = null;

            foreach (var commandGroup in commandProvider.CommandGroups)
            {
                command = commandGroup.Commands.OfType <RelayCommand>().FirstOrDefault(c => c.UniqueId == uniqueIdentifier);
                if (command != null)
                {
                    break;
                }
            }
            return(command);
        }
示例#26
0
        public BindingViewModel(
            ICommandProvider cmdProvider,
            IUiNavigation navigation,
            IMessageBoxService messanger,
            IObjectSearcher objectSearcher,
            IResourceService resourceService)
        {
            _subscribersDictionary = new Dictionary <string, CommandChangedEventHandler>();

            _cmdProvider     = cmdProvider;
            _navigation      = navigation;
            _messanger       = messanger;
            _objectSearcher  = objectSearcher;
            _resourceService = resourceService;
        }
示例#27
0
        public SchoolSystemEngine(IUserInterfaceProvider userInterface, ICommandProvider commandProvider)
        {
            if (userInterface == null)
            {
                throw new ArgumentNullException(nameof(userInterface));
            }

            if (commandProvider == null)
            {
                throw new ArgumentNullException(nameof(commandProvider));
            }

            this.userInterface   = userInterface;
            this.commandProvider = commandProvider;
        }
        public void Setup()
        {
            _httpclientFactory = new Mock <IHttpClientFactory>();

            _availableCommands = new List <ICommand>
            {
                new CategoriesCommand(_httpclientFactory.Object),
                new FeaturedProductsCommand(_httpclientFactory.Object),
                new ProductsByCategoryCommand(_httpclientFactory.Object),
                new NotFoundCommand(),
                new QuitCommand()
            };

            _commandProvider = new ShopDemoCommandProvider(_availableCommands);
        }
示例#29
0
        /// <inheritdoc />
        public new void BindProperties(T element, ICommandProvider commandProvider = null,
                                       IList <StyleModel> styleModels = null)
        {
            if (element is null)
            {
                throw new UIException(nameof(element));
            }

            bool isParsed = Enum.TryParse(ClickMode, out System.Windows.Controls.ClickMode clickMode);

            clickMode = isParsed ? clickMode : default;

            element.ClickMode = clickMode;
            //element.Command;
            //element.CommandParameter;
            //element.CommandTarget;
        }
示例#30
0
        public void BeforeEachTest()
        {
            this.sequentialTestExecutionMonitor.WaitOne();

            CommandLineIntegrationTestUtilities.RemoveAllFilesAndFoldersWhichAreCreatedOnStartup();

            StructureMapSetup.Setup();
            this.encodingProvider = ObjectFactory.GetInstance<IEncodingProvider>();
            this.applicationInformation = ObjectFactory.GetInstance<ApplicationInformation>();
            this.commandProvider = ObjectFactory.GetInstance<ICommandProvider>();
            this.userInterface = ObjectFactory.GetInstance<IUserInterface>();
            this.logger = ObjectFactory.GetInstance<IActionLogger>();
            this.commandLineArgumentInterpreter = ObjectFactory.GetInstance<ICommandLineArgumentInterpreter>();
            this.helpCommand = ObjectFactory.GetInstance<IHelpCommand>();

            this.program = new Program(this.applicationInformation, this.userInterface, this.logger, this.commandLineArgumentInterpreter, this.helpCommand);
        }
示例#31
0
        public static ICommand?DefaultCommand(this ICommandProvider commandProvider)
        {
            var c = commandProvider.Commands.ToList();

            if (c.Count == 0)
            {
                return(null);
            }
            else if (c.Count == 1)
            {
                return(c[0]);
            }
            else
            {
                return(c.FirstOrDefault(_ => _.IsDefault));
            }
        }
示例#32
0
        /// <inheritdoc />
        public new void BindProperties(T element, ICommandProvider commandProvider = null, IList <StyleModel> styleModels = null)
        {
            if (element is null)
            {
                throw new UIException(nameof(element));
            }

            element.Background = PropertyParser.ParseBackground(Background);

            //Bind panel's children
            foreach (ChildModel childModel in Children)
            {
                element.Children.Add(childModel.ToUIElement(commandProvider, styleModels));
            }

            element.IsItemsHost = IsItemsHost;
        }
示例#33
0
 public void Building(ICommandProvider commandProvider)
 {
     _provider = commandProvider;
     if (commandProvider == null)
     {
         return;
     }
     if (commandProvider.Menus != null)
     {
         foreach (IItem it in commandProvider.Menus)
         {
             AddUIItem(it);
         }
     }
     if (commandProvider.Toolbars != null)
     {
         foreach (IItem it in commandProvider.Toolbars)
         {
             AddUIItem(it);
         }
     }
     //
     if (_toolstrips != null)
     {
         foreach (ToolStrip ts in _toolstrips)
         {
             SetToolStripStyle(ts);
             _hostForm.Controls.Add(ts);
         }
     }
     if (_toolStripMenuItems != null && _toolStripMenuItems.Count > 0)
     {
         MenuStrip ms = new MenuStrip();
         foreach (ToolStripMenuItem it in _toolStripMenuItems)
         {
             ms.Items.Add(it);
         }
         SetMenuStripStyle(ms);
         _hostForm.Controls.Add(ms);
         _hostForm.MainMenuStrip = ms;
     }
     //先将最近使用过的文件初始化
     InitRecentFiles();
     //
     _uiTimer.Start();
 }
        public virtual void config(ICommandProvider commandProvider)
        {
            commandProvider.CreateConstant("PI", Math.PI);
            commandProvider.CreateConstant("E", Math.E);

            //sufix > prefix > binary
            commandProvider.CreateOperator("+", OperatorType.Binary, 5000, AssociationType.Left, (x, y) => x + y);
            commandProvider.CreateOperator("-", OperatorType.Binary | OperatorType.Prefix, 5000, AssociationType.Left,
                (x, y) => (double.IsNaN(x) ? 0 : x) - y
            );
            commandProvider.CreateOperator("*", OperatorType.Binary, 6000, AssociationType.Left, (x, y) => x * y);
            commandProvider.CreateOperator("/", OperatorType.Binary, 6000, AssociationType.Left, (x, y) => x / y);
            commandProvider.CreateOperator("%", OperatorType.Binary, 7000, AssociationType.Left, (x, y) => (long)x % (long)y);
            commandProvider.CreateOperator("^", OperatorType.Binary, 8000, AssociationType.Right, (x, y) => Math.Pow(x, y));
            commandProvider.CreateOperator("!", OperatorType.Prefix | OperatorType.Suffix, 5000, AssociationType.Right,
                (x, y) =>
                {
                    if (double.IsNaN(y))
                    {
                        double retval = 1;
                        for (int i = (int)x; i > 0; i--)
                            retval *= i;
                        return retval;
                    }
                    else
                    {
                        return y == 0 ? 1 : 0;
                    }

                });
            commandProvider.CreateOperator("=", OperatorType.Binary, 4000, AssociationType.Left, (x, y) => x == y ? 1 : 0);
            commandProvider.CreateOperator("!=", OperatorType.Binary, 4000, AssociationType.Left, (x, y) => x != y ? 1 : 0);
            commandProvider.CreateOperator(">", OperatorType.Binary, 4000, AssociationType.Left, (x, y) => x > y ? 1 : 0);
            commandProvider.CreateOperator(">=", OperatorType.Binary, 4000, AssociationType.Left, (x, y) => x >= y ? 1 : 0);
            commandProvider.CreateOperator("<", OperatorType.Binary, 4000, AssociationType.Left, (x, y) => x < y ? 1 : 0);
            commandProvider.CreateOperator("<=", OperatorType.Binary, 4000, AssociationType.Left, (x, y) => x <= y ? 1 : 0);

            //functions
            commandProvider.CreateFunction("log", args => Math.Log(args[1], args[0]));
            commandProvider.CreateFunction("sin", args => Math.Sin(args[0]));
            commandProvider.CreateFunction("cos", args => Math.Cos(args[0]));
            commandProvider.CreateFunction("tan", args => Math.Tan(args[0]));
            commandProvider.CreateFunction("sum", args => args.Sum());
            commandProvider.CreateFunction("nan", args => double.NaN);
        }
示例#35
0
        /// <inheritdoc />
        public new void BindProperties(T element, ICommandProvider commandProvider = null,
                                       IList <StyleModel> styleModels = null)
        {
            if (element is null)
            {
                throw new UIException(nameof(element));
            }

            foreach (string rowDefinition in RowDefinitions)
            {
                element.RowDefinitions.Add(PropertyParser.ParseRowDefinition(rowDefinition));
            }

            foreach (string columnDefinition in ColumnDefinitions)
            {
                element.ColumnDefinitions.Add(PropertyParser.ParseColumnDefinition(columnDefinition));
            }
        }
示例#36
0
        public MainWindowModel(IUnityContainer container, ISettings settings, ILogger logger)
        {
            container.ThrowIfNull(nameof(container));
            _container       = container;
            _commandProvider = _container.Resolve <ICommandProvider>();

            settings.ThrowIfNull(nameof(settings));
            Settings = settings;

            _logger = logger;

            SettingsCommand   = new DelegateCommand(ExecuteSettings);
            StatisticsCommand = new DelegateCommand(ExecuteStatistics);
            RestartCommand    = new DelegateCommand(
                () => _commandProvider.RestartCommand.Execute(null),
                () => _commandProvider.RestartCommand.CanExecute(null));
            AboutCommand = new DelegateCommand(ExecuteAbout);
        }
示例#37
0
        /// <inheritdoc />
        public virtual T ToUIElement(ICommandProvider commandProvider = null, IList <StyleModel> styleModels = null)
        {
            T element = new T();

            //Bind properties
            BindProperties(element);

            //Bind commands
            BindCommands(element, commandProvider);

            //todo support not only grid
            //Set positions in parent grid
            Grid.SetRow(element, ParentRow);
            Grid.SetColumn(element, ParentColumn);
            Grid.SetRowSpan(element, RowSpan);
            Grid.SetColumnSpan(element, ColumnSpan);

            return(element);
        }
示例#38
0
        private void Start()
        {
            _transform = transform;

            ICommandProvider commandProvider = _isHumanControlled ? ActivateHumanControl() : ActivateAgentControl();
            Animator         animator        = GetComponentInChildren <Animator>();

            _idleStateTrigger      = new CharacterIdleStateTrigger(commandProvider, animator);
            _movingStateTrigger    = new CharacterMovingStateTrigger(commandProvider);
            _attackingStateTrigger = new CharacterAttackingStateTrigger(commandProvider);

            _movementActuator = new CharacterMovementActuator(transform, GetComponent <Rigidbody>(), GetComponent <AgentNavigator>(), GetComponent <IAgentAI>(), GetComponent <SwampCollisionListener>(),
                                                              commandProvider, _configuration);
            _animationActuator = new CharacterAnimationActuator(animator);

            _currentState = CharacterState.Idle;

            FindObjectOfType <TargetOrchestrator>().RegisterBeacon(this);
        }
示例#39
0
 public CommandProcessor(IFactory factory, ITurnProcessor turn, IDataContainer data, ICommandProvider commandProvider)
 {
     this.factory         = factory;
     this.turn            = turn;
     this.data            = data;
     this.commandProvider = commandProvider;
     this.heroSelection   = new Dictionary <string, string>()
     {
         { "1", "CreateAssasin" },
         { "2", "CreateWarrior" },
         { "3", "CreateMage" },
         { "4", "CreateCleric" },
     };
     this.abilitySelection = new Dictionary <string, string>()
     {
         { "1", "SelectBasicAbility" },
         { "2", "SelectDamageAbility" },
         { "3", "SelectEffectAbility" }
     };
 }
示例#40
0
        public static int Main(string[] args)
        {
            if (SingleApplicationInstance.IsAlreadyRunning())
                return 1;

            Application.SetCompatibleTextRenderingDefault(true);
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException, true);
            Application.EnableVisualStyles();

            using (_keyboardHook = new KeyboardHook())
            {
                _capsHook = _keyboardHook.CreateKeyHook(Keys.CapsLock);
                _capsHook.SuppressInput = true;
                _capsHook.KeyDown += new KeyEventHandler(OnCapsKeyDown);
                _capsHook.KeyUp += new KeyEventHandler(OnCapsKeyUp);

                EnsureCapsLockDisabled();

                var thisAssembly = Assembly.GetExecutingAssembly();
                var assemblyCatalog = new AssemblyCatalog(thisAssembly);
                var coreCatalog = new AssemblyCatalog(typeof(ICommand).Assembly);
                var catalog = new AggregateCatalog(assemblyCatalog, coreCatalog);
                var container = new CompositionContainer(catalog);

                // Todo: Hack: Forcing creation of command factories.
                container.GetExportedValues<ICommandFactory>();
                _commandProvider = container.GetExportedValue<ICommandProvider>();

                NotificationForm.Show("Ephemeral");

                Application.Run();
            }

            EnsureCapsLockDisabled();

            return 0;
        }
示例#41
0
 public UIElement GetEditor(ICommandProvider commandProvider)
 {
     return new CommandSettingsEditor();
 }
示例#42
0
 public override ICommandEditor GetCommandEditor(ICommandProvider commandProvider)
 {
     return null;
 }
 public AssertCountSyntaxProvider(ICommandProvider commandProvider, IAssertProvider assertProvider, AssertSyntaxProvider assertSyntaxProvider, int count)
     : this(commandProvider, assertProvider, assertSyntaxProvider, count, false)
 {
 }
 public BaseAssertSyntaxProvider(ICommandProvider commandProvider, IAssertProvider assertProvider)
     : this(commandProvider, assertProvider, null)
 {
 }
 public BaseAssertSyntaxProvider(ICommandProvider commandProvider, IAssertProvider assertProvider, AssertSyntaxProvider assertSyntaxProvider)
 {
     this.commandProvider = commandProvider;
     this.assertProvider = assertProvider;
     this.assertSyntaxProvider = assertSyntaxProvider == null ? (AssertSyntaxProvider)this : assertSyntaxProvider;
 }
 public AssertCountSyntaxProvider(ICommandProvider commandProvider, IAssertProvider assertProvider, AssertSyntaxProvider assertSyntaxProvider, int count, bool notMode)
     : base(commandProvider, assertProvider, assertSyntaxProvider)
 {
     this.count = count;
     this.notMode = notMode;
 }
 public AssertClassSyntaxProvider(ICommandProvider commandProvider, IAssertProvider assertProvider, AssertSyntaxProvider assertSyntaxProvider, string className, bool notMode)
     : base(commandProvider, assertProvider, assertSyntaxProvider)
 {
     this.className = className;
     this.notMode = notMode;
 }
示例#48
0
 public ICommandEditor GetCommandEditor(ICommandProvider commandProvider)
 {
     return new ImageWriterEditor();
 }
示例#49
0
 public ICommandEditor GetCommandEditor(ICommandProvider commandProvider)
 {
     return new SlexyUploaderEditor();
 }
 public AssertValueSyntaxProvider(ICommandProvider commandProvider, IAssertProvider assertProvider, AssertSyntaxProvider assertSyntaxProvider, string value)
     : this(commandProvider, assertProvider, assertSyntaxProvider, value, false)
 {
 }
 public AssertTextSyntaxProvider(ICommandProvider commandProvider, IAssertProvider assertProvider, AssertSyntaxProvider assertSyntaxProvider, string text, bool notMode)
     : base(commandProvider, assertProvider, assertSyntaxProvider)
 {
     this.text = text;
     this.notMode = notMode;
 }
 public AssertTextSyntaxProvider(ICommandProvider commandProvider, IAssertProvider assertProvider, AssertSyntaxProvider assertSyntaxProvider, string text)
     : this(commandProvider, assertProvider, assertSyntaxProvider, text, false)
 {
 }
 public AssertCssPropertySyntaxProvider(ICommandProvider commandProvider, IAssertProvider assertProvider, AssertSyntaxProvider assertSyntaxProvider, string propertyName, string propertyValue, bool notMode)
     : base(commandProvider, assertProvider, assertSyntaxProvider)
 {
     this.propertyName = propertyName;
     this.propertyValue = propertyValue;
     this.notMode = notMode;
 }
 public AssertCssPropertySyntaxProvider(ICommandProvider commandProvider, IAssertProvider assertProvider, AssertSyntaxProvider assertSyntaxProvider, string propertyName, string propertyValue)
     : this(commandProvider, assertProvider, assertSyntaxProvider, propertyName, propertyValue, false)
 {
 }
示例#55
0
 public void PopulateCommand(ICommand command, ICommandProvider commandProvider)
 {
     var imageWriter = (ImageWriter) command;
     imageWriter.Codec = new PngBitmapCodec();
 }
 public AssertValueSyntaxProvider(ICommandProvider commandProvider, IAssertProvider assertProvider, AssertSyntaxProvider assertSyntaxProvider, Expression<Func<string, bool>> matchFunc)
     : this(commandProvider, assertProvider, assertSyntaxProvider, matchFunc, false)
 {
 }
示例#57
0
 public void PopulateCommand(ICommand command, ICommandProvider commandProvider)
 {
     // Do nothing.
 }
 public AssertValueSyntaxProvider(ICommandProvider commandProvider, IAssertProvider assertProvider, AssertSyntaxProvider assertSyntaxProvider, Expression<Func<string, bool>> matchFunc, bool notMode)
     : base(commandProvider, assertProvider, assertSyntaxProvider)
 {
     this.matchFunc = matchFunc;
     this.notMode = notMode;
 }
 public AssertValueSyntaxProvider(ICommandProvider commandProvider, IAssertProvider assertProvider, AssertSyntaxProvider assertSyntaxProvider, string value, bool notMode)
     : base(commandProvider, assertProvider, assertSyntaxProvider)
 {
     this.value = value;
     this.notMode = notMode;
 }
 public NotAssertSyntaxProvider(ICommandProvider commandProvider, IAssertProvider assertProvider, AssertSyntaxProvider assertSyntaxProvider)
     : base(commandProvider, assertProvider, assertSyntaxProvider)
 {
 }