Ejemplo n.º 1
0
        /// <summary>
        /// Removes device with specified Mac from saved devices.
        /// </summary>
        public static void RemoveDevice(Network.PhysicalAddressSerializable mac)
        {
            Network.Device device = GetDevice(mac);

            if (device != null)
            {
                Properties.Settings.Default.Devices.Remove(device);
                Properties.Settings.Default.Save();
            }
        }
Ejemplo n.º 2
0
        public static void CycleDeviceReceiveMode(Network.PhysicalAddressSerializable mac)
        {
            Network.Device device = GetDevice(mac);

            if (device != null)
            {
                device.CycleReceiveMode();
                Properties.Settings.Default.Save();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sets a password for encryption for device. If password is null, will remove password.
        /// </summary>
        /// <param name="mac"></param>
        /// <param name="password"></param>
        public static void SetDeviceEncryptionPassword(Network.PhysicalAddressSerializable mac, SecureString password)
        {
            Network.Device device = GetDevice(mac);

            if (device != null)
            {
                if (password == null)
                {
                    device.RemoveEncryptionPassword();
                }
                else
                {
                    device.SetEncryptionPassword(password);
                }

                Properties.Settings.Default.Save();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds new device into list or updates info on already existing device.
        /// </summary>
        public static void AddUpdateDevice(Network.PhysicalAddressSerializable mac, string name, IPAddress ip, Network.DeviceType?type = null)
        {
            Network.Device device = GetDevice(mac);

            if (device != null)
            {
                if (device.TryUpdateInfo(name, ip))
                {
                    Properties.Settings.Default.Save();
                }
            }
            else
            {
                device = new Network.Device(name, ip, mac, type ?? Network.DeviceType.Unknown);
                Properties.Settings.Default.Devices.Add(device);
                Properties.Settings.Default.Save();
                device.NotifyPropertyChanged();
            }
        }
Ejemplo n.º 5
0
        // Devices
        /// <summary>
        /// Returns device with specified Mac from saved devices.
        /// </summary>
        public static Network.Device GetDevice(Network.PhysicalAddressSerializable mac)
        {
            if (mac == null)
            {
                return(null);
            }

            foreach (var dev in Properties.Settings.Default.Devices)
            {
                if (dev == null || dev.MacAdress == null)
                {
                    continue;
                }

                if (dev.MacAdress.Equals(mac))
                {
                    return(dev);
                }
            }

            return(null);
        }