private void OnServerBtnClick(object sender, RoutedEventArgs e)
        {
            // Set the application mode selected.
            m_appMode = eAppMode.Server;

            // Display appropriate input controls for this mode.
            DisplayAppModeBtns(false);
            DisplayAppModeInput(true);
            m_appModeSelectionLbl.Content = "Server Mode";
            m_connectBtn.Content = "Start";

            m_mainWindow.clientNameLbl.Visibility = Visibility.Hidden;
            m_mainWindow.clientNameTxt.Visibility = Visibility.Hidden;
            m_msgTxt.Visibility = Visibility.Hidden;
            m_sendMsgBtn.Visibility = Visibility.Hidden;

            m_mainWindow.chatBoxScroll.Margin = new Thickness(10);
            m_mainWindow.connectionsLbl.Content = "Connections: 0";
        }
        private UIHandler()
        {
            // Get current application window context.
            m_mainWindow = Application.Current.MainWindow as MainWindow;

            // Get reference to UI elements.
            m_appMode = eAppMode.None;
            m_appModeSelectionGrid = m_mainWindow.modeSelectionGrid;
            m_appModeBtnsGrid = m_mainWindow.appModeBtns;
            m_appModeInputControlsGrid = m_mainWindow.appModeInputControls;
            m_appModeSelectionLbl = m_mainWindow.modeSelectionLbl;
            m_serverModeBtn = m_mainWindow.startServerBtn;
            m_clientModeBtn = m_mainWindow.startClientBtn;
            m_findIPBtn = m_mainWindow.refreshIPBtn;
            m_connectBtn = m_mainWindow.connectBtn;
            m_sendMsgBtn = m_mainWindow.sendBtn;
            m_ipAddressTxt = m_mainWindow.ipAddressTxt;
            m_portTxt = m_mainWindow.portTxt;
            m_chatBox = m_mainWindow.chatBox;
            m_msgTxt = m_mainWindow.messageTxtBox;

            // Subscribe to UI events, button clicks, etc.
            m_serverModeBtn.Click += OnServerBtnClick;
            m_clientModeBtn.Click += OnClientBtnClick;
            m_connectBtn.Click += OnConnectBtnClick;
            m_sendMsgBtn.Click += OnSendBtnClick;
            m_msgTxt.KeyUp += OnMsgTxtBoxKeyUp;

            // Store this machine's IPV4 address.
            m_ipAddressTxt.Text = ResolveIPAddress(Dns.GetHostName()).ToString();
            m_portTxt.Text = "11000";

            m_Messages = new List<ChatMessage>();
        }
        private void OnClientBtnClick(object sender, RoutedEventArgs e)
        {
            // Set the application mode selected.
            m_appMode = eAppMode.Client;

            // Display appropriate input controls for this mode.
            DisplayAppModeBtns(false);
            DisplayAppModeInput(true);
            m_appModeSelectionLbl.Content = "Client Mode";
            m_connectBtn.Content = "Connect";
        }