/// <summary>
        /// Climbs the small hill.
        /// </summary>
        /// <returns></returns>
        private long ClimbSmallHill()
        {
            var sw = Stopwatch.StartNew();

            for (int i = 0; i < maxWaitTime / IDLE_TIME; i++)
            {
                Thread.Sleep(IDLE_TIME);

                nic = WindowsNetworkCardManager.RefreshStatus(nic.Id);

                Debug.WriteLine("Device connected " + nic.Connected);
                Debug.WriteLine("Device gateway " + nic.GatewayAddress);
                NetworkCardUp = PingHelper.RunPing(nic.GatewayAddress);

                // if (nic.Connected && nic.GatewayAddress == "" && !NetworkCardUp)
                pingCounter++;

                Debug.WriteLine("Ping on " + nic.GatewayAddress + " " + NetworkCardUp);

                if (pingCounter >= MAX_PING || NetworkCardUp || (nic.Connected && !NetworkCardUp))
                {
                    sw.Stop();
                    Debug.WriteLine("Termino");
                    return(sw.ElapsedMilliseconds);
                }
            }

            sw.Stop();
            return(sw.ElapsedMilliseconds);
        }
Пример #2
0
        /// <summary>
        /// Sets the device status.
        /// </summary>
        /// <param name="card">The card.</param>
        /// <param name="status">if set to <c>true</c> [status].</param>
        /// <returns></returns>
        public static bool SetDeviceStatus(WindowsNetworkCard card, bool status)
        {
            bool ret;

            switch (OSInfo.OperatingSystem)
            {
            case OperatingSystemType.WINDOWS_XP:
            {
                WinXPNetworkCardHelper hl = new WinXPNetworkCardHelper();
                string[] oparams          = { card.HardwareName };
                ret = hl.SetDeviceState(oparams, status);
            }
            break;

            case OperatingSystemType.WINDOWS_7:
            {
                Win7NetworkCardHelper hl = new Win7NetworkCardHelper();
                ret = hl.SetDeviceState(card.Id, status);
            }
            break;

            default:
            {
                throw (new Exception("Operating system not supported!"));
            }
            }

            return(ret);
        }
Пример #3
0
        /// <summary>
        /// Applies the specified card.
        /// </summary>
        /// <param name="card">The card.</param>
        public static void Apply(WindowsNetworkCard card)
        {
            switch (OSInfo.OperatingSystem)
            {
            case OperatingSystemType.WINDOWS_XP:
                WinXPNetworkCardManager.Apply(card);
                break;

            case OperatingSystemType.WINDOWS_7:
                Win7NetworkCardManager.Apply(card);
                break;
            }
        }
Пример #4
0
        /// <summary>
        /// Writes the data into registry.
        /// </summary>
        /// <param name="card">The card.</param>
        public static void WriteDataIntoRegistry(WindowsNetworkCard card)
        {
            switch (OSInfo.OperatingSystem)
            {
            case OperatingSystemType.WINDOWS_XP:
                WinXPNetworkCardManager.WriteDataIntoRegistry(card);
                break;

            case OperatingSystemType.WINDOWS_7:
                Win7NetworkCardManager.WriteDataIntoRegistry(card);
                break;
            }
        }
Пример #5
0
        /// <summary>
        /// Checks the name of if present in hardware.
        /// </summary>
        /// <param name="card">The card.</param>
        /// <param name="checkValues">The check values.</param>
        /// <returns></returns>
        internal static bool CheckIfPresentInHardwareName(WindowsNetworkCard card, params string[] checkValues)
        {
            string value = card.HardwareName.ToLower();

            foreach (string item in checkValues)
            {
                if (value.Contains(item.ToLower()))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #6
0
        /// <summary>
        /// Sets the state of the device.
        /// </summary>
        /// <param name="guid">The GUID.</param>
        /// <param name="bEnable">if set to <c>true</c> [b enable].</param>
        /// <returns></returns>
        public static string GetDeviceStatus(WindowsNetworkCard nic)
        {
            String      name  = nic.Name;
            SelectQuery query = new SelectQuery("Win32_NetworkAdapter");

            Console.WriteLine("--> CERCO " + name);
            ManagementObjectSearcher search = new ManagementObjectSearcher(query);

            foreach (ManagementObject result in search.Get())
            {
                //result.Pu
                WmiNetworkAdapter adapter = new WmiNetworkAdapter(result);

                //Console.WriteLine("--> ANALISZ " + adapter.Name);
                if (adapter.Name.Equals(name))
                {
                    Console.WriteLine("===> FOUND [" + adapter.NetConnectionStatus + "]");
                    return(adapter.Status);
                }
            }

            return("");
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="WindowsNetworkCardEventHandler"/> class.
 /// </summary>
 /// <param name="card">The card.</param>
 public WindowsNetworkCardEventHandler(WindowsNetworkCard card)
 {
     nic = card;
 }
Пример #8
0
 /// <summary>
 /// Copies the specified item.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns></returns>
 public static WindowsNetworkCard Copy(WindowsNetworkCard item)
 {
     return((WindowsNetworkCard)item.MemberwiseClone());
 }
Пример #9
0
 /// <summary>
 /// Checks if fire wire card.
 /// </summary>
 /// <param name="card">The card.</param>
 /// <returns></returns>
 internal static bool CheckIfFireWireCard(WindowsNetworkCard card)
 {
     return(CheckIfPresentInHardwareName(card, "1394", "Firewire"));
 }
Пример #10
0
 /// <summary>
 /// Checks if bluetooth card.
 /// </summary>
 /// <param name="card">The card.</param>
 /// <returns></returns>
 internal static bool CheckIfBluetoothCard(WindowsNetworkCard card)
 {
     return(CheckIfPresentInHardwareName(card, "Bluetooth"));
 }
Пример #11
0
 /// <summary>
 /// Checks if virtual card.
 /// </summary>
 /// <param name="card">The card.</param>
 /// <returns></returns>
 internal static bool CheckIfVirtualCard(WindowsNetworkCard card)
 {
     return(CheckIfPresentInHardwareName(card, "VMWare", "VirtualBox", "VPN"));
 }
Пример #12
0
 /// <summary>
 /// Checks if wireless card.
 /// </summary>
 /// <param name="card">The card.</param>
 /// <returns></returns>
 internal static bool CheckIfWirelessCard(WindowsNetworkCard card)
 {
     return(CheckIfPresentInHardwareName(card, "Wireless", "WLAN", "Wi-Fi", "802.11a", "802.11b", "802.11g", "802.11n"));
 }