public ConsolePresenter(IConsoleView view)
 {
     _view = view;
     _bot = new Bot();
     _player = new Player();
     _player.MoveNeeded += MakeMove;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the ConsoleViewPresenter class.
 /// </summary>
 /// <param name="consoleView">Console view.</param>
 /// <param name="fileWatcherController">FileWatcherController.</param>
 /// <param name="logger">Logger.</param>
 /// <param name="formatter">Log formatter.</param>
 /// <param name="xmlConfigFilePath">Path of the configuration XML file.</param>
 /// <param name="xmlSchemaConfigFilePath">Path of the configuration XML Schema file.</param>
 /// <exception cref="ArgumentNullException">xmlConfigFilePath is null.</exception>
 /// <exception cref="ArgumentNullException">xmlSchemaConfigFilePath is null.</exception>
 public ConsoleViewPresenter(IConsoleView consoleView,
     FileWatcherController fileWatcherController,
     ILogger logger,
     IFormatter formatter,
     string xmlConfigFilePath,
     string xmlSchemaConfigFilePath)
     : base(fileWatcherController, 
            logger,
            formatter)
 {
     if (consoleView == null)
     {
         throw new ArgumentNullException("consoleView",
                                         Resources.ArgumentNullException);
     }
     if (xmlConfigFilePath == null)
     {
         throw new ArgumentNullException("xmlConfigFilePath",
                                         Resources.ArgumentNullException);
     }
     if (xmlSchemaConfigFilePath == null)
     {
         throw new ArgumentNullException("xmlSchemaConfigFilePath",
                                         Resources.ArgumentNullException);
     }
     _consoleView = consoleView;
     _xmlConfigFilePath = xmlConfigFilePath;
     _xmlSchemaConfigFilePath = xmlSchemaConfigFilePath;
     SubscribeToConsoleViewEvents();
 }
Exemplo n.º 3
0
 public SimpleConsoleController(IConsoleView view, ILoggerFactory loggerFactory,
                                ICalculator <LoanInfo, LoanPaymentsInfo> calculator)
 {
     _view       = view;
     _logger     = loggerFactory.CreateLogger <SimpleConsoleController>();
     _calculator = calculator;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the ConsoleViewPresenter class.
 /// </summary>
 /// <param name="consoleView">Console view.</param>
 /// <param name="fileWatcherController">FileWatcherController.</param>
 /// <param name="logger">Logger.</param>
 /// <param name="formatter">Log formatter.</param>
 /// <param name="xmlConfigFilePath">Path of the configuration XML file.</param>
 /// <param name="xmlSchemaConfigFilePath">Path of the configuration XML Schema file.</param>
 /// <exception cref="ArgumentNullException">xmlConfigFilePath is null.</exception>
 /// <exception cref="ArgumentNullException">xmlSchemaConfigFilePath is null.</exception>
 public ConsoleViewPresenter(IConsoleView consoleView,
                             FileWatcherController fileWatcherController,
                             ILogger logger,
                             IFormatter formatter,
                             string xmlConfigFilePath,
                             string xmlSchemaConfigFilePath)
     : base(fileWatcherController,
            logger,
            formatter)
 {
     if (consoleView == null)
     {
         throw new ArgumentNullException("consoleView",
                                         Resources.ArgumentNullException);
     }
     if (xmlConfigFilePath == null)
     {
         throw new ArgumentNullException("xmlConfigFilePath",
                                         Resources.ArgumentNullException);
     }
     if (xmlSchemaConfigFilePath == null)
     {
         throw new ArgumentNullException("xmlSchemaConfigFilePath",
                                         Resources.ArgumentNullException);
     }
     _consoleView             = consoleView;
     _xmlConfigFilePath       = xmlConfigFilePath;
     _xmlSchemaConfigFilePath = xmlSchemaConfigFilePath;
     SubscribeToConsoleViewEvents();
 }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            IGameBoard   board = ...;
            IConsoleView view  = ...;

            //Game Loop
            while (!board.IsFinished)
            {
                //Print Board
                Console.WriteLine(view.BoardToString(board));

                //Print Possible Moves
                Console.WriteLine("Possible moves:");
                IEnumerable <IGameMove> possibleMoves = board.GetPossibleMoves();
                Console.WriteLine(string.Join(",", possibleMoves.Select(view.MoveToString)));

                //Print the current player and input their move.
                Console.WriteLine("It is {0}’s turn.", view.PlayerToString(board.CurrentPlayer));
                Console.WriteLine("Enter a move: ");
                string input = Console.ReadLine();

                // Parse move and check if it's possible/valid
                IGameMove toApply   = view.ParseMove(input);
                IGameMove foundMove = possibleMoves.FirstOrDefault(toApply.Equals);
                if (foundMove == null)
                {
                    Console.WriteLine("Sorry, that move is invalid.");
                }
                else
                {
                    board.ApplyMove(foundMove);
                }
            }
        }
Exemplo n.º 6
0
        protected override void OnViewLoaded(object view)
        {
            base.OnViewLoaded(view);

            _consoleView = (IConsoleView)view;
            //_consoleView.Control.StartProcess("powershell.exe", "-noprofile -executionPolicy remotesigned");
            //_consoleView.Control.StartProcess("cmd", "powershell.exe");
        }
Exemplo n.º 7
0
        protected override void OnViewLoaded(object view)
        {
            base.OnViewLoaded(view);

            _consoleView = (IConsoleView)view;
            //_consoleView.Control.StartProcess("powershell.exe", "-noprofile -executionPolicy remotesigned");
            //_consoleView.Control.StartProcess("cmd", "powershell.exe");
        }
Exemplo n.º 8
0
        public ConsolePresenter(ConsoleView consoleView, IConsoleDao dao)
        {
            Logger.debug("Initalizing Console Presenter.", origin: "ChatMail.ConsolePresenter");
            m_consoleView = consoleView;
            m_consoleDao  = dao;

            Initialize();
        }
Exemplo n.º 9
0
 public ConsoleViewDemo( IConsoleView console )
 {
     Console = console;
       _location = new Point( 0, 0 );
       _log = new StringBuilder();
       GenerateLevel();
       UseBuffer = true;
 }
Exemplo n.º 10
0
 protected override void Awake()
 {
     base.Awake();
     this.Viewer = new ConsoleViewMobile(this);
     if (this.Viewer != null)
     {
         this.Viewer.Awake();
     }
 }
Exemplo n.º 11
0
        public ProjectR()
        {
            _stateSyncer = Factories.RFactory.CreateStateMachineSynchronizer();
            _model       = Factories.RFactory.CreateModel();
            _view        = Factories.RFactory.CreateConsoleView();
            _logic       = Factories.RFactory.CreateLogic();

            ExitHelper.ExitAction = Exit;
        }
Exemplo n.º 12
0
 public void Run(IConsoleView view)
 {
     running = true;
     view.Start();
     while (running)
     {
         view.GetInput();
     }
     view.Finish();
 }
Exemplo n.º 13
0
        public void ChangeToPCView()
        {
#if UNITY_STANDALONE || UNITY_EDITOR
            if (Viewer as ConsoleViewPC == null)
            {
                Viewer = new ConsoleViewPC(this);
                Viewer.OnEnter();
            }
#endif
        }
Exemplo n.º 14
0
        public CheatConsole(DebugSettings debugSettings, IConsoleView consoleView)
        {
            m_consoleView   = consoleView;
            m_debugSettings = debugSettings;

            m_consoleLogEntries = new Queue <string>();
            m_consoleCommands   = new Dictionary <string, List <ConsoleCommand> >();
            m_commandRegistry   = new CommandRegistry(this);

            m_commandRegistry.InitializeConsoleCommands();
        }
Exemplo n.º 15
0
        /// <summary>
        /// Initializes a new instance of the PresenterBuilder class.
        /// </summary>
        /// <param name="consoleView">IConsoleView.</param>
        /// <exception cref="ArgumentNullException">consoleView is null.</exception>
        public PresenterBuilder(IConsoleView consoleView)
        {
            if (consoleView == null)
            {
                throw new ArgumentNullException("consoleView",
                                                Resources.ArgumentNullException);
            }

            _viewType = ViewType.Console;

            _consoleView = consoleView;
        }
Exemplo n.º 16
0
        public ConsoleController(IConsoleView view, IArgsParser <string> argsParser)
        {
            mView = view ?? throw new ArgumentNullException("view");

            mView.ClearOutput();

            mArgsParser = argsParser ?? throw new ArgumentNullException("argsParser");

            mView.OnNewCommandSubmited += _processNewCommand;

            mCommandsTable = new Dictionary <string, IConsoleCommand>();
        }
Exemplo n.º 17
0
        public List(string requestUri, IConsoleView escapeView)
        {
            EscapeView = escapeView;

            var response = httpClient.GetAsync(requestUri).Result;

            if (response.IsSuccessStatusCode)
            {
                var stringContent = response.Content.ReadAsStringAsync().Result;
                listItems = JsonConvert.DeserializeObject <IEnumerable <T> >(stringContent);
            }
        }
Exemplo n.º 18
0
 public SignInForm(IConsoleView escapeView)
     : base(
         requestUri: "token",
         escapeView: escapeView,
         fieldSet: new string[]
 {
     "Username",
     "Password"
 },
         success: "You have signed in!",
         fail: "Failed to sign in. Please try again")
 {
 }
Exemplo n.º 19
0
 public void CreatView(Enum.ViewEnum viewEnum)
 {
     factoryView = AbstractFactoryView.getFactory(viewEnum);
     if (market != null && user != null)
     {
         consoleView = factoryView.GetView(market, user);
     }
     else
     {
         Console.WriteLine("Something goes wrong...");
         Environment.Exit(0);
     }
 }
Exemplo n.º 20
0
        protected override void Awake()
        {
            base.Awake();

#if UNITY_STANDALONE || UNITY_EDITOR
            Viewer = new ConsoleViewPC(this);
#elif UNITY_IPHONE || UNITY_ANDROID || UNITY_BLACKBERRY || UNITY_WP8
            Viewer = new ConsoleViewMobile(this);
#endif

            if (Viewer != null)
            {
                Viewer.Awake();
            }
        }
Exemplo n.º 21
0
        public MainFormPresenter(IMainFormView mainFormView, ITfsHttpClient tfsHttpClient)
        {
            this._mainFormView = mainFormView;

            _consoleView = mainFormView.ConsoleView;
            _toolbarView = mainFormView.ToolbarView;
            _tfsRequestPanelView = mainFormView.TfsRequestPanelView;

            mainFormView.Load += MainFormView_Load;
            mainFormView.FormClosed += MainFormView_FormClosed;

            _toolbarView.StartClicked += ToolbarView_StartClicked;
            _toolbarView.TrashClicked += ToolbarView_TrashClicked;

            _tfsHttpClient = tfsHttpClient;
        }
Exemplo n.º 22
0
 static void Main(string[] args)
 {
     try
     {
         IEnumerable <Type> clsIps = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IConsoleView)));
         IConsoleView       app    = (IConsoleView)Activator.CreateInstance(clsIps.First());
         app.Lanuch(args);
         Environment.Exit(0);
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Application Exception:");
         Debug.WriteLine(ex.Message);
         Debug.WriteLine(ex.StackTrace);
         Environment.Exit(-1);
     }
 }
        /// <summary>
        /// The start game menu.
        /// </summary>
        /// <param name="output">
        /// The output.
        /// </param>
        /// <param name="view">
        /// The console view.
        /// </param>
        /// <param name="timer">
        /// The console timer.
        /// </param>
        public static void StartGameMenu(
            IConsoleWrapper<ConsoleColor, ConsoleKeyInfo> output, 
            IConsoleView view, 
            ConsoleTimer timer)
        {
            EventHandler ev1 =
                (sender, args) =>
                    {
                        gameController =
                            new MinesweeperGameController(
                                MinesweeperGridFactory.CreateNewTable(MinesweeperDifficultyType.Easy),
                                view,
                                timer,
                                LoadPlayers(),
                                MinesweeperDifficultyType.Easy);
                    };

            EventHandler ev2 =
                (sender, args) =>
                    {
                        gameController =
                            new MinesweeperGameController(
                                MinesweeperGridFactory.CreateNewTable(MinesweeperDifficultyType.Medium),
                                view,
                                timer,
                                LoadPlayers(),
                                MinesweeperDifficultyType.Medium);
                    };

            EventHandler ev3 =
                (sender, args) =>
                    {
                        gameController =
                            new MinesweeperGameController(
                                MinesweeperGridFactory.CreateNewTable(MinesweeperDifficultyType.Hard),
                                view,
                                timer,
                                LoadPlayers(),
                                MinesweeperDifficultyType.Hard);
                    };

            EventHandler ev4 = (sender, args) => { StartMainMenu(output); };

            DisplayFourItemsMenu("Easy", "Medium", "Hard", "Back", ev1, ev2, ev3, ev4, output);
        }
Exemplo n.º 24
0
Arquivo: Game.cs Projeto: nrkn/LosvRL
        public Game(IConsoleView console)
        {
            _mapPersistence = new Persistence<Map>();

              if (File.Exists(MapFile))
              {
            _map = _mapPersistence.Load(MapFile);
              }
              else
              {
            _map = new Map();
            var generator = new Generator(_map);
            generator.GenerateLevel();
            _mapPersistence.Save(_map, MapFile);
              }

              Console = console;
              Console.HideCursor();
        }
        public ConsoleViewModel(IConsoleView view, IEventAggregator eventAggregator)
        {
            View             = view;
            View.DataContext = this;

            _eventAggregator  = eventAggregator;
            _stringBuilder    = new StringBuilder();
            _textBoxOutputter = new TextBoxOutputter(_stringBuilder);

            _textBoxOutputter.TextChange += () => Text = _stringBuilder.ToString();

            System.Console.SetOut(_textBoxOutputter);

            _errorTextWriter = System.Console.Error;

            _eventAggregator.GetEvent <ClearLogsEvent>().Subscribe(obj =>
            {
                _stringBuilder.Clear();
                Text = _stringBuilder.ToString();
            });
        }
Exemplo n.º 26
0
 private static void RegisterView(IConsoleView view)
 {
     ConsoleViews.Add(view.Key.ToUpper(), view);
 }
 public MarketInfoDecorator(IConsoleView consoleView, Market.MarketAbstract marketAbstract) : base(consoleView)
 {
     this.marketAbstract = marketAbstract;
 }
Exemplo n.º 28
0
 /// <summary>
 /// The <see cref="ConsolePresenter"/> constructor will receive the <see cref="IConsoleView"/> interface from the
 /// <see cref="Views.Windows.MainTui"/> and couple together with the view.
 /// </summary>
 /// <param name="view"></param>
 public ConsolePresenter(IConsoleView view)
 {
     _view = view;
 }
 private static void RegisterView(IConsoleView view)
 {
     ConsoleViews.Add(view.Key.ToUpper(), view);
 }
Exemplo n.º 30
0
 public Application(IConsoleView view, ISender sender)
 {
     _view   = view;
     _sender = sender;
 }
Exemplo n.º 31
0
 static void RegisterView(IConsoleView view)
 {
     Views.Add(view.Key, view);
 }
Exemplo n.º 32
0
 public Mediator(IConsoleView consoleViewMarket)
 {
     this.consoleViewMarket = consoleViewMarket;
 }
Exemplo n.º 33
0
 public Menu(IConsoleView escapeView)
 {
     EscapeView = escapeView;
 }
Exemplo n.º 34
0
 public ConsoleViewDecorator(IConsoleView consoleView)
 {
     this.consoleView = consoleView;
 }
Exemplo n.º 35
0
 public CategoryMenuNavigator(IConsoleView view)
 {
     View = view;
 }
Exemplo n.º 36
0
 public Form(string requestUri, IConsoleView escapeView, string[] fieldSet)
 {
     this.requestUri = requestUri;
     this.fieldSet   = fieldSet;
     EscapeView      = escapeView;
 }
Exemplo n.º 37
0
        public static void Main(string[] args)
        {
            IGameBoard   board = null;
            IConsoleView view  = null;

            // Use a game name from the command line, or default to chess.
            string gameName = args.Length == 1 ? args[0] : "chess";

            switch (gameName)
            {
            case "othello":
                board = new OthelloBoard();
                view  = new OthelloConsoleView();
                break;

            case "chess":
                board = new ChessBoard();
                view  = new ChessConsoleView();
                break;
            }

            while (!board.IsFinished)
            {
                Console.WriteLine(view.BoardToString(board));

                Console.WriteLine();
                Console.WriteLine("Possible moves:");
                IEnumerable <IGameMove> possMoves = board.GetPossibleMoves();
                Console.WriteLine(string.Join(", ",
                                              possMoves.Select(view.MoveToString)));

                Console.WriteLine("It is {0}'s turn.",
                                  view.PlayerToString(board.CurrentPlayer));
                Console.WriteLine("Enter a command: ");
                string input = Console.ReadLine();

                if (input.StartsWith("move"))
                {
                    IGameMove toApply   = view.ParseMove(input.Substring(5));
                    IGameMove foundMove = possMoves.SingleOrDefault(toApply.Equals);
                    if (foundMove == null)
                    {
                        Console.WriteLine("Sorry, that move is invalid.");
                    }
                    else
                    {
                        board.ApplyMove(foundMove);
                    }
                }
                else if (input.StartsWith("undo"))
                {
                    if (!int.TryParse(input.Split(' ')[1], out int undoCount))
                    {
                        undoCount = 1;
                    }
                    for (int i = 0; i < undoCount && board.MoveHistory.Count > 0; i++)
                    {
                        board.UndoLastMove();
                    }
                }
                else if (input.StartsWith("history"))
                {
                    Console.WriteLine("Move history:");
                    Console.WriteLine(string.Join(Environment.NewLine,
                                                  board.MoveHistory.Reverse().Select(
                                                      m => view.PlayerToString(m.Player) + ":" + view.MoveToString(m))));
                }
                else if (input.StartsWith("advantage"))
                {
                    var adv = board.CurrentAdvantage;
                    if (adv.Player == 0)
                    {
                        Console.WriteLine("No player has an advantage.");
                    }
                    else
                    {
                        Console.WriteLine("{0} has an advantage of {1}.",
                                          view.PlayerToString(adv.Player), adv.Advantage);
                    }
                }

                Console.WriteLine();
                Console.WriteLine();
            }
        }
Exemplo n.º 38
0
 public Presenter(IConsoleView view, IHammingModel model)
 {
     _model = model;
     _view  = view;
 }
Exemplo n.º 39
0
 public FlightService(IScheduleService scheduleService, IConsoleView consoleView)
 {
     _scheduleService = scheduleService;
     _consoleView     = consoleView;
 }