public void UpdateLeds()
        {
            // Update the LEDs in the RGB.NET device layout
            if (DeviceLayout.Leds != null)
            {
                LedLayout lastLed = null;
                foreach (var led in DeviceLayout.Leds)
                {
                    led.CalculateValues(DeviceLayout, lastLed);
                    lastLed = led;
                }
            }

            // Update the LEDs in the VMs
            var imageLayout = DeviceLayout.LedImageLayouts?.FirstOrDefault(l => l.Layout != null && l.Layout.Equals(EditorViewModel.SelectedImageLayout));

            foreach (var ledViewModel in LedViewModels)
            {
                ledViewModel.Update();
                if (imageLayout != null)
                {
                    // Try to find a matching LED image layout
                    var ledImage = imageLayout.LedImages.FirstOrDefault(i => i.Id.Equals(ledViewModel.LedLayout.Id));
                    ledViewModel.UpdateLedImage(ledImage);
                }
            }
        }
        public LedViewModel(LayoutEditModel model, DeviceLayoutViewModel layoutViewModel, IWindowManager windowManager, LedLayout ledLayout)
        {
            _layoutViewModel = layoutViewModel;
            _windowManager   = windowManager;

            Model           = model;
            LedLayout       = ledLayout;
            AvailableLedIds = new BindableCollection <string>();
            LedCursor       = Cursors.Hand;

            ApplyLogicalLayout();
        }
Example #3
0
        public LedViewModel(LayoutEditModel model, DeviceLayoutViewModel layoutViewModel, IWindowManager windowManager, LedLayout ledLayout)
        {
            _layoutViewModel = layoutViewModel;
            _windowManager   = windowManager;

            Model           = model;
            LedLayout       = ledLayout;
            AvailableLedIds = new BindableCollection <string>();
            LedCursor       = Cursors.Hand;

            this.PropertyChanged           += OnPropertyChanged;
            FileChangedWatcher.FileChanged += FileChangedWatcherOnFileChanged;

            UpdateImageSource();
        }
        public void UpdateLeds()
        {
            // Update the LEDs in the RGB.NET device layout
            if (DeviceLayout.Leds != null)
            {
                LedLayout lastLed = null;
                foreach (var ledLayout in DeviceLayout.Leds)
                {
                    var led = (LedLayout)ledLayout;
                    led.CalculateValues(DeviceLayout, lastLed);
                    lastLed = led;
                }
            }

            // Update the LEDs in the VMs
            foreach (var ledViewModel in Items)
            {
                ledViewModel.Update();
            }
        }
        public void FinishAddLed(bool addBefore, string ledId)
        {
            int index;

            if (SelectedLed == null)
            {
                if (addBefore)
                {
                    index = 0;
                }
                else
                {
                    index = Items.Count;
                }
            }
            else
            {
                if (addBefore)
                {
                    index = Items.IndexOf(SelectedLed);
                }
                else
                {
                    index = Items.IndexOf(SelectedLed) + 1;
                }
            }

            var ledLayout = new LedLayout {
                Id = ledId, CustomData = new LayoutCustomLedData()
            };
            var ledViewModel = new LedViewModel(Model, this, _windowManager, ledLayout);

            DeviceLayout.InternalLeds.Insert(index, ledLayout);
            Items.Insert(index, ledViewModel);

            UpdateLeds();
            SelectLed(ledViewModel);
        }