Example #1
0
        /// <summary>
        /// Constructor. Takes the window owner and the chat associated 
        /// with this chat control.
        /// </summary>
        /// <param name="owner">Window owner</param>
        /// <param name="chat"></param>
        public ChatControl(MainWindow owner, UIChat chat)
        {
            InitializeComponent();

            this.Owner = owner;
            this.DataContext = chat;
            this.lvMessages.ItemsSource = chat.Messages;
            chat.Messages.CollectionChanged += new NotifyCollectionChangedEventHandler(Messages_CollectionChanged);
            chat.Close += new EventHandler(chat_Close);
        }
Example #2
0
        /// <summary>
        /// Adds a new tab to the main tab control.
        /// </summary>
        /// <param name="chat">Chat to add.</param>
        public void AddChatTab(UIChat chat)
        {
            // create new chat control
            ChatControl chatControl = new ChatControl(this, chat);

            // create new tab
            TabItem tabItem = new TabItem
            {
                Name = chat.Name.Trim('#'),
                Header = chat.Name,
                Content = chatControl
            };

            // add to tabs
            tbChatrooms.Items.Add(tabItem);

            // select it if first tab added
            if (tbChatrooms.Items.Count == 1)
                tabItem.IsSelected = true;
        }