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;
            }
        }
예제 #2
0
        void OnChatMessage(object sender, ChatMessageArgs e)
        {
            ChatControl control = FindMatchingChatControl(IdConversions.AccountIdToUlong(e.ChatMessage.AccountIdFrom));

            if (control == null)
            {
                return;
            }
            InvokeHandleMessage(control, e.ChatMessage.Text);
        }
예제 #3
0
 void InvokeHandleMessage(ChatControl control, string message)
 {
     if (!control.Dispatcher.CheckAccess())
     {
         control.Dispatcher.Invoke(() => { control.HandleMessage(message); });
     }
     else
     {
         control.HandleMessage(message);
     }
 }
예제 #4
0
        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;
            }
        }
 void InvokeHandleMessage(ChatControl control, string message)
 {
     if (!control.Dispatcher.CheckAccess())
         control.Dispatcher.Invoke(() => { control.HandleMessage(message); });
     else
         control.HandleMessage(message);
 }