Ejemplo n.º 1
0
        void _chat_LoginCharlistEvent(Vha.Net.Chat chat, LoginChararacterListEventArgs e)
        {
            // Only fire the character selection event when no character has been pre-selected
            if (string.IsNullOrEmpty(chat.Character))
            {
                // Create event arguments
                List <Character> characters = new List <Character>();
                Dictionary <Character, LoginCharacter> charactersMap = new Dictionary <Character, LoginCharacter>();
                foreach (LoginCharacter c in e.CharacterList)
                {
                    Character character = new Character(c.Name, c.ID, c.Level, c.IsOnline);
                    characters.Add(character);
                    charactersMap.Add(character, c);
                }
                SelectCharacterEventArgs args = new SelectCharacterEventArgs(characters.ToArray());
                // Fire event
                if (this.SelectCharacterEvent != null)
                {
                    this.SelectCharacterEvent(this, args);
                }
                // Login
                if (args.Character != null && charactersMap.ContainsKey(args.Character))
                {
                    this._character   = args.Character.Name;
                    this._characterID = args.Character.ID;
                    this._chat.SendLoginCharacter(charactersMap[args.Character]);

                    // Mark as 'recently used'
                    OptionsAccount acc = this.Options.GetAccount(this.Account, true);
                    acc.Name      = this.Options.LastAccount = this._account;
                    acc.Dimension = this.Options.LastDimension = this._dimension;
                    acc.Character = this._character;
                    this.Options.Save();
                }
                else
                {
                    // If no character was selected, there's no reason to remain connected
                    this._chat.Disconnect(true);
                    return;
                }
            }
        }
Ejemplo n.º 2
0
        private void _context_SelectCharacterEvent(Context context, SelectCharacterEventArgs args)
        {
            // Run this method locally
            if (this.InvokeRequired)
            {
                this.Invoke(
                    new Handler <SelectCharacterEventArgs>(_context_SelectCharacterEvent),
                    new object[] { context, args });
                return;
            }
            // Early out
            if (args.Characters.Length == 0)
            {
                return;
            }
            if (this._statusForm == null)
            {
                return;
            }
            // Hide current form
            this._statusForm.DialogResult = DialogResult.OK;
            this._statusForm.Hide();
            this._statusForm = null;
            this.Hide();
            // Show character selection dialog
            this._selectionForm = new SelectionForm(context, args.Characters);
            DialogResult result = this._selectionForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                // Select character
                args.Character = this._selectionForm.Character;
            }
            else
            {
                // Return to authentication screen
                this.Show();
            }
            this._selectionForm = null;
        }