/// <summary>
 /// Removes the provided character for the uri characters
 /// </summary>
 /// <param name="character">The character to remove</param>
 /// <exception cref="InvalidOperationException">This character does not have that identity</exception>
 public void Remove(UriCharacter character)
 {
     if (!m_uriCharacters.Remove(character))
     {
         throw new InvalidOperationException("This source does not belong to this character's sources");
     }
     EveClient.OnCharacterCollectionChanged();
 }
        /// <summary>
        /// Addsa new UriCharacter with the specified Uri and deserialization object, then returns it
        /// </summary>
        /// <param name="uri">The source uri</param>
        /// <param name="result">The deserialization object acquired from the given uri</param>
        /// <returns>The created character, or null if there was errors on the provided CCP data.</returns>
        internal UriCharacter Add(Uri uri, APIResult <SerializableAPICharacterSheet> result)
        {
            if (result.HasError)
            {
                return(null);
            }

            var character = new UriCharacter(m_characterID, uri, result);

            m_uriCharacters.Add(character);

            EveClient.OnCharacterCollectionChanged();
            return(character);
        }
Esempio n. 3
0
        /// <summary>
        /// Updates the given character.
        /// </summary>
        /// <param name="character"></param>
        public void UpdateCharacter(UriCharacter character)
        {
            var identity = GetIdentity(m_result);

            // Updates
            if (m_apiResult != null)
            {
                character.Update(identity, m_uri, m_apiResult);
            }
            else
            {
                var ccpCharacter = m_result as SerializableCCPCharacter;
                character.Update(identity, m_uri, ccpCharacter);
            }
        }
        /// <summary>
        /// Constructor to update a character.
        /// </summary>
        public CharacterImportationWindow(UriCharacter character)
        {
            InitializeComponent();
            errorPanel.Visible = false;
            namePanel.Visible = false;
            okButton.Enabled = false;

            m_character = character;
            if (m_character.Uri.IsFile)
            {
                fileTextBox.Text = m_character.Uri.ToString();
                fileRadio.Checked = true;
            }
            else
            {
                urlTextBox.Text = m_character.Uri.ToString();
                urlRadio.Checked = true;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Creates the character.
        /// </summary>
        public UriCharacter CreateCharacter()
        {
            var identity = GetIdentity(m_result);

            // Instantiates characters, adds, notify
            UriCharacter uriCharacter;

            if (m_apiResult != null)
            {
                uriCharacter = new UriCharacter(identity, m_uri, m_apiResult);
            }
            else
            {
                var ccpCharacter = m_result as SerializableCCPCharacter;
                uriCharacter = new UriCharacter(identity, m_uri, ccpCharacter);
            }

            EveClient.Characters.Add(uriCharacter, true);
            return(uriCharacter);
        }
        /// <summary>
        /// Creates the character.
        /// </summary>
        public UriCharacter CreateCharacter()
        {
            var identity = GetIdentity(m_result);

            // Instantiates characters, adds, notify
            UriCharacter uriCharacter;
            if (m_apiResult != null)
            {
                uriCharacter = new UriCharacter(identity, m_uri, m_apiResult);
            }
            else
            {
                var ccpCharacter = m_result as SerializableCCPCharacter;
                uriCharacter = new UriCharacter(identity, m_uri, ccpCharacter);
            }

            EveClient.Characters.Add(uriCharacter, true);
            return uriCharacter;
        }
        /// <summary>
        /// Updates the given character.
        /// </summary>
        /// <param name="character"></param>
        public void UpdateCharacter(UriCharacter character)
        {
            var identity = GetIdentity(m_result);

            // Updates
            if (m_apiResult != null)
            {
                character.Update(identity, m_uri, m_apiResult);
            }
            else
            {
                var ccpCharacter = m_result as SerializableCCPCharacter;
                character.Update(identity, m_uri, ccpCharacter);
            }
        }
        /// <summary>
        /// When the user clicks the OK button, we may have to generate the character
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void okButton_Click(object sender, EventArgs e)
        {
            // Shouldn't occur but, well...
            if (m_args == null || m_args.HasError)
            {
                DialogResult = DialogResult.Cancel;
                return;
            }

            // Generates or updates the character
            if (m_character == null)
            {
                m_character = m_args.CreateCharacter();
            }
            else
            {
                m_args.UpdateCharacter(m_character);
            }
            
            m_character.Name = nameTextBox.Text;

            DialogResult = DialogResult.OK;
        }