コード例 #1
0
        public void WriteTextToRTB(string message, sbyte id)
        {
            Run line = new Run(message);

            line.Foreground = new SolidColorBrush(colorsManager.GetColorForID(id));
            line.Typography.StandardSwashes = 2;

            rtbServerMessages.CaretPosition.Paragraph.Inlines.Add(line);

            rtbServerMessages.CaretPosition.Paragraph.Inlines.Add(new Run("\n"));
            try
            {
                rtbServerMessages.ScrollToEnd();
            }
            catch (Exception) { }
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: Kupilif/ChatBox
        public void UpdateConnectionInfo()
        {
            labIP.Content                      = String.Format(TEMPLATE_IP, serverIP);
            labPort.Content                    = String.Format(TEMPLATE_PORT, serverPort);
            labIP.Foreground                   = new SolidColorBrush(colorsManager.ClrIPandPort);
            labPort.Foreground                 = new SolidColorBrush(colorsManager.ClrIPandPort);
            labUsernameText.Foreground         = new SolidColorBrush(colorsManager.ClrLabelText);
            labConnectionStatusText.Foreground = new SolidColorBrush(colorsManager.ClrLabelText);

            if (IsUserConnectedToServer())
            {
                labUsername.Content    = user.userName;
                labUsername.Foreground = new SolidColorBrush(colorsManager.GetColorForID(user.ID));

                tbSendMessage.IsEnabled  = true;
                btnSendMessage.IsEnabled = true;

                if (!user.IsUserBannedForCurrentDialog())
                {
                    labConnectionStatus.Content    = TEMPLATE_CONNECTION_STATUS_ACTIVE;
                    labConnectionStatus.Foreground = new SolidColorBrush(colorsManager.ClrClientStatusActive);
                }
                else
                {
                    labConnectionStatus.Content    = TEMPLATE_CONNECTION_STATUS_BANNED;
                    labConnectionStatus.Foreground = new SolidColorBrush(colorsManager.ClrClientStatusBanned);
                }
            }
            else
            {
                tbSendMessage.IsEnabled  = false;
                btnSendMessage.IsEnabled = false;

                labUsername.Content    = TEMPLATE_NO_USERNAME;
                labUsername.Foreground = new SolidColorBrush(colorsManager.ClrLabelText);

                labConnectionStatus.Content    = TEMPLATE_CONNECTION_STATUS_DISCONNECTED;
                labConnectionStatus.Foreground = new SolidColorBrush(colorsManager.ClrClientStatusDisconnected);
            }

            SetAvaliabiltyOfMenuItems();
        }