예제 #1
0
파일: IMService.cs 프로젝트: nandub/DeOps
        public void ProcessMessage(IMStatus status, InstantMessage message)
        {
            if (Core.Buddies.IgnoreList.SafeContainsKey(message.UserID))
            {
                return;
            }

            // log message - locks both dictionary and embedded list form reading
            status.MessageLog.SafeAdd(message);

            if (ActiveUsers.Contains(status.UserID))
            {
                Core.RunInGuiThread(MessageUpdate, status.UserID, message);
            }
            else
            {
                Core.RunInGuiThread(CreateView, status.UserID);
            }

            Update(status);
        }
예제 #2
0
파일: IM_View.cs 프로젝트: RoelofSol/DeOps
        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;
        }
예제 #3
0
        public void ProcessMessage(IMStatus status, InstantMessage message)
        {
            if (Core.Buddies.IgnoreList.SafeContainsKey(message.UserID))
                return;

            // log message - locks both dictionary and embedded list form reading
            status.MessageLog.SafeAdd(message);

            if(ActiveUsers.Contains(status.UserID))
                Core.RunInGuiThread(MessageUpdate, status.UserID, message);
            else
                Core.RunInGuiThread(CreateView, status.UserID);

            Update(status);
        }
예제 #4
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;
            }
        }