/// <summary>
 /// Override this to made changes before device group load.
 /// </summary>
 protected override void OnDeserializing(bool designMode)
 {
     DeviceGroups = new GXDeviceGroupCollection();
     Devices = new GXDeviceCollection();
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 public GXDeviceGroup()
 {
     DeviceGroups = new GXDeviceGroupCollection();
     Devices = new GXDeviceCollection();
 }
 /// <summary>
 /// Delete selected device.
 /// </summary>
 /// <param name="devices">A collection of devices to be deleted.</param>
 public void DeleteDevices(GXDeviceCollection devices)
 {
     if (devices == null)
     {
         System.Diagnostics.Debug.Assert(false);
         return;
     }
     //Show default Gurux dialog.
     if (GXCommon.ShowExclamation(ParentComponent, Gurux.DeviceSuite.Properties.Resources.GuruxDeviceSuiteTxt, Gurux.DeviceSuite.Properties.Resources.RemoveDeviceTxt) != DialogResult.Yes)
     {
         return;
     }
     //Remove all itemss.
     foreach (GXDevice dev in devices)
     {
         if ((dev.Status & Gurux.Device.DeviceStates.Connected) == 0)
         {
             dev.Parent.Remove(dev);
         }
         else
         {
             throw new Exception("Connected device cannot be removed.");
         }
     }
 }
		/// <summary>
		/// Get devices recursively from this and all the child device groups.
		/// </summary>
        public GXDeviceCollection GetDevicesRecursive()
        {
            GXDeviceCollection devices = new GXDeviceCollection();
			devices.AddRange(this.Devices);
			foreach (GXDeviceGroup dg in this.DeviceGroups)
			{
				devices.AddRange(dg.GetDevicesRecursive());
			}
            return devices;
        }
 private void ShowAvailableDevices(GXDeviceCollection devs, TreeNode root)
 {
     if (Gurux.DeviceSuite.Properties.Settings.Default.DeviceTreeShowDevices)
     {
         foreach (GXDevice dev in devs)
         {
             ShowAvailableDevice(dev, root);
         }
     }
 }