/// <summary> /// BnetViewModel's constructor /// </summary> /// <param name="account">BnetAccount passed by AccountViewModel</param> public BnetViewModel(BnetAccount account) { ChatMessages = new ObservableCollection <BnetEvent>(); ChannelList = new ObservableCollection <BnetUser>(); ChannelUsers = new ObservableCollection <BnetUser>(); FriendsList = new ObservableCollection <BnetFriend>(); AutoCompletionEntries = new ObservableCollection <AutoCompletionEntry>(); AutoCompletionEntries.Add(new AutoCompletionEntry() { EntryType = AutoCompletionEntryType.Command, Title = "Reply Command", Description = "Replies to the last person who whispered you.", LiteralText = "/r" }); AutoCompletionEntries.Add(new AutoCompletionEntry() { EntryType = AutoCompletionEntryType.Command, Title = "Reconnect Command", Description = "Reconnects the current account to Battle.net.", LiteralText = "/reconnect" }); AutoCompletionEntries.Add(new AutoCompletionEntry() { EntryType = AutoCompletionEntryType.Command, Title = "Version Command", Description = "Emotes the current bot version.", LiteralText = "/version" }); ChattingStatus = "disconnected"; // Initialize Battle.net stuff bnetAccount = account; // Start listening for messages from BnetConnection Messenger.Default.Register <BnetEvent[]>(this, token, BnetEventReceived); Messenger.Default.Register <BnetFriend>(this, token, BnetFriendReceived); Connect(); }
public static string GetFriendListName(BnetPlayer friend, bool addColorTags) { string fullName = null; BnetAccount account = friend.GetAccount(); if (account != null) { fullName = account.GetFullName(); if ((fullName == null) && (account.GetBattleTag() != null)) { fullName = account.GetBattleTag().ToString(); } } if (fullName == null) { foreach (KeyValuePair <BnetGameAccountId, BnetGameAccount> pair in friend.GetGameAccounts()) { if (pair.Value.GetBattleTag() != null) { fullName = pair.Value.GetBattleTag().ToString(); break; } } } if (addColorTags) { string str2 = !friend.IsOnline() ? "999999ff" : "5ecaf0ff"; return(string.Format("<color=#{0}>{1}</color>", str2, fullName)); } return(fullName); }
/// AccountViewModel Constructor /// <summary> /// </summary> /// <param name="account">The Account passed by the MainWindowViewModel</param> public AccountViewModel(BnetAccount account) { bnetAccount = account; // Initialize our BnetViewModel with the BnetAccount // Note: Strong VM coupling is discouraged, but it makes sense here bnetViewModel = new BnetViewModel(bnetAccount); }
public override bool Equals(object obj) { if (obj == null) { return(false); } BnetAccount account = obj as BnetAccount; if (account == null) { return(false); } return(this.m_id.Equals((BnetEntityId)account.m_id)); }
public BnetAccount Clone() { BnetAccount account = (BnetAccount)base.MemberwiseClone(); if (this.m_id != null) { account.m_id = this.m_id.Clone(); } if (this.m_battleTag != null) { account.m_battleTag = this.m_battleTag.Clone(); } return(account); }
private void CreateAccount(BnetAccountId id, BattleNet.PresenceUpdate update, BnetPlayerChangelist changelist) { BnetAccount account = new BnetAccount(); this.m_accounts.Add(id, account); account.SetId(id); BnetPlayer player = null; if (!this.m_players.TryGetValue(id, out player)) { player = new BnetPlayer(); this.m_players.Add(id, player); BnetPlayerChange change = new BnetPlayerChange(); change.SetNewPlayer(player); changelist.AddChange(change); } player.SetAccount(account); this.UpdateAccount(account, update, changelist); }
public void SetAccount(BnetAccount account) { this.m_account = account; this.m_accountId = account.GetId(); }