void InvokeAddTab(ChatUser friend, string message)
        {
            if (FindMatchingChatControl(friend.Summary.SteamId) != null) return;

            if (!chatTabs.Dispatcher.CheckAccess())
                chatTabs.Dispatcher.Invoke(() =>
                {
                    var tabItem = new TabItem { Header = friend.Summary.PersonaName };
                    var chatControl = new ChatControl(this, tabItem, ChatHandler, friend);
                    tabItem.Content = chatControl;
                    chatTabs.Items.Add(tabItem);
                    if (!string.IsNullOrEmpty(message))
                        InvokeHandleMessage(chatControl, message);
                    chatTabs.SelectedIndex = chatTabs.Items.Count - 1;
                });
            else
            {
                var tabItem = new TabItem { Header = friend.Summary.PersonaName };
                var chatControl = new ChatControl(this, tabItem, ChatHandler, friend);
                tabItem.Content = chatControl;
                chatTabs.Items.Add(tabItem);
                if (!string.IsNullOrEmpty(message))
                    InvokeHandleMessage(chatControl, message);
                chatTabs.SelectedIndex = chatTabs.Items.Count - 1;
            }
        }
        public ChatControl(ChatWindow window, TabItem containingTab, SteamChatHandler chatHandler, ChatUser friend)
        {
            ContainingTab = containingTab;
            Friend = friend;
            ChatterId = friend.Summary.SteamId;

            _window = window;
            _chatHandler = chatHandler;

            Loaded += ChatControl_Loaded;

            InitializeComponent();
        }
        public void SetFromFriendObject(ChatUser friend)
        {
            Friend = friend;

            SolidColorBrush stateBrush = StateToBrush(friend.State.PersonaState, friend.State.InGame);

            personaName.Text = friend.Summary.PersonaName;
            personaName.Foreground = stateBrush;

            personaState.Text = StateToText(friend.State.PersonaState) + (friend.State.InGame ? " and in-game" : "");
            personaState.Foreground = stateBrush;

            avatarImage.Source = new BitmapImage(new Uri(friend.Summary.AvatarMedium));

            avatarBorder.BorderBrush = stateBrush;

            inGameName.Text = friend.State.InGameName;
            inGameName.Foreground = stateBrush;
        }
 public void AddChatWindow(ChatUser friend, string message)
 {
     InvokeAddTab(friend, message);
 }
        public FriendControl(ChatUser friend)
        {
            InitializeComponent();

            SetFromFriendObject(friend);
        }