Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainWindow"/> class.
        /// Executes dependency injection and sets the data context.
        /// </summary>
        public MainWindow()
        {
            this.InitializeComponent();

            IHost host = Host.CreateDefaultBuilder()
                         .ConfigureLogging(logging =>
            {
                logging.AddSerilog(new LoggerConfiguration().WriteTo.Debug(Serilog.Events.LogEventLevel.Debug).WriteTo.Console().WriteTo.File(System.IO.Path.GetFullPath(System.IO.Path.Combine(AppContext.BaseDirectory, "..\\..\\..\\")) + "log.txt").CreateLogger());
            })
                         .ConfigureServices(services =>
            {
                services.AddSingleton <ClientVM>();
                services.AddSingleton <Services.UrlService>();
            }).Build();

            this.client = host.Services.GetService <ClientVM>();

            this.DataContext         = this.client;
            this.client.BotMode      = true;
            this.client.ClientPlayer = new PlayerVM(new Player("Human"));
            this.client.StartNewBotgame();
        }
Exemplo n.º 2
0
        public MainWindow(int userID, string playerName, string token)
        {
            this.InitializeComponent();

            IHost host = Host.CreateDefaultBuilder()
                         .ConfigureLogging(logging =>
            {
                logging.AddSerilog(new LoggerConfiguration().WriteTo.Debug(Serilog.Events.LogEventLevel.Debug).WriteTo.Console().WriteTo.File(System.IO.Path.GetFullPath(System.IO.Path.Combine(AppContext.BaseDirectory, "..\\..\\..\\")) + "log.txt").CreateLogger());
            })
                         .ConfigureServices(services =>
            {
                services.AddSingleton <ClientVM>();
                services.AddSingleton <Services.UrlService>();
            }).Build();

            this.client = host.Services.GetService <ClientVM>();

            this.DataContext     = this.client;
            this.client.ClientId = userID;
            this.client.Token    = token;
            this.client.SetupCommand.Execute(new object());
            this.client.ClientPlayer = new PlayerVM(new Player(playerName));
            this.client.ConnectCommand.Execute(new { });
        }