コード例 #1
0
        private readonly SequenceDiceMainGameClass _mainGame; //if we don't need, delete.

        public SequenceDiceMainViewModel(CommandContainer commandContainer,
                                         SequenceDiceMainGameClass mainGame,
                                         SequenceDiceVMData model,
                                         BasicData basicData,
                                         TestOptions test,
                                         IGamePackageResolver resolver,
                                         IStandardRollProcesses roller
                                         )
            : base(commandContainer, mainGame, model, basicData, test, resolver, roller)
        {
            _mainGame = mainGame;
        }
コード例 #2
0
 public EightOffSolitaireMainViewModel(IEventAggregator aggregator,
                                       CommandContainer command,
                                       IGamePackageResolver resolver
                                       )
     : base(aggregator, command, resolver)
 {
     GlobalClass.MainModel    = this;
     ReservePiles1            = new ReservePiles(command);
     ReservePiles1.Maximum    = 8;
     ReservePiles1.AutoSelect = HandObservable <SolitaireCard> .EnumAutoType.SelectOneOnly;
     ReservePiles1.Text       = "Reserve Pile";
 }
        public void TestCommandDispatchEmptyLine()
        {
            var inputReaderMock = new Mock <IInputReader>();
            // Create a fake command. We want to test if it is executed.
            //
            var commandMock = new Mock <ICommand>();

            // Let accept return false always.
            //
            commandMock.Setup(x => x.Accept(
                                  It.IsAny <string>(),
                                  It.IsAny <List <string> >()))
            .Returns(false);

            var commandContainer = new CommandContainer(inputReaderMock.Object);

            commandContainer.AddCommand(commandMock.Object);

            // Define our MOCK functionality of the StartInputLoop method. If this method is called
            // our MOCK will act as a user providing a single input.
            //
            inputReaderMock
            .Setup(x => x.StartInputLoop()).Raises((x) =>
                                                   // Notice this += is a trick the Mock library uses to fire events.
                                                   x.InputEntered += null, this, new InputReadEventArgs(""));

            // Start the fake input loop, this will simulate a user input of "unknown command".
            // We expect the commandMock to not accept the input. The MOCK library will remember what happened.
            //
            inputReaderMock.Object.StartInputLoop();

            // We now check if our methods were called with the correct input. We tested what would happen if
            // the user entered "unknown command".
            // We expect that Accept() was called on the command mock once, and Execute() never.
            //

            // Set up the Execute() method of the mock, we expect it to be never called in this test.
            //
            commandMock.Verify(x =>
                               x.Execute(It.IsAny <List <string> >()), // The It class can be used to check the parameters supplied to the method.
                               Times.Never);                           // We expect the execute to not be called for the wrong command.

            // Set up the mock for the Accept() method and add some constraints we expect on the parameter.
            // This lets us test with what parameters and how often a method was called.
            //
            commandMock.Verify(x => x.Accept(
                                   // Tests the first parameter is not null
                                   It.IsNotNull <string>(),
                                   // Test the second parameter is an empty list
                                   It.Is <List <string> >((input) => input != null && input.Count == 0)),
                               Times.Once // We expect this method to be called exactly once.
                               );
        }
コード例 #4
0
    public void CommandContainer_BindGeneric()
    {
        // Arrange
        var container = new DiContainer();

        // Act
        var commandContainer = new CommandContainer(container);
        var actual           = commandContainer.Bind <CommandTest>();

        //Assert
        Assert.IsNotNull(actual);
    }
コード例 #5
0
 public ChooseGenderViewModel(CommandContainer commandContainer, LifeBoardGameVMData model, IGenderProcesses processes, LifeBoardGameGameContainer gameContainer)
 {
     CommandContainer = commandContainer;
     _model           = model;
     _processes       = processes;
     _gameContainer   = gameContainer;
     _gameContainer.SelectGenderAsync = _processes.ChoseGenderAsync;
     _processes.SetInstructions       = (x => Instructions = x);
     _processes.SetTurn = (x => Turn = x); //has to set delegates before init obviously.
     _model.GenderChooser.ItemClickedAsync += GenderChooser_ItemClickedAsync;
     //_processes.Init();
 }
コード例 #6
0
    public void CommandContainer_UnbindGeneric_ReturnFalse()
    {
        // Arrange
        var container = new DiContainer();

        // Act
        var commandContainer = new CommandContainer(container);
        var actual           = commandContainer.Unbind <CommandTest>();

        //Assert
        Assert.IsFalse(actual);
    }
コード例 #7
0
        private readonly ConnectTheDotsVMData _model;           //if we don't need, delete.

        public ConnectTheDotsMainViewModel(CommandContainer commandContainer,
                                           ConnectTheDotsMainGameClass mainGame,
                                           ConnectTheDotsVMData model,
                                           BasicData basicData,
                                           TestOptions test,
                                           IGamePackageResolver resolver
                                           )
            : base(commandContainer, mainGame, model, basicData, test, resolver)
        {
            _mainGame = mainGame;
            _model    = model;
        }
コード例 #8
0
 public MinesweeperMainViewModel(IEventAggregator aggregator,
                                 CommandContainer commandContainer,
                                 IGamePackageResolver resolver,
                                 LevelClass level
                                 )
 {
     _aggregator = aggregator;
     LevelChosen = level.Level; //at this point, can't choose level because its already chosen.
     this.PopulateMinesNeeded();
     CommandContainer = commandContainer;
     _mainGame        = resolver.ReplaceObject <MinesweeperMainGameClass>(); //hopefully this works.  means you have to really rethink.
 }
 public PickelCardGameMainViewModel(CommandContainer commandContainer,
                                    PickelCardGameMainGameClass mainGame,
                                    PickelCardGameVMData viewModel,
                                    BasicData basicData,
                                    TestOptions test,
                                    IGamePackageResolver resolver
                                    )
     : base(commandContainer, mainGame, viewModel, basicData, test, resolver)
 {
     _model = viewModel;
     _model.Deck1.NeverAutoDisable = true;
 }
コード例 #10
0
 public GameBoardCP(CommandContainer container,
                    IAsyncDelayer delayer,
                    LottoDominosVMData model
                    ) : base(container)
 {
     Columns  = 7;
     Rows     = 4;
     _delayer = delayer;
     _model   = model;
     Text     = "Dominos"; //just do here since its inherited anyways.
     Visible  = true;      //hopefully no problem because if the view model is not shown, this won't show up anyways.
 }
コード例 #11
0
        //will never show game over.

        public FroggiesMainViewModel(IEventAggregator aggregator,
                                     CommandContainer commandContainer,
                                     IGamePackageResolver resolver,
                                     LevelClass level
                                     )
        {
            _aggregator      = aggregator;
            StartingFrogs    = level.NumberOfFrogs;
            NumberOfFrogs    = level.NumberOfFrogs;
            CommandContainer = commandContainer;
            _mainGame        = resolver.ReplaceObject <FroggiesMainGameClass>(); //hopefully this works.  means you have to really rethink.
        }
コード例 #12
0
        public async ValueTask Invoke(CommandArgument argument)
        {
            var currentArgument = argument;

            if (argument.Command == null)
            {
                if (!CommandContainer.TryAssignCommand(argument, out var nextArgument))
                {
                    Logger.LogWarning($"Unknown command {argument.Command}");
                    return;
                }
                else
                {
                    currentArgument = nextArgument;
                }
            }

            if (currentArgument.Command == "help" && CurrentScope.TryResolve <ICommandHelp>(out var help))
            {
                help.HandleHelp(argument);
                return;
            }

            if (!commandHandlers.TryGetValue(currentArgument.Command, out var handlerInfo) || handlerInfo == null)
            {
                Logger.LogWarning($"Unknown command {argument.Command}");
                return;
            }
            object ret;

            if (handlerInfo.CommandHandler.GetParameters().Length == 0)
            {
                ret = handlerInfo.CommandHandler.Invoke(CommandContainer, null);
            }
            else
            {
                var parser = parsers[handlerInfo.HandlerParserType];
                ret = handlerInfo.CommandHandler.Invoke(CommandContainer, parser.ParseCommandArgument(argument).ToArray());
            }
            if (ret != null && handlerInfo.IsAwaitable)
            {
                switch (ret)
                {
                case Task task:
                    await task;
                    return;

                case ValueTask valueTask:
                    await valueTask;
                    return;
                }
            }
        }
コード例 #13
0
        public Result CanCommandBeExecuted(CommandContainer args)
        {
            IBotCommand command = _serviceProvider.GetCommand(args.CommandName);

            var    descriptor = command.GetBotCommandDescriptorAttribute();
            Result canExecute = command.CanExecute(args);

            return(canExecute.IsSuccess
                ? Result.Ok()
                : Result.Fail(
                       $"Command [{descriptor.CommandName}] cannot be executed: {canExecute}"));
        }
コード例 #14
0
 public GolfCardGameShellViewModel(IGamePackageResolver mainContainer,
                                   CommandContainer container,
                                   IGameInfo gameData,
                                   BasicData basicData,
                                   IMultiplayerSaveState save,
                                   TestOptions test,
                                   GolfDelegates delegates
                                   )
     : base(mainContainer, container, gameData, basicData, save, test)
 {
     delegates.LoadMainScreenAsync = LoadMainScreenAsync;
 }
コード例 #15
0
 public GameBoardVM(MancalaMainGameClass mainGame,
                    CommandContainer command,
                    BasicData basicData,
                    GameBoardProcesses gameBoard1
                    )
 {
     _mainGame  = mainGame;
     _command   = command;
     _basicData = basicData;
     GameBoard1 = gameBoard1;
     _network   = _basicData.GetNetwork();
 }
コード例 #16
0
        public MillebournesVMData(IEventAggregator aggregator, CommandContainer command)
        {
            Deck1       = new DeckObservablePile <MillebournesCardInformation>(aggregator, command);
            Pile1       = new PileObservable <MillebournesCardInformation>(aggregator, command);
            PlayerHand1 = new HandObservable <MillebournesCardInformation>(command);
            OtherPile   = Pile1;

            Pile2 = new PileObservable <MillebournesCardInformation>(aggregator, command);

            Stops         = new CustomStopWatchCP();
            Stops.MaxTime = 3000;
        }
 public HorseshoeCardGameGameContainer(BasicData basicData,
                                       TestOptions test,
                                       IGameInfo gameInfo,
                                       IAsyncDelayer delay,
                                       IEventAggregator aggregator,
                                       CommandContainer command,
                                       IGamePackageResolver resolver,
                                       IListShuffler <HorseshoeCardGameCardInformation> deckList,
                                       RandomGenerator random)
     : base(basicData, test, gameInfo, delay, aggregator, command, resolver, deckList, random)
 {
 }
コード例 #18
0
 public ChineseCheckersMainViewModel(CommandContainer commandContainer,
                                     ChineseCheckersMainGameClass mainGame,
                                     ChineseCheckersVMData model,
                                     BasicData basicData,
                                     TestOptions test,
                                     IGamePackageResolver resolver,
                                     GameBoardProcesses gameBoard
                                     )
     : base(commandContainer, mainGame, model, basicData, test, resolver)
 {
     _gameBoard = gameBoard;
 }
コード例 #19
0
 public LottoDominosMainViewModel(CommandContainer commandContainer,
                                  LottoDominosMainGameClass mainGame,
                                  IViewModelData viewModel,
                                  BasicData basicData,
                                  TestOptions test,
                                  IGamePackageResolver resolver
                                  )
     : base(commandContainer, mainGame, viewModel, basicData, test, resolver)
 {
     _mainGame = mainGame;
     _resolver = resolver;
 }
コード例 #20
0
 public YahtzeeHandsDownVMData(IEventAggregator aggregator, CommandContainer command)
 {
     Deck1                  = new DeckObservablePile <YahtzeeHandsDownCardInformation>(aggregator, command);
     Pile1                  = new PileObservable <YahtzeeHandsDownCardInformation>(aggregator, command);
     PlayerHand1            = new HandObservable <YahtzeeHandsDownCardInformation>(command);
     ComboHandList          = new HandObservable <ComboCardInfo>(command);
     ComboHandList.Text     = "Category Cards";
     ChancePile             = new PileObservable <ChanceCardInfo>(aggregator, command);
     ChancePile.Visible     = false;
     ChancePile.CurrentOnly = true;
     ChancePile.Text        = "Chance";
 }
コード例 #21
0
 public ClueBoardGameVMData(CommandContainer command, IGamePackageResolver resolver, IEventAggregator aggregator)
 {
     _command            = command;
     _resolver           = resolver;
     HandList            = new HandObservable <CardInfo>(command);
     HandList.AutoSelect = HandObservable <CardInfo> .EnumAutoType.None;
     HandList.Maximum    = 3;
     HandList.Text       = "Your Cards";
     Pile             = new PileObservable <CardInfo>(aggregator, command);
     Pile.CurrentOnly = true;
     Pile.Text        = "Clue";
 }
コード例 #22
0
 public StockPileVM(CommandContainer command, IEventAggregator aggregator)
 {
     StockFrame          = new BasicMultiplePilesCP <D>(command, aggregator);
     StockFrame.Style    = BasicMultiplePilesCP <D> .EnumStyleList.HasList; // for sure has a list
     StockFrame.Rows     = 1;
     StockFrame.Columns  = 1;
     StockFrame.HasText  = true;
     StockFrame.HasFrame = true;
     StockFrame.LoadBoard();
     StockFrame.PileList.Single().Text = TextToAppear;
     StockFrame.PileClickedAsync += StockFrame_PileClickedAsync;
 }
コード例 #23
0
    public static void EnumSelection(this CommandContainer _container, object _value, Action <object> OnClick, bool foldOut = true)
    {
        Type type = _value.GetType();

        if (!type.IsEnum)
        {
            throw new Exception("Input Must Be Enum!");
        }
        IEnumerable <object> enumNumerable = Enum.GetValues(type).GetEnumerable();

        EnumSelection(_container, enumNumerable.FindIndex(p => p.Equals(_value)), enumNumerable.ToList(obj => obj.ToString()), value => OnClick(Enum.ToObject(type, value)), foldOut);
    }
コード例 #24
0
 public CheckersMainViewModel(CommandContainer commandContainer,
                              CheckersMainGameClass mainGame,
                              CheckersVMData model,
                              BasicData basicData,
                              TestOptions test,
                              IGamePackageResolver resolver
                              )
     : base(commandContainer, mainGame, model, basicData, test, resolver)
 {
     _mainGame  = mainGame;
     _basicData = basicData;
 }
コード例 #25
0
 public CrazyEightsGameContainer(BasicData basicData,
                                 TestOptions test,
                                 IGameInfo gameInfo,
                                 IAsyncDelayer delay,
                                 IEventAggregator aggregator,
                                 CommandContainer command,
                                 IGamePackageResolver resolver,
                                 IListShuffler <RegularSimpleCard> deckList,
                                 RandomGenerator random)
     : base(basicData, test, gameInfo, delay, aggregator, command, resolver, deckList, random)
 {
 }
コード例 #26
0
 public GolfCardGameVMData(IEventAggregator aggregator, CommandContainer command, GolfCardGameGameContainer gameContainer)
 {
     Deck1                 = new DeckObservablePile <RegularSimpleCard>(aggregator, command);
     Pile1                 = new PileObservable <RegularSimpleCard>(aggregator, command);
     PlayerHand1           = new HandObservable <RegularSimpleCard>(command);
     OtherPile             = new PileObservable <RegularSimpleCard>(aggregator, command);
     OtherPile.CurrentOnly = true;
     OtherPile.Text        = "Current";
     HiddenCards1          = new HiddenCards(gameContainer);
     Beginnings1           = new Beginnings(command);
     GolfHand1             = new GolfHand(gameContainer);
 }
コード例 #27
0
 public ClockBoard(IClockVM thisMod,
                   ClockSolitaireMainGameClass mainGame,
                   CommandContainer command,
                   IGamePackageResolver resolver,
                   IEventAggregator aggregator
                   ) : base(thisMod, command, resolver)
 {
     _mainGame   = mainGame;
     _aggregator = aggregator;
     ShowCenter  = true;
     LoadBoard();
 }
        public ScatteringPiecesObservable(CommandContainer command, IGamePackageResolver resolver) : base(command)
        {
            //Visible = true; // the old did not have this.  will always be true here.
            _thisI = resolver.Resolve <IProportionImage>(TagUsed);
            _rs    = resolver.Resolve <RandomGenerator>();
            _thisE = resolver.Resolve <EventAggregator>();

            MethodInfo method = this.GetPrivateMethod(nameof(PrivateClickItemAsync));

            ObjectCommand = new ControlCommand(this, method, command);
            method        = this.GetPrivateMethod(nameof(PrivateBoardClickAsync));
            BoardCommand  = new ControlCommand(this, method, command);
        }
 public BowlingDiceGameMainGameClass(IGamePackageResolver resolver,
                                     IEventAggregator aggregator,
                                     BasicData basic,
                                     TestOptions test,
                                     BowlingDiceGameVMData model,
                                     IMultiplayerSaveState state,
                                     IAsyncDelayer delay,
                                     CommandContainer command,
                                     BasicGameContainer <BowlingDiceGamePlayerItem, BowlingDiceGameSaveInfo> gameContainer
                                     ) : base(resolver, aggregator, basic, test, model, state, delay, command, gameContainer)
 {
     _test = test;
 }
コード例 #30
0
 public ConnectFourMainGameClass(IGamePackageResolver resolver,
                                 IEventAggregator aggregator,
                                 BasicData basic,
                                 TestOptions test,
                                 ConnectFourVMData model,
                                 IMultiplayerSaveState state,
                                 IAsyncDelayer delay,
                                 CommandContainer command,
                                 ConnectFourGameContainer container
                                 ) : base(resolver, aggregator, basic, test, model, state, delay, command, container)
 {
     _command = command;
 }
コード例 #31
0
ファイル: CommandCache.cs プロジェクト: TycTak/TycTak
        public bool Delete(CommandContainer command)
        {
            IEnumerable<CommandContainer> cmds = (from CommandContainer c in _commandList
                                                  where c.ClientId == command.ClientId & c.SessionId == command.SessionId & c.Id == command.Id
                                                  orderby c.Created descending
                                                  select c).Take(1);

            bool commandFound = (cmds.Count() == 1);

            if (commandFound) {
                CommandContainer cmd = cmds.First();
                _commandList.Remove(cmd);
            }

            return commandFound;
        }
コード例 #32
0
ファイル: PlugInProcessor.cs プロジェクト: TycTak/TycTak
        public string ProcessCommand(CommandContainer cmd)
        {
            TTE.Log(cmd);
            //Assembly assembly = Assembly.LoadFrom(@"C:\Users\Mike\SkyDrive\TycTak\Source\TycTak.System\bin\Debug\TycTak.PlugIn.dll");
            //Type type = assembly.GetType("TycTak.PlugIn.System");
            //object instanceOfMyType = Activator.CreateInstance(type);

            //TycTak.Engine.Core sys = new TycTak.Engine.Core();

            //sys.EventProcess += new EventHandler();

            //sys.SaveState(null);

            //int val = sys.SaveState(resource);

            //return val.ToString();
            return null;
        }
コード例 #33
0
ファイル: StatementProcessor.cs プロジェクト: TycTak/TycTak
        public void Execute(UserContainer user, CommandContainer command)
        {
            Log(command);

            PlugInContainer plugIn = PlugInCache.Read(command.PlugInId);

            if (plugIn == null | plugIn.Instance == null) {
                throw new TrappedException(enmMessageCode.NoSuchPluginFound, new object[] { command.PlugInId });
            } else {
                Type typ = plugIn.Instance.GetType();

                MethodInfo methodInfo = typ.GetMethod(command.Method);

                object[] arguments = new object[command.ArgumentList.Count];

                for (int i = 0; i < command.ArgumentList.Count; i++) {
                    arguments[i] = command.ArgumentList[i].Value;
                }

                object payload = methodInfo.Invoke(plugIn.Instance, arguments);

                _messageProcessor.Create(command.ClientId, command.SessionId, command.SourceId, payload);
            }
        }
コード例 #34
0
ファイル: StatementProcessor.cs プロジェクト: TycTak/TycTak
        public CommandContainer Instantiate(string sourceId, string clientId, CommandContainer command)
        {
            Log(sourceId, clientId, command);

            StatementContainer stm = StatementCache.Read(command.Id);

            if (command.ArgumentList.Count != stm.ParameterList.Count) {
                command.Status = enmCommandStatus.IncorrectArgument;
            } else if (stm != null) {
                stm.ClientId = command.ClientId;
                stm.SessionId = command.SessionId;
                stm.Host = command.Host;
                stm.Callback = command.Callback;
                stm.Created = command.Created;
                stm.SourceId = command.SourceId;
                stm.ArgumentList = command.ArgumentList;

                stm.Status = enmCommandStatus.Initialized;

                command = (CommandContainer)stm;
            } else {
                command.Status = enmCommandStatus.NotValid;
            }

            return command;
        }
コード例 #35
0
ファイル: CommandPrompt.cs プロジェクト: darkl/CmdPrompt
 public CommandPrompt(IEnumerable<ICommandDescriptionProvider> providers)
 {
     mContainer = new CommandContainer(providers);
 }
コード例 #36
0
ファイル: CommandProcessor.cs プロジェクト: TycTak/TycTak
 public void Create(CommandContainer command)
 {
     Log(command);
     CommandCache.Create(command);
 }
コード例 #37
0
ファイル: CommandProcessor.cs プロジェクト: TycTak/TycTak
 public bool Undo(CommandContainer command)
 {
     Log(command);
     return false; // CommandController.Undo(command);
 }
コード例 #38
0
ファイル: CommandCache.cs プロジェクト: TycTak/TycTak
 public void Create(CommandContainer command)
 {
     _commandList.Add(command);
 }
コード例 #39
0
ファイル: StatementProcessor.cs プロジェクト: TycTak/TycTak
        // Take list of commands which have now been split and cleaned and produce command objects to execute
        internal ArrayList Instantiate(string[] commands, string clientId, string sessionId, string callBack)
        {
            Log(commands);

            ArrayList commandList = new ArrayList();

            for (int i = 0; (i <= (commands.Length - 1)); i++) {
                string[] parameters = Split(commands[i], true);
                string[] arguments = new string[parameters.Length - 1];

                List<ArgumentContainer> argumentList = new List<ArgumentContainer>();

                for (int x = 1; x < parameters.Length; x++) {
                    argumentList.Add(new ArgumentContainer { Value = parameters[x] });
                }

                if (arguments.Length > 0) Array.Copy(parameters, 1, arguments, 0, arguments.Length);

                string cmdName = parameters[0].ToLower();

                //TODO Not tidy enough need to work on this

                //TODO Need someway to thoroughly test this, maybe send 1000's of commands all different
                //how about system.exec <filename>, this filename is situated on its local drive and
                //has the format of test.scr. The system admin can manually put files in the bin folder.
                bool noEcho = (cmdName.StartsWith("@"));
                if (noEcho) cmdName = (cmdName.Substring(1, cmdName.Length - 1));

                if (callBack == "") callBack = null;

                string host = null;
                bool isRemote = (cmdName.StartsWith("!"));
                if (isRemote) {
                    int t = cmdName.IndexOf(" ");
                    if (t == -1) t = cmdName.Length;
                    host = cmdName.Substring(1, t - 1);
                    cmdName = (cmdName.Substring(t, cmdName.Length - t)).Trim();
                }

                // Arguments = arguments,
                CommandContainer cmd = new CommandContainer { Id = cmdName, SourceId = Config.ClientId, ClientId = clientId, Host = host, SessionId = sessionId, NoEcho = noEcho, Created = DateTime.Now, Status = enmCommandStatus.Waiting, Callback = callBack, ArgumentList = argumentList };

                //if (commandList == null) {
                //    commandList = new Command[1];
                //} else {
                //    Array.Resize(ref commandList, commandList.Length + 1);
                //}

                commandList.Add(cmd);
                //commandList[commandList.Length - 1] = cmd;
            }

            return commandList;
        }
コード例 #40
0
ファイル: MainForm.cs プロジェクト: Letractively/schnell
        public MainForm()
        {
            InitializeComponent();

            _saveFileDialog.Filter = _openFileDialog.Filter;
            _title = Text;

            NamedCommandTable commands = new NamedCommandTable();
            commands.FillStandardCommands();
            _commandProvider.CommandTable = commands;

            CommandContainer cc = new CommandContainer();

            cc.Add(new Command<TextBoxBase>(StandardCommands.Undo,
                delegate(TextBoxBase control) { control.Undo(); },
                delegate(TextBoxBase control) { return !control.ReadOnly && control.CanUndo; }));

            cc.Add(new Command<TextBoxBase>(StandardCommands.Copy,
                delegate(TextBoxBase control) { control.Copy(); },
                delegate(TextBoxBase control) { return control.SelectionLength > 0; }));
            cc.Add(new Command<TextBoxBase>(StandardCommands.Cut,
                delegate(TextBoxBase control) { control.Cut(); },
                delegate(TextBoxBase control) { return !control.ReadOnly && control.SelectionLength > 0; }));
            cc.Add(new Command<TextBoxBase>(StandardCommands.Paste,
                delegate(TextBoxBase control) { control.Paste(); },
                delegate(TextBoxBase control) { return !control.ReadOnly && Clipboard.ContainsText(); }));

            cc.Add(new Command<TextBoxBase>(StandardCommands.SelectAll,
                delegate(TextBoxBase control) { control.SelectAll(); }));

            _commandsByType = new Dictionary<Type, ICommandContainer>();
            _commandsByType.Add(typeof(TextBoxBase), cc);

            _focusWatchdog = new ControlFocusWatchdog();
            _focusWatchdog.Watch(_wikiBox, _htmlBox);

            switch (Settings.Default.NewLine.ToLowerInvariant())
            {
                case "mac":
                case "cr": _newLine = "\r"; break;
                case "windows":
                case "win":
                case "crlf": _newLine = "\r\n"; break;
                case "unix":
                case "lf": _newLine = "\n"; break;
                default: _newLine = Environment.NewLine; break;
            }

            _webBrowser.DocumentCompleted += delegate { _webBrowser.AllowNavigation = false; };
        }