Exemplo n.º 1
0
        /// <summary>
        /// Initializes the form and sets event listeners
        /// </summary>
        public MainWindow()
        {
            _config = new Config();

            // Web client setup
            var webClient = new WebClient {
                Encoding = System.Text.Encoding.UTF8
            };

            webClient.Headers.Add("user-agent", $"{_config.ProgramTitle} {_config.ProgramVersion}");
            ServicePointManager.SecurityProtocol =
                SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

            // Define event handlers
            ClipboardNotification.ClipboardUpdate += Event_clipboard;
            MouseHook.MouseAction += Event_mouse;

            // Initialize the UI components
            InitializeComponent();

            // Set objects that need to be accessed from outside
            _console = console_window;

            // Object setup
            _settingsWindow = new SettingsWindow(_config, Log);
            _priceManager   = new PriceManager(_config, webClient, Log);
            _priceBox       = new PriceboxWindow();
            var updateWindow = new UpdateWindow(_config, webClient, Log);

            _leagueManager = new LeagueManager(_config, webClient, Log);

            // Set window title
            Title = $"{_config.ProgramTitle} {_config.ProgramVersion}";
            Log($"{_config.ProgramTitle} {_config.ProgramVersion} by Siegrest");

            Task.Run(() =>
            {
                // Check for updates
                updateWindow.Run();
                // Query PoE API for active league list and add them to settings selectors
                UpdateLeagues();
            });
        }