Beispiel #1
0
        /// <summary>
        /// Try to download a character XML from the given URI.
        /// </summary>
        /// <param name="uri"></param>
        private void TryUri(string uri)
        {
            m_version++;
            m_args = null;

            // Update controls
            okButton.Enabled   = false;
            namePanel.Visible  = false;
            errorPanel.Visible = false;
            urlThrobber.State  = ThrobberState.Rotating;

            // Starts querying the web or the hard drive, and invokes the given callback on result.
            int version = m_version;

            EveClient.Characters.TryAddOrUpdateFromUriAsync(new Uri(uri), (sender, args) =>
            {
                if (version != m_version)
                {
                    return;
                }

                urlThrobber.State = ThrobberState.Stopped;

                // Was there an error ?
                if (args.HasError)
                {
                    okButton.Enabled   = false;
                    errorPanel.Visible = true;
                    labelError.Text    = args.Error;
                    return;
                }

                nameTextBox.Text  = args.CharacterName;
                namePanel.Visible = true;
                okButton.Enabled  = true;
                m_args            = args;
            });
        }
        /// <summary>
        /// Try to download a character XML from the given URI.
        /// </summary>
        /// <param name="uri"></param>
        private async Task TryUri(string uri)
        {
            m_version++;
            m_args = null;

            // Update controls
            okButton.Enabled   = false;
            namePanel.Visible  = false;
            errorPanel.Visible = false;
            urlThrobber.State  = ThrobberState.Rotating;

            // Starts querying the web or the hard drive, and invokes the given callback on result
            int version = m_version;
            var result  = await GlobalCharacterCollection.TryAddOrUpdateFromUriAsync(new Uri(uri));

            if (version != m_version)
            {
                return;
            }

            urlThrobber.State = ThrobberState.Stopped;

            // Was there an error ?
            if (result.HasError)
            {
                okButton.Enabled   = false;
                errorPanel.Visible = true;
                labelError.Text    = result.Error;
                return;
            }

            nameTextBox.Text  = result.CharacterName;
            namePanel.Visible = true;
            okButton.Enabled  = true;
            m_args            = result;
        }