示例#1
0
        /// <summary>
        /// Load XML and accounts, start League client.
        /// </summary>
        private void FrmWidget_Load(object sender, EventArgs e)
        {
            // Setup XML
            if (!System.IO.File.Exists("accounts.xml"))
            {
                var launchDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                xml = XmlConfiguration.CreateConfiguration(launchDir + "/accounts.xml");
            }
            else
            {
                xml = new XmlConfiguration("accounts.xml");
            }

            // Load accounts
            LoadAccounts();

            // Load position data
            // Currently hard-coded positional data for the regular window size (1280x720) and the next 2 available options.
            positionData    = new PositionData[3];
            positionData[0] = new PositionData(1280, 720, 67, 284, 67, 348, 188, 495, 66, 56);
            positionData[1] = new PositionData(1024, 576, 53, 225, 53, 278, 150, 397, 53, 45);
            positionData[2] = new PositionData(1600, 900, 84, 355, 84, 435, 233, 621, 82, 70);

            // Focus on the label to avoid ugly selection
            this.ActiveControl = btnClose;

            // Read shortcutInfo and run the LeagueClient executable.
            string shortcutInfoFile = Application.StartupPath + "/shortcutInfo.txt";
            string leagueClientFile = string.Empty;

            try
            {
                leagueClientFile = System.IO.File.ReadAllText(shortcutInfoFile)
                                   .Replace("\n", string.Empty).Replace("\r", string.Empty);
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occurred while trying to read the shortcutInfo.txt file.\n" + ex.Message);
                Application.Exit();
            }

            try
            {
                Process.Start(leagueClientFile);
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occured while trying to launch the LeagueClient executable.\n" + ex.Message);
            }

            // Start looking for process
            tmrCheckProcess.Start();
        }
        /// <summary>
        /// Load accounts and expand treeview.
        /// </summary>
        private void FrmAccounts_Load(object sender, EventArgs e)
        {
            // Setup XML
            if (!System.IO.File.Exists("accounts.xml"))
            {
                var launchDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                xml = XmlConfiguration.CreateConfiguration(launchDir + "/accounts.xml");
            }
            else
            {
                xml = new XmlConfiguration("accounts.xml");
            }

            // Load accounts
            LoadAccounts();

            // Avoid ugly selection
            this.ActiveControl = lblUI1;
        }