Artemis.Profiles.Layers.Types.KeyPress.KeyPressType.KeyboardHookOnKeyDownCallback C# (CSharp) Метод

KeyboardHookOnKeyDownCallback() приватный Метод

private KeyboardHookOnKeyDownCallback ( KeyEventArgs e ) : void
e System.Windows.Forms.KeyEventArgs
Результат void
        private void KeyboardHookOnKeyDownCallback(KeyEventArgs e)
        {
            if (_layerModel == null)
                return;

            // Reset animation progress if layer wasn't drawn for 100ms
            if (new TimeSpan(0, 0, 0, 0, 100) < DateTime.Now - _layerModel.LastRender)
                return;

            lock (_keyPressLayers)
            {
                if (_keyPressLayers.Count >= 25)
                    return;
            }

            var keyMatch = _mainManager.DeviceManager.ActiveKeyboard.GetKeyPosition(e.KeyCode);
            if (keyMatch == null)
                return;

            lock (_keyPressLayers)
            {
                var properties = (KeyPressPropertiesModel) _layerModel.Properties;
                var layer = LayerModel.CreateLayer();
                layer.Properties.X = keyMatch.Value.X - properties.Scale/2;
                layer.Properties.Y = keyMatch.Value.Y - properties.Scale/2;
                layer.Properties.Width = properties.Scale;
                layer.Properties.Height = properties.Scale;
                layer.Properties.AnimationSpeed = properties.AnimationSpeed;
                layer.LayerAnimation = new GrowAnimation();

                // Setup the brush according to settings
                layer.Properties.Brush = properties.RandomColor
                    ? ColorHelpers.RandomizeBrush(properties.Brush)
                    : properties.Brush.CloneCurrentValue();

                _keyPressLayers.Add(layer);
            }
        }
    }