public void ApplyInput() { // If the ID changed the image layouts must change as well if (!LedLayout.Id.Equals(InputId)) { foreach (var imageLayout in Model.DeviceLayout.LedImageLayouts) { foreach (var ledImage in imageLayout.LedImages.Where(l => l.Id.Equals(LedLayout.Id))) { ledImage.Id = InputId; } } } LedLayout.Id = InputId; LedLayout.DescriptiveX = InputX; LedLayout.DescriptiveY = InputY; LedLayout.DescriptiveWidth = InputWidth; LedLayout.DescriptiveHeight = InputHeight; // Apply custom shape data if (InputShape == Shape.Custom) { LedLayout.DescriptiveShape = InputShapeData; } else { LedLayout.DescriptiveShape = InputShape.ToString(); } // If LED image exists, update it if (_ledImage != null) { _ledImage.Image = InputImage; NotifyOfPropertyChange(() => LedImagePath); } // Create a new LED image and add it to the layout else { var ledImage = new LedImage { Id = LedLayout.Id, Image = InputImage }; // Find the current layout var layout = Model.DeviceLayout.LedImageLayouts.FirstOrDefault(l => l.Layout != null && l.Layout.Equals(_layoutViewModel.EditorViewModel.SelectedImageLayout)); // If missing, create it if (layout == null) { layout = new LedImageLayout { Layout = _layoutViewModel.EditorViewModel.SelectedImageLayout }; Model.DeviceLayout.LedImageLayouts.Add(layout); } layout.LedImages.Add(ledImage); UpdateLedImage(ledImage); } _layoutViewModel.UpdateLeds(); }
public void ApplyInput() { LedLayout.Id = InputId; LedLayout.DescriptiveX = InputX; LedLayout.DescriptiveY = InputY; LedLayout.DescriptiveWidth = InputWidth; LedLayout.DescriptiveHeight = InputHeight; // Apply custom shape data if (InputShape == Shape.Custom) { LedLayout.DescriptiveShape = InputShapeData; } else { LedLayout.DescriptiveShape = InputShape.ToString(); } // If LED image exists, update it _layoutViewModel.UpdateLeds(); }