Exemplo n.º 1
0
 private void MessageTimer_Tick(object sender, EventArgs e)
 {
     MessageTextBox.Text = Messages.Text;
     MessageTextBox.Focus();
     MessageTextBox.Select(MessageTextBox.TextLength, 0);
     MessageTextBox.ScrollToCaret();
 }
Exemplo n.º 2
0
 private void AppendMessage(string text)
 {
     //if not disposed
     if (outpuTimer != null)
     {
         MessageTextBox.Text          += text;
         MessageTextBox.SelectionStart = MessageTextBox.Text.Length;
         MessageTextBox.ScrollToCaret();
         MessageTextBox.Visible = true;
     }
 }
Exemplo n.º 3
0
        public async void AsyncDisplayInformation()
        {
            while (true)
            {
                MessageTextBox.Text = Messages.Text;
                if (AutoRollChk.Checked)
                {
                    MessageTextBox.Focus();
                    MessageTextBox.Select(MessageTextBox.TextLength, 0);
                    MessageTextBox.ScrollToCaret();
                }


                await Task.Delay(500);
            }
        }
Exemplo n.º 4
0
        void Chat_Update(ChatMessage message)
        {
            int oldStart  = MessageTextBox.SelectionStart;
            int oldLength = MessageTextBox.SelectionLength;

            MessageTextBox.SelectionStart  = MessageTextBox.Text.Length;
            MessageTextBox.SelectionLength = 0;

            // name, in bold, blue for incoming, red for outgoing
            if (message.System)
            {
                MessageTextBox.SelectionColor = Color.Black;
            }
            else if (Core.Network.Local.Equals(message))
            {
                MessageTextBox.SelectionColor = message.Sent ? Color.Red : Color.LightCoral;
            }
            else
            {
                MessageTextBox.SelectionColor = Color.Blue;
            }

            MessageTextBox.SelectionFont = BoldFont;

            string prefix = " ";

            if (!message.System)
            {
                prefix += Chat.GetNameAndLocation(message);
            }

            if (MessageTextBox.Text.Length != 0)
            {
                prefix = "\n" + prefix;
            }


            // add timestamp
            if (TimestampMenu.Checked)
            {
                MessageTextBox.AppendText(prefix);

                MessageTextBox.SelectionFont = TimeFont;
                MessageTextBox.AppendText(" (" + message.TimeStamp.ToString("T") + ")");

                MessageTextBox.SelectionFont = BoldFont;
                prefix = "";
            }

            if (!message.System)
            {
                prefix += ": ";
            }

            MessageTextBox.AppendText(prefix);

            // message, grey for not acked
            MessageTextBox.SelectionColor = Color.Black;
            if (Core.Network.Local.Equals(message) && !message.Sent)
            {
                MessageTextBox.SelectionColor = Color.LightGray;
            }

            if (message.System)
            {
                MessageTextBox.SelectionFont = SystemFont;
                MessageTextBox.AppendText(" *" + message.Text);
            }
            else
            {
                MessageTextBox.SelectionFont = RegularFont;

                if (message.Format == TextFormat.RTF)
                {
                    MessageTextBox.SelectedRtf = GuiUtils.RtftoColor(message.Text, MessageTextBox.SelectionColor);
                }
                else
                {
                    MessageTextBox.AppendText(message.Text);
                }
            }


            MessageTextBox.SelectionStart  = oldStart;
            MessageTextBox.SelectionLength = oldLength;

            MessageTextBox.DetectLinksDefault();

            if (!MessageTextBox.Focused)
            {
                MessageTextBox.SelectionStart = MessageTextBox.Text.Length;
                MessageTextBox.ScrollToCaret();
            }

            ParentView.MessageFlash();
        }
Exemplo n.º 5
0
        public void IM_MessageUpdate(ulong id, InstantMessage message)
        {
            if (id != UserID)
            {
                return;
            }

            int oldStart  = MessageTextBox.SelectionStart;
            int oldLength = MessageTextBox.SelectionLength;

            MessageTextBox.SelectionStart  = MessageTextBox.Text.Length;
            MessageTextBox.SelectionLength = 0;

            // name, in bold, blue for incoming, red for outgoing
            if (message.System)
            {
                MessageTextBox.SelectionColor = Color.Black;
            }
            else if (Core.Network.Local.Equals(message))
            {
                MessageTextBox.SelectionColor = message.Sent ? Color.Red : Color.LightCoral;
            }
            else
            {
                MessageTextBox.SelectionColor = Color.Blue;
            }

            MessageTextBox.SelectionFont = BoldFont;

            string prefix = " ";

            if (!message.System)
            {
                prefix += Core.GetName(message.UserID);
            }

            if (MessageTextBox.Text.Length != 0)
            {
                prefix = "\n" + prefix;
            }

            // add timestamp
            if (TimestampMenu.Checked)
            {
                MessageTextBox.AppendText(prefix);

                MessageTextBox.SelectionFont = TimeFont;
                MessageTextBox.AppendText(" (" + message.TimeStamp.ToString("T") + ")");

                MessageTextBox.SelectionFont = BoldFont;
                prefix = "";
            }

            string location = "";

            if (!message.System && Locations.ActiveClientCount(message.UserID) > 1)
            {
                location = " @" + Locations.GetLocationName(message.UserID, message.ClientID);
            }


            if (!message.System)
            {
                prefix += location + ": ";
            }

            MessageTextBox.AppendText(prefix);

            // message, grey for not acked
            MessageTextBox.SelectionColor = Color.Black;
            if (Core.Network.Local.Equals(message) && !message.Sent)
            {
                MessageTextBox.SelectionColor = Color.LightGray;
            }

            if (message.System)
            {
                MessageTextBox.SelectionFont = SystemFont;
                MessageTextBox.AppendText(" *" + message.Text);
            }
            else
            {
                MessageTextBox.SelectionFont = RegularFont;

                if (message.Format == TextFormat.RTF)
                {
                    MessageTextBox.SelectedRtf = GuiUtils.RtftoColor(message.Text, MessageTextBox.SelectionColor);
                }

                else if (message.Format == TextFormat.Plain)
                {
                    MessageTextBox.AppendText(message.Text);
                }
            }


            MessageTextBox.SelectionStart  = oldStart;
            MessageTextBox.SelectionLength = oldLength;

            MessageTextBox.DetectLinksDefault();

            if (!MessageTextBox.Focused)
            {
                MessageTextBox.SelectionStart = MessageTextBox.Text.Length;
                MessageTextBox.ScrollToCaret();
            }

            if (External != null && !WindowActivated)
            {
                FlashMe = true;
            }
        }