// this method will be called for editing the device Object in the list.
        public static void editDevice(Device editedDevice)
        {
            // deletes the existing device with obsolete data
            deviceList.Remove(getDevice(editedDevice.DeviceId));

            // add the edited device with the new data
            deviceList.Add(editedDevice);
        }
        public AddNewDevice(MainWindow handle, AddNewDeviceType deviceType, int deviceId)
        {
            InitializeComponent();

            this.handle = handle;
            this.deviceType = deviceType;

            string name = "Root";
            device = DeviceList.getDevice(deviceId);

            if (device != null)
                name = device.DeviceName;

            switch (deviceType)
            {
                case AddNewDeviceType.PEER:
                    device = DeviceList.getDevice(deviceId);
                    addDeviceButton.Content = "Add Device";
                    instructionBox.Content = "Add new Peer device to " + name;
                    break;
                case AddNewDeviceType.SLAVE:
                    device = DeviceList.getDevice(deviceId);
                    addDeviceButton.Content = "Add Device";
                    instructionBox.Content = "Add new Peer slave to " + name;
                    break;
                case AddNewDeviceType.EDIT:
                    device = DeviceList.getDevice(deviceId);
                    addDeviceButton.Content = "Edit Device";
                    instructionBox.Content = "Edit device "+ name ;

                    ipAddress.Text = device.DomainName;
                    deviceName.Text = device.DeviceName;
                    break;
            }

        }
 // comparator function for this class
 public static int CompareDeviceId(Device  x, Device  y)
 {
     return x.DeviceId .CompareTo(y.DeviceId );
 }
 // called from GUI for creating a new device object.
 public static int addDeviceFromGUI(int parentID, string domainOrIpaddress, String deviceName)
 {
     Device devObj = new Device(-1, parentID, domainOrIpaddress , domainOrIpaddress  , deviceName, -1, -1, false, NetworkStatus.OFFLINE );
     deviceList.Add(devObj);
     return devObj.DeviceId;
 }
 // called from xml parser while loading the data from XML file
 public static void loadDeviceFromXML(int deviceID, int parentID, string domain, string ipaddress, String deviceName, double latitude, double longitude, bool disabled, NetworkStatus currentStatus)
 {
     Device devObj = new Device(deviceID, parentID, domain, ipaddress, deviceName, latitude, longitude, disabled, currentStatus );
     deviceList.Add(devObj);
 }