public void Update(LayerModel layerModel, ModuleDataModel dataModel, bool isPreview = false) { var properties = layerModel?.Properties as AmbientLightPropertiesModel; if (properties == null) { return; } var width = (int)Math.Round(properties.Width); var height = (int)Math.Round(properties.Height); var data = ScreenCaptureManager.GetLastScreenCapture(); var newData = GetAmbienceCreator(properties) .GetAmbience(data, ScreenCaptureManager.LastCaptureWidth, ScreenCaptureManager.LastCaptureHeight, width, height, properties); _lastData = _lastData?.Blend(newData, properties.SmoothMode) ?? newData; var stride = (width * ScreenCaptureManager.LastCapturePixelFormat.BitsPerPixel + 7) / 8; properties.AmbientLightBrush = new DrawingBrush(new ImageDrawing (BitmapSource.Create(width, height, 96, 96, ScreenCaptureManager.LastCapturePixelFormat, null, _lastData, stride), new Rect(0, 0, width, height))); layerModel.ApplyProperties(true); }
public void Update(LayerModel layerModel, ModuleDataModel dataModel, bool isPreview = false) { // Key press is always as large as the entire keyboard it is drawn for layerModel.Properties.Width = _deviceManager.ActiveKeyboard.Width; layerModel.Properties.Height = _deviceManager.ActiveKeyboard.Height; layerModel.Properties.X = 0; layerModel.Properties.Y = 0; layerModel.Properties.Contain = true; layerModel.ApplyProperties(true); _layerModel = layerModel; if (isPreview) { return; } lock (_keyPressLayers) { // Remove expired key presses var updateLayers = _keyPressLayers.Where(k => !k.LayerAnimation.MustExpire(k)).ToList(); // Update the ones that are still active foreach (var updateLayer in updateLayers) { updateLayer.Update(null, false, true); } _keyPressLayers = updateLayers; } }
public void Update(LayerModel layerModel, ModuleDataModel dataModel, bool isPreview = false) { layerModel.ApplyProperties(true); if (isPreview || dataModel == null) { return; } // If not previewing, apply dynamic properties according to datamodel foreach (var dynamicProperty in layerModel.Properties.DynamicProperties) { dynamicProperty.ApplyProperty(dataModel, layerModel); } }
public void Update(LayerModel layerModel, ModuleDataModel dataModel, bool isPreview = false) { // Generic layers are always drawn 10*10 (which is 40*40 when scaled up) layerModel.Properties.Width = 10; layerModel.Properties.Height = 10; layerModel.Properties.X = 0; layerModel.Properties.Y = 0; layerModel.Properties.Contain = true; layerModel.ApplyProperties(true); if (isPreview || dataModel == null) { return; } // If not previewing, apply dynamic properties according to datamodel foreach (var dynamicProperty in layerModel.Properties.DynamicProperties) { dynamicProperty.ApplyProperty(dataModel, layerModel); } }
public void Update(LayerModel layerModel, ModuleDataModel dataModel, bool isPreview = false) { layerModel.ApplyProperties(true); var newProperties = (AudioPropertiesModel)layerModel.Properties; if (_properties == null) { _properties = newProperties; } SubscribeToAudioChange(); if (_audioCapture == null || newProperties.Device != _properties.Device || newProperties.DeviceType != _properties.DeviceType) { var device = GetMmDevice(); if (device != null) { _audioCapture = _audioCaptureManager.GetAudioCapture(device, newProperties.DeviceType); } } _properties = newProperties; if (_audioCapture == null) { return; } _audioCapture.Pulse(); var direction = ((AudioPropertiesModel)layerModel.Properties).Direction; int currentLines; double currentHeight; if (direction == Direction.BottomToTop || direction == Direction.TopToBottom) { currentLines = (int)layerModel.Width; currentHeight = layerModel.Height; } else { currentLines = (int)layerModel.Height; currentHeight = layerModel.Width; } // Get a new line spectrum if the lines changed, it is null or the layer hasn't rendered for a few frames if (_lines != currentLines || _lineSpectrum == null || DateTime.Now - _lastRender > TimeSpan.FromMilliseconds(100)) { _lines = currentLines; _lineSpectrum = _audioCapture.GetLineSpectrum(_lines, ScalingStrategy.Decibel); } var newLineValues = _audioCapture.GetLineSpectrum(_lines, ScalingStrategy.Decibel)?.GetLineValues(currentHeight); if (newLineValues != null) { _lineValues = newLineValues; _lastRender = DateTime.Now; } }
public void Update(LayerModel layerModel, ModuleDataModel dataModel, bool isPreview = false) { layerModel.ApplyProperties(true); var newProperties = (AudioPropertiesModel)layerModel.Properties; if (_properties == null) { _properties = newProperties; } SubscribeToAudioChange(); if (_audioCapture == null || newProperties.Device != _properties.Device || newProperties.DeviceType != _properties.DeviceType) { var device = GetMmDevice(); if (device != null) { _audioCapture = _audioCaptureManager.GetAudioCapture(device, newProperties.DeviceType); } } _properties = newProperties; if (_audioCapture == null) { return; } _audioCapture.Pulse(); var direction = ((AudioPropertiesModel)layerModel.Properties).Direction; int currentLines; double currentHeight; if (direction == Direction.BottomToTop || direction == Direction.TopToBottom) { currentLines = (int)layerModel.Width; currentHeight = layerModel.Height; } else { currentLines = (int)layerModel.Height; currentHeight = layerModel.Width; } if (_lines != currentLines || _lineSpectrum == null) { _lines = currentLines; _lineSpectrum = _audioCapture.GetLineSpectrum(_lines, ScalingStrategy.Decibel); if (_lineSpectrum == null) { return; } } var newLineValues = _lineSpectrum?.GetLineValues(currentHeight); if (newLineValues != null) { _lineValues = newLineValues; } }