Exemplo n.º 1
0
        public void UpdateDataGridView2( object sender, RepositoryUpdatedEventArg e )
        {
            foreach( INetworkDictionaryItem item in e.ReadOnlyRepository )
            {
                byte[] b = item.IPAddress.GetAddressBytes();
                IPAddressV4 ip = new IPAddressV4();
                string intIP = string.Empty;
                if ( BitConverter.IsLittleEndian )
                {
                    ip.B0 = b[3];
                    ip.B1 = b[2];
                    ip.B2 = b[1];
                    ip.B3 = b[0];
                }
                else
                {
                    ip.B0 = b[0];
                    ip.B1 = b[1];
                    ip.B2 = b[2];
                    ip.B3 = b[3];
                }
                intIP = ((uint)ip.Address).ToString(); ;

                string IPAddressToString = string.Empty;
                IPAddressToString = item.IPAddress.ToString();

                string macToString = string.Empty;
                if ( item.MacAddress != null && item.MacAddress != PhysicalAddress.None )
                {
                    macToString = ToMac( item.MacAddress.ToString() );
                }

                string hostNameString = string.Empty;
                if ( item.HostEntry != null )
                {
                    hostNameString = item.HostEntry.HostName.ToString();
                }

                string portToString = string.Empty;
                //pour l'affichage des virgule
                if( item.Ports.Count > 0 )
                {
                    portToString += item.Ports[0].ToString();
                    for( int i = 1 ; i < item.Ports.Count ; i++ )
                        portToString += ", " + item.Ports[i].ToString();
                }

                bool found = false;
                foreach(DataGridViewRow row in dataGridView1.Rows)
                {
                    if ( row.Cells[1].Value.ToString() == IPAddressToString )
                    {
                        found = true;
                        if ( row.Cells[0].Value.ToString() == string.Empty && intIP != string.Empty )
                        {
                            row.Cells[0].Value = intIP;
                        }
                        if ( row.Cells[2].Value.ToString() == string.Empty && macToString != string.Empty )
                        {
                            row.Cells[2].Value = macToString;
                        }
                        if ( row.Cells[3].Value.ToString() == string.Empty && hostNameString != string.Empty )
                        {
                            row.Cells[3].Value = hostNameString;
                        }
                        if ( row.Cells[4].Value.ToString() == string.Empty && portToString != string.Empty )
                        {
                            row.Cells[4].Value = portToString;
                        }
                        break;
                    }
                }
                if ( !found )
                {
                    dataGridView1.Rows.Add( intIP, IPAddressToString, macToString, hostNameString, portToString);
                }
            }
        }
Exemplo n.º 2
0
        public void UpdateNshapeDisplay2(object sender, RepositoryUpdatedEventArg e)
        {
            int x = 0;
            int y = 0;

            foreach (INetworkDictionaryItem item in e.ReadOnlyRepository)
            {
                byte[] b = item.IPAddress.GetAddressBytes();
                IPAddressV4 ip = new IPAddressV4();
                string intIP = string.Empty;
                if (BitConverter.IsLittleEndian)
                {
                    ip.B0 = b[3];
                    ip.B1 = b[2];
                    ip.B2 = b[1];
                    ip.B3 = b[0];
                }
                else
                {
                    ip.B0 = b[0];
                    ip.B1 = b[1];
                    ip.B2 = b[2];
                    ip.B3 = b[3];
                }
                intIP = ((uint)ip.Address).ToString(); ;

                string IPAddressToString = string.Empty;
                IPAddressToString = item.IPAddress.ToString();

                string macToString = string.Empty;
                if (item.MacAddress != null && item.MacAddress != PhysicalAddress.None)
                {
                    macToString = ToMac(item.MacAddress.ToString());
                }

                string hostNameString = string.Empty;
                if (item.HostEntry != null)
                {
                    hostNameString = item.HostEntry.HostName.ToString();
                }

                string portToString = string.Empty;
                //pour l'affichage des virgule
                if (item.Ports.Count > 0)
                {
                    portToString += item.Ports[0].ToString();
                    for (int i = 1; i < item.Ports.Count; i++)
                        portToString += ", " + item.Ports[i].ToString();
                }

                //bool found = false;
                //List<IPAddressV4> HostDone = new List<IPAddressV4>();

                //foreach (INetworkDictionaryItem item2 in e.ReadOnlyRepository)
                //{
                    x += 100;
                    y += 100;

                    DrawEngine(hostNameString, x, y, shapeDict);

                    //HostDone.Add(ip);
                //}
            }
        }
Exemplo n.º 3
0
 public void UpdateDataGridView( object sender, RepositoryUpdatedEventArg e )
 {
     dataGridView1.Invoke( new UpdateDataGrid<RepositoryUpdatedEventArg>( UpdateDataGridView2 ), new object[] { sender, e } );
 }
Exemplo n.º 4
0
 public void UpdateNshapeDisplay1(object sender, RepositoryUpdatedEventArg e)
 {
     Invoke(new UpdateNshapeDisplay<RepositoryUpdatedEventArg>(UpdateNshapeDisplay2), new object[] { sender, e });
 }