public AddLedViewModel(bool addBefore, DeviceLayoutViewModel deviceLayoutViewModel) { _addBefore = addBefore; _deviceLayoutViewModel = deviceLayoutViewModel; AvailableLedIds = new BindableCollection <string>(); AvailableLedIds.AddRange(deviceLayoutViewModel.Model.GetAvailableLedIds()); }
public DeviceLayoutEditorViewModel(LayoutEditModel model, ShellViewModel shellViewModel, IWindowManager windowManager) { _shellViewModel = shellViewModel; _windowManager = windowManager; Model = model; DeviceLayout = model.DeviceLayout; DeviceLayout.CustomData ??= new LayoutCustomDeviceData(); DeviceLayoutViewModel = new DeviceLayoutViewModel(Model, this, windowManager); DeviceLayoutViewModel.ConductWith(this); LogicalLayouts = new ObservableCollection <string> { "Empty" }; foreach (var led in DeviceLayout.Leds) { if (led.CustomData == null) { continue; } var customLedData = (LayoutCustomLedData)led.CustomData; foreach (var ledDataLogicalLayout in customLedData.LogicalLayouts) { if (ledDataLogicalLayout.Name != null && !LogicalLayouts.Contains(ledDataLogicalLayout.Name)) { LogicalLayouts.Add(ledDataLogicalLayout.Name); } } } SelectedLogicalLayout = LogicalLayouts.FirstOrDefault(); // Lame but works if (Model.FilePath.EndsWith("ABNT.xml")) { Model.PhysicalLayout = KeyboardLayoutType.ABNT; } else if (Model.FilePath.EndsWith("ANSI.xml")) { Model.PhysicalLayout = KeyboardLayoutType.ANSI; } else if (Model.FilePath.EndsWith("ISO.xml")) { Model.PhysicalLayout = KeyboardLayoutType.ISO; } else if (Model.FilePath.EndsWith("JIS.xml")) { Model.PhysicalLayout = KeyboardLayoutType.JIS; } else if (Model.FilePath.EndsWith("KS.xml")) { Model.PhysicalLayout = KeyboardLayoutType.KS; } UpdateDeviceImage(); }
public DeviceLayoutEditorViewModel(LayoutEditModel model, ShellViewModel shellViewModel, IWindowManager windowManager) { _shellViewModel = shellViewModel; _windowManager = windowManager; Model = model; DeviceLayout = model.DeviceLayout; DeviceLayoutViewModel = new DeviceLayoutViewModel(Model, this, windowManager); ImageLayouts = new ObservableCollection <string>(); foreach (var ledImage in DeviceLayout.LedImageLayouts) { if (!ImageLayouts.Contains(ledImage.Layout)) { ImageLayouts.Add(ledImage.Layout); } } SelectedImageLayout = ImageLayouts.FirstOrDefault(); ImageBasePath = DeviceLayout.ImageBasePath; DeviceImage = DeviceLayout.DeviceImage; }