public ConsolePresenter(IConsoleView view)
 {
     _view = view;
     _bot = new Bot();
     _player = new Player();
     _player.MoveNeeded += MakeMove;
 }
 /// <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();
 }
示例#3
0
 public SimpleConsoleController(IConsoleView view, ILoggerFactory loggerFactory,
                                ICalculator <LoanInfo, LoanPaymentsInfo> calculator)
 {
     _view       = view;
     _logger     = loggerFactory.CreateLogger <SimpleConsoleController>();
     _calculator = calculator;
 }
示例#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();
 }
示例#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);
                }
            }
        }
        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");
        }
示例#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");
        }
        public ConsolePresenter(ConsoleView consoleView, IConsoleDao dao)
        {
            Logger.debug("Initalizing Console Presenter.", origin: "ChatMail.ConsolePresenter");
            m_consoleView = consoleView;
            m_consoleDao  = dao;

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

            ExitHelper.ExitAction = Exit;
        }
示例#12
0
 public void Run(IConsoleView view)
 {
     running = true;
     view.Start();
     while (running)
     {
         view.GetInput();
     }
     view.Finish();
 }
示例#13
0
        public void ChangeToPCView()
        {
#if UNITY_STANDALONE || UNITY_EDITOR
            if (Viewer as ConsoleViewPC == null)
            {
                Viewer = new ConsoleViewPC(this);
                Viewer.OnEnter();
            }
#endif
        }
示例#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();
        }
示例#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;
        }
        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>();
        }
示例#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);
            }
        }
 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")
 {
 }
示例#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);
     }
 }
示例#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();
            }
        }
示例#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;
        }
示例#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);
        }
示例#24
0
文件: Game.cs 项目: 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();
            });
        }
示例#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;
 }
示例#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);
 }
示例#30
0
 public Application(IConsoleView view, ISender sender)
 {
     _view   = view;
     _sender = sender;
 }
示例#31
0
 static void RegisterView(IConsoleView view)
 {
     Views.Add(view.Key, view);
 }
示例#32
0
 public Mediator(IConsoleView consoleViewMarket)
 {
     this.consoleViewMarket = consoleViewMarket;
 }
示例#33
0
 public Menu(IConsoleView escapeView)
 {
     EscapeView = escapeView;
 }
示例#34
0
 public ConsoleViewDecorator(IConsoleView consoleView)
 {
     this.consoleView = consoleView;
 }
示例#35
0
 public CategoryMenuNavigator(IConsoleView view)
 {
     View = view;
 }
示例#36
0
 public Form(string requestUri, IConsoleView escapeView, string[] fieldSet)
 {
     this.requestUri = requestUri;
     this.fieldSet   = fieldSet;
     EscapeView      = escapeView;
 }
示例#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();
            }
        }
示例#38
0
 public Presenter(IConsoleView view, IHammingModel model)
 {
     _model = model;
     _view  = view;
 }
示例#39
0
 public FlightService(IScheduleService scheduleService, IConsoleView consoleView)
 {
     _scheduleService = scheduleService;
     _consoleView     = consoleView;
 }