private void SaveDeviceItemLocation(Controls.DeviceItem deviceItem) { List <DeviceItemLocation> locations = null; var json = Properties.Settings.Default.ShopStatusItemLocations; if (!string.IsNullOrEmpty(json)) { locations = JSON.ToType <List <DeviceItemLocation> >(json); } if (locations == null) { locations = new List <DeviceItemLocation>(); } double x = Canvas.GetLeft(deviceItem); double y = Canvas.GetTop(deviceItem); double width = deviceItem.ActualWidth; double height = deviceItem.ActualHeight; var location = locations.Find(o => o.DeviceId == deviceItem.Device.UniqueId); if (location == null) { location = new DeviceItemLocation(); locations.Add(location); } location.DeviceId = deviceItem.Device.UniqueId; location.X = x; location.Y = y; location.Height = height; location.Width = width; json = JSON.FromList <DeviceItemLocation>(locations); if (!string.IsNullOrEmpty(json)) { Properties.Settings.Default.ShopStatusItemLocations = json; Properties.Settings.Default.Save(); } }
private void SaveDeviceItemLocation(Controls.DeviceItem deviceItem) { List<DeviceItemLocation> locations = null; var json = Properties.Settings.Default.ShopStatusItemLocations; if (!string.IsNullOrEmpty(json)) { locations = JSON.ToType<List<DeviceItemLocation>>(json); } if (locations == null) { locations = new List<DeviceItemLocation>(); } double x = Canvas.GetLeft(deviceItem); double y = Canvas.GetTop(deviceItem); double width = deviceItem.ActualWidth; double height = deviceItem.ActualHeight; var location = locations.Find(o => o.DeviceId == deviceItem.Device.UniqueId); if (location == null) { location = new DeviceItemLocation(); locations.Add(location); } location.DeviceId = deviceItem.Device.UniqueId; location.X = x; location.Y = y; location.Height = height; location.Width = width; json = JSON.FromList<DeviceItemLocation>(locations); if (!string.IsNullOrEmpty(json)) { Properties.Settings.Default.ShopStatusItemLocations = json; Properties.Settings.Default.Save(); } }