예제 #1
0
        public ChatMessageItem(BitChat.Peer senderPeer, string message, DateTime date, bool myMessage)
        {
            InitializeComponent();

            _senderPeer = senderPeer;
            _date = date;

            lblUsername.Text = _senderPeer.PeerCertificate.IssuedTo.Name;
            txtMessage.Text = message;
            lblDateTime.Text = date.ToString("HH:mm");

            if (myMessage)
                lblUsername.ForeColor = Color.FromArgb(63, 186, 228);

            OnResize(EventArgs.Empty);
        }
예제 #2
0
        public UserListItem(BitChat.Peer peer)
        {
            InitializeComponent();

            _peer = peer;

            _peer.StateChanged += _peer_StateChanged;
            _peer.NetworkStatusUpdated += _peer_NetworkStatusUpdated;

            if (_peer.PeerCertificate.IssuedTo.FieldExists(CertificateProfileFlags.Name))
            {
                string name = _peer.PeerCertificate.IssuedTo.Name;

                if (name.Length > 0)
                {
                    labIcon.Text = name.Substring(0, 1).ToUpper();

                    int x = name.LastIndexOf(" ", StringComparison.CurrentCultureIgnoreCase);
                    if (x > 0)
                    {
                        labIcon.Text += name.Substring(x + 1, 1).ToUpper();
                    }
                    else if (name.Length > 1)
                    {
                        labIcon.Text += name.Substring(1, 1).ToLower();
                    }
                }
                else
                {
                    labIcon.Text = "";
                }

                labName.Text = name;
            }
            else
            {
                labIcon.Text = "";
                labName.Text = "{missing name}";
                labName.ForeColor = Color.Red;
            }

            labEmail.Text = _peer.PeerCertificate.IssuedTo.EmailAddress.Address;

            _peer_StateChanged(null, null);
            _peer_NetworkStatusUpdated(null, null);
        }
예제 #3
0
        public frmViewUser(BitChat.Peer peer)
        {
            InitializeComponent();

            _peer = peer;

            //name
            if (_peer.PeerCertificate.IssuedTo.FieldExists(CertificateProfileFlags.Name))
            {
                string name = _peer.PeerCertificate.IssuedTo.Name;

                //name icon
                if (name.Length > 0)
                {
                    labIcon.Text = name.Substring(0, 1).ToUpper();

                    int x = name.LastIndexOf(" ", StringComparison.CurrentCultureIgnoreCase);
                    if (x > 0)
                    {
                        labIcon.Text += name.Substring(x + 1, 1).ToUpper();
                    }
                    else if (name.Length > 1)
                    {
                        labIcon.Text += name.Substring(1, 1).ToLower();
                    }
                }
                else
                {
                    labIcon.Text = "";
                }

                if (_peer.IsOnline)
                    labIcon.BackColor = Color.FromArgb(102, 153, 255);
                else
                    labIcon.BackColor = Color.Gray;

                labName.Text = name;
            }
            else
            {
                labIcon.Text = "";
                labName.Text = "{missing name}";
                labName.ForeColor = Color.Red;
            }

            //email
            if (_peer.PeerCertificate.IssuedTo.FieldExists(CertificateProfileFlags.EmailAddress))
            {
                labEmail.Text = _peer.PeerCertificate.IssuedTo.EmailAddress.Address;
            }
            else
            {
                labEmail.Text = "{missing email address}";
                labEmail.ForeColor = Color.Red;
            }

            //location
            if (_peer.PeerCertificate.IssuedTo.FieldExists(CertificateProfileFlags.City | CertificateProfileFlags.State | CertificateProfileFlags.Country))
            {
                labLocation.Text = "";

                if (_peer.PeerCertificate.IssuedTo.FieldExists(CertificateProfileFlags.City))
                    labLocation.Text = _peer.PeerCertificate.IssuedTo.City + ", ";

                if (_peer.PeerCertificate.IssuedTo.FieldExists(CertificateProfileFlags.State))
                    labLocation.Text += _peer.PeerCertificate.IssuedTo.State + ", ";

                if (_peer.PeerCertificate.IssuedTo.FieldExists(CertificateProfileFlags.Country))
                    labLocation.Text += _peer.PeerCertificate.IssuedTo.Country;
            }
            else
            {
                labLocation.Text = "{missing location}";
                labLocation.ForeColor = Color.Red;
            }

            //network status
            switch (_peer.NetworkStatus)
            {
                case BitChatNetworkStatus.NoNetwork:
                    labNetworkStatus.Text = "No Network";
                    labNetworkStatus.ForeColor = Color.DimGray;
                    picNetwork.Image = BitChatAppMono.Properties.Resources.NoNetwork;
                    break;

                case BitChatNetworkStatus.PartialNetwork:
                    labNetworkStatus.Text = "Partial Network";
                    labNetworkStatus.ForeColor = Color.OrangeRed;
                    picNetwork.Image = BitChatAppMono.Properties.Resources.PartialNetwork;
                    break;

                case BitChatNetworkStatus.FullNetwork:
                    labNetworkStatus.Text = "Full Network";
                    labNetworkStatus.ForeColor = Color.Green;
                    picNetwork.Image = BitChatAppMono.Properties.Resources.FullNetwork;
                    break;

                default:
                    labNetworkStatus.Text = "Unknown";
                    labNetworkStatus.ForeColor = Color.DimGray;
                    picNetwork.Image = BitChatAppMono.Properties.Resources.NoNetwork;
                    break;
            }

            //cipher suite
            labCipherSuite.Text = _peer.CipherSuite.ToString();

            //connected with
            PeerInfo[] connectedWith = _peer.ConnectedWith;

            foreach (PeerInfo peerInfo in connectedWith)
            {
                string peerIPs = null;

                foreach (IPEndPoint peerEP in peerInfo.PeerEPList)
                {
                    if (peerIPs == null)
                        peerIPs = peerEP.ToString();
                    else
                        peerIPs += ", " + peerEP.ToString();
                }

                lstConnectedWith.Items.Add(peerInfo.PeerEmail).SubItems.Add(peerIPs);
            }

            //not connected with
            PeerInfo[] notConnectedWith = _peer.NotConnectedWith;

            foreach (PeerInfo peerInfo in notConnectedWith)
            {
                string peerIPs = null;

                foreach (IPEndPoint peerEP in peerInfo.PeerEPList)
                {
                    if (peerIPs == null)
                        peerIPs = peerEP.ToString();
                    else
                        peerIPs += ", " + peerEP.ToString();
                }

                lstNotConnectedWith.Items.Add(peerInfo.PeerEmail).SubItems.Add(peerIPs);
            }
        }