예제 #1
0
        public void SetActiveSurfaceConfiguration(ArtemisSurface surface)
        {
            if (ActiveSurface == surface)
                return;

            // Set the new entity
            ActiveSurface = surface;

            // Ensure only the new entity is marked as active
            lock (_surfaceConfigurations)
            {
                // Mark only the new surface as active
                foreach (var configuration in _surfaceConfigurations)
                {
                    configuration.IsActive = configuration == ActiveSurface;
                    configuration.ApplyToEntity();

                    _surfaceRepository.Save(configuration.SurfaceEntity);
                }
            }

            // Apply the active surface entity to the devices
            if (ActiveSurface != null)
            {
                foreach (var device in ActiveSurface.Devices)
                    device.ApplyToRgbDevice();
            }

            // Update the RGB service's graphics decorator to work with the new surface entity
            _rgbService.UpdateSurfaceLedGroup();
            OnActiveSurfaceConfigurationChanged(new SurfaceConfigurationEventArgs(ActiveSurface));
        }
예제 #2
0
        public void SetActiveSurfaceConfiguration(SurfaceConfiguration surfaceConfiguration)
        {
            if (ActiveSurfaceConfiguration == surfaceConfiguration)
            {
                return;
            }

            // Set the new configuration
            ActiveSurfaceConfiguration = surfaceConfiguration;

            // Ensure only the new configuration is marked as active
            lock (_surfaceConfigurations)
            {
                // Mark only the new surfaceConfiguration as active
                foreach (var configuration in _surfaceConfigurations)
                {
                    configuration.IsActive = configuration == ActiveSurfaceConfiguration;
                    configuration.ApplyToEntity();
                }

                _surfaceRepository.Save();
            }

            // Apply the active surface configuration to the devices
            if (ActiveSurfaceConfiguration != null)
            {
                foreach (var deviceConfiguration in ActiveSurfaceConfiguration.DeviceConfigurations)
                {
                    deviceConfiguration.ApplyToDevice();
                }
            }

            // Update the RGB service's graphics decorator to work with the new surface configuration
            _rgbService.UpdateGraphicsDecorator();
            OnActiveSurfaceConfigurationChanged(new SurfaceConfigurationEventArgs(ActiveSurfaceConfiguration));
        }