Esempio n. 1
0
        public MainWindow()
        {
#if !DEBUG
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            TaskScheduler.UnobservedTaskException      += TaskScheduler_UnobservedTaskException;
#endif
            {
                ServicePointManager.Expect100Continue = true;
                ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;
            }

            Thread.CurrentThread.Name = "UI Thread";
            Bot            = new BotClient();
            Bot.Connected += Client_Connected;
            Bot.AutoReconnector.StateChanged += Bot_AutoReconnectorStateChanged;
            Bot.PokemonEvolver.StateChanged  += Bot_PokemonEvolverStateChanged;
            Bot.Disconnected      += Bot_ConnectionClosed;
            Bot.LogMessage        += Bot_LogMessage;
            Bot.ColoredLogMessage += Bot_ColoredLogMessage;
            Bot.ClientChanged     += Bot_ClientChanged;
            Bot.StateChanged      += Bot_StateChanged;

            InitializeComponent();

            Bot.PokemonEvolver.IsEnabled  = Bot.Settings.AutoEvolve;
            Bot.AutoReconnector.IsEnabled = Bot.Settings.AutoReconnect;

            FileLog = new FileLogger();

            Team             = new TeamView(Bot);
            ChatCommandsView = new ChatCommandsView(Bot);
            Inventory        = new InventoryView(Bot);
            BattleStat       = new BattleStatView();

            {
                //Drag window things....
                Team.MainWindow       = this;
                BattleStat.MainWindow = this;
                Inventory.MainWindow  = this;
                //End of Drag Window things...
            }

            AddView(Team, TeamContent, TeamTab, true);
            AddView(ChatCommandsView, ChatCommandsContent, ChatTab);
            AddView(Inventory, InventoryContent, InventoryTab);
            AddView(BattleStat, BattleStatsContent, BattleStatTab);

            App.InitializeVersion();

            SetTitle(null);
            LogMessage("Running " + App.Name + " by " + App.Author + ", version " + App.Version);

            if (!string.IsNullOrEmpty(Bot.Settings.LastScript) && File.Exists(Bot.Settings.LastScript))
            {
                LogMessage($"Reloadable Script: {Bot.Settings.LastScript}.\tPress Ctrl+R to reload.");
                ReloadPopup.IsEnabled = true;
                ReloadPopup.Content   = "Reload " + Path.GetFileName(Bot.Settings.LastScript) + "\tCtrl+R";
            }
            else
            {
                ReloadPopup.IsEnabled = false;
                ReloadPopup.Content   = "Reload Script";
                Bot.Settings.LastScript.Clear(); //lol
            }

            Task.Run(() => UpdateClients());
        }
Esempio n. 2
0
        public MainWindow()
        {
#if !DEBUG
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            TaskScheduler.UnobservedTaskException      += TaskScheduler_UnobservedTaskException;
#endif
            {
                ServicePointManager.Expect100Continue = true;
                ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;
            }

            Thread.CurrentThread.Name = "UI Thread";
            Bot = new BotClient();
            Bot.ConnectionOpened             += Bot_ConnectionOpened;
            Bot.ConnectionClosed             += Bot_ConnectionClosed;
            Bot.WebSuccessfullyLoggedIn      += OnWebSuccessfullyLoggedIn;
            Bot.AutoReconnector.StateChanged += Bot_AutoReconnectorStateChanged;
            Bot.PokemonEvolver.StateChanged  += Bot_PokemonEvolverStateChanged;
            Bot.LogMessage        += Bot_LogMessage;
            Bot.ColoredLogMessage += Bot_ColoredLogMessage;
            Bot.ClientChanged     += Bot_ClientChanged;
            Bot.StateChanged      += Bot_StateChanged;

            InitializeComponent();

            Bot.PokemonEvolver.IsEnabled  = Bot.Settings.AutoEvolve;
            Bot.AutoReconnector.IsEnabled = Bot.Settings.AutoReconnect;

            FileLog = new FileLogger();

            _refreshPlayers      = DateTime.UtcNow;
            _refreshPlayersDelay = 5000;

            Team             = new TeamView(Bot, this);
            ChatCommandsView = new ChatCommandsView(Bot);
            Inventory        = new InventoryView(Bot, this);
            BattleStat       = new BattleStatView(this);
            Players          = new PlayersView(Bot, this);


            AddView(Team, TeamContent, TeamTab, true);
            AddView(ChatCommandsView, ChatCommandsContent, ChatTab);
            AddView(Inventory, InventoryContent, InventoryTab);
            AddView(BattleStat, BattleStatsContent, BattleStatTab);
            AddView(Players, PlayersContent, PlayersTab);

            App.InitializeVersion();

            SetTitle(null);
            LogMessage("Running " + App.Name + " by " + App.Author + ", version " + App.Version);
            if (App.IsBeta)
            {
                LogMessage("This is a BETA version. Bugs, crashes and bans might occur.");
                LogMessage("Join the Discord chat for the latest information and to report issues.");
            }

            if (!string.IsNullOrEmpty(Bot.Settings.LastScript) && File.Exists(Bot.Settings.LastScript))
            {
                LogMessage($"Reloadable Script: {Bot.Settings.LastScript}.\tPress Ctrl+R to reload.");
                ReloadPopup.IsEnabled = true;
                ReloadPopup.Content   = "Reload " + Path.GetFileName(Bot.Settings.LastScript) + "\tCtrl+R";
            }
            else
            {
                ReloadPopup.IsEnabled = false;
                ReloadPopup.Content   = "Reload Script";
                Bot.Settings.LastScript.Clear(); //lol
            }

            Task.Run(() => UpdateClients());
        }