コード例 #1
0
 /// <summary>
 /// Remove the device
 /// </summary>
 /// <param name="device"></param>
 private void RemoveDevice(INatDevice device)
 {
     if (devices.Contains(device))
     {
         devices.Remove(device);
         for (int i = 0; i < lvDevices.Items.Count; i++)
         {
             if (device.ToString().Contains(lvDevices.Items[i].SubItems[3].Text))
             {
                 lvDevices.Items.Remove(lvDevices.Items[i]);
             }
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// Adding devices to the list and listbox
        /// </summary>
        /// <param name="device"></param>
        private void AddDevice(INatDevice device)
        {
            if (!devices.Contains(device))
            {
                devices.Add(device);
                //listBoxDevices.Items.Add(device.ToString());
                IPAddress external = device.GetExternalIP();
                Mapping[] maps = device.GetAllMappings();

                //complicated stuff because the library only allows to display some data via .ToString() as far as I know
                string str = device.ToString();
                lvDevices.Items.Add(ReadBetween("EndPoint:", ",", str));
                lvDevices.Items[lvDevices.Items.Count-1].SubItems.Add(external.ToString());
                lvDevices.Items[lvDevices.Items.Count - 1].SubItems.Add(maps.Length.ToString());
                lvDevices.Items[lvDevices.Items.Count - 1].SubItems.Add(ReadBetween("/dyndev/uuid:", ",", str));

                //if it's the first added, select it
                if (lvDevices.Items.Count == 1)
                    lvDevices.Items[0].Selected = true;
            }
        }
コード例 #3
0
        /// <summary>
        /// Adding devices to the list and listbox
        /// </summary>
        /// <param name="device"></param>
        private void AddDevice(INatDevice device)
        {
            if (!devices.Contains(device))
            {
                devices.Add(device);
                //listBoxDevices.Items.Add(device.ToString());
                IPAddress external = device.GetExternalIP();
                Mapping[] maps     = device.GetAllMappings();

                //complicated stuff because the library only allows to display some data via .ToString() as far as I know
                string str = device.ToString();
                lvDevices.Items.Add(ReadBetween("EndPoint:", ",", str));
                lvDevices.Items[lvDevices.Items.Count - 1].SubItems.Add(external.ToString());
                lvDevices.Items[lvDevices.Items.Count - 1].SubItems.Add(maps.Length.ToString());
                lvDevices.Items[lvDevices.Items.Count - 1].SubItems.Add(ReadBetween("/dyndev/uuid:", ",", str));

                //if it's the first added, select it
                if (lvDevices.Items.Count == 1)
                {
                    lvDevices.Items[0].Selected = true;
                }
            }
        }
コード例 #4
0
 /// <summary>
 /// Remove the device
 /// </summary>
 /// <param name="device"></param>
 private void RemoveDevice(INatDevice device)
 {
     if (devices.Contains(device))
     {
         devices.Remove(device);
         for (int i = 0; i < lvDevices.Items.Count; i++)
         {
             if (device.ToString().Contains(lvDevices.Items[i].SubItems[3].Text))
             {
                 lvDevices.Items.Remove(lvDevices.Items[i]);
             }
         }
     }
 }