void deviceItemControl_EditComplete(DeviceItemControl deviceItemControl)
        {
            deviceItemControl.Top  = deviceItemControl.DeviceItem.Device.Y;
            deviceItemControl.Left = deviceItemControl.DeviceItem.Device.X;

            Singleton.Instance.EditDeviceMode = EditDeviceMode.None;
        }
        private void LoadAllDevice()
        {
            var alldevices = DeviceService.GetAllDevices();

            foreach (var device in alldevices)
            {
                var deviceItem        = new DeviceItem(device, null);
                var deviceItemControl = new DeviceItemControl(deviceItem);
                deviceItemControl.EditComplete   += deviceItemControl_EditComplete;
                deviceItemControl.RemodeComplete += deviceItemControl_RemodeComplete;
                deviceItemControl.Top             = device.Y;
                deviceItemControl.Left            = device.X;
                panel1.Controls.Add(deviceItemControl);
            }
        }
        void addDeviceForm_EditComplete(Infrastructure.DataRepository.Models.Device device)
        {
            var deviceItem        = new DeviceItem(device, null);
            var deviceItemControl = new DeviceItemControl(deviceItem);

            deviceItemControl.Top  = device.Y;
            deviceItemControl.Left = device.X;

            var targetClient = AppStartUp.Clients.FirstOrDefault(o => o.Ip == device.IPAddress && o.Port == device.Port);

            if (targetClient != null)
            {
                deviceItemControl.SetClient(targetClient);
            }
            panel1.Controls.Add(deviceItemControl);

            Singleton.Instance.EditDeviceMode = EditDeviceMode.None;
        }
 void deviceItemControl_RemodeComplete(DeviceItemControl control)
 {
     panel1.Controls.Remove(control);
 }