예제 #1
0
        public frmMessageInfo(BitChat.Peer selfPeer, MessageItem message)
        {
            _message = message;

            this.SuspendLayout();

            InitializeComponent();

            chatMessageDisplay                  = new ChatMessageTextItem(selfPeer, _message);
            chatMessageDisplay.Anchor           = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
            chatMessageDisplay.Width            = chatMessagePanel.Width - 30;
            chatMessageDisplay.ContextMenuStrip = null;

            if (chatMessageDisplay.Height > 150)
            {
                chatMessagePanel.Height = 140;
            }
            else
            {
                chatMessagePanel.Height = chatMessageDisplay.Height + 10;

                int heightDiff = 150 - chatMessagePanel.Height;

                this.Height   -= heightDiff;
                listView1.Top -= heightDiff;
                btnClose.Top  -= heightDiff;
            }

            chatMessagePanel.Controls.Add(chatMessageDisplay);

            this.ResumeLayout();
        }
예제 #2
0
        public frmMessageInfo(MeshNetwork.Peer selfPeer, MessageItem message)
        {
            this.SuspendLayout();

            InitializeComponent();

            CustomListViewItem displayItem;

            switch (message.Type)
            {
            case MessageType.TextMessage:
                ChatMessageTextItem textItem = new ChatMessageTextItem(selfPeer, message);
                textItem.Anchor           = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                textItem.Width            = chatMessagePanel.Width - 30;
                textItem.ContextMenuStrip = null;

                displayItem = textItem;
                break;

            case MessageType.FileAttachment:
                ChatMessageFileItem fileItem = new ChatMessageFileItem(selfPeer, message);
                fileItem.Anchor           = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                fileItem.Width            = chatMessagePanel.Width - 30;
                fileItem.ContextMenuStrip = null;

                displayItem = fileItem;
                break;

            default:
                return;
            }

            if (displayItem.Height > 150)
            {
                chatMessagePanel.Height = 140;
            }
            else
            {
                chatMessagePanel.Height = displayItem.Height + 10;

                int heightDiff = 150 - chatMessagePanel.Height;

                this.Height   -= heightDiff;
                listView1.Top -= heightDiff;
                btnClose.Top  -= heightDiff;
            }

            chatMessagePanel.Controls.Add(displayItem);

            MeshNetwork.Peer[] peers = selfPeer.Network.GetPeers();

            foreach (MessageRecipient rcpt in message.Recipients)
            {
                string rcptName = null;

                foreach (MeshNetwork.Peer peer in peers)
                {
                    if (peer.PeerUserId.Equals(rcpt.UserId))
                    {
                        rcptName = peer.ProfileDisplayName;
                        break;
                    }
                }

                if (rcptName == null)
                {
                    rcptName = rcpt.UserId.ToString();
                }

                ListViewItem item = listView1.Items.Add(rcptName);

                switch (rcpt.Status)
                {
                case MessageRecipientStatus.Delivered:
                    item.SubItems.Add("Delivered on " + rcpt.DeliveredOn.ToLocalTime().ToString());
                    break;

                case MessageRecipientStatus.Undelivered:
                    item.SubItems.Add("Undelivered");
                    break;
                }
            }

            this.ResumeLayout();
        }