diff --git a/Devices/Keyboard/Keys/RectangleKeyGroup.cs b/Devices/Keyboard/Keys/RectangleKeyGroup.cs index 4185a78..e02caba 100644 --- a/Devices/Keyboard/Keys/RectangleKeyGroup.cs +++ b/Devices/Keyboard/Keys/RectangleKeyGroup.cs @@ -17,10 +17,21 @@ namespace CUE.NET.Devices.Keyboard.Keys { #region Properties & Fields + private IList _keyCache; + + private RectangleF _rectangle; /// /// Gets or sets the rectangle the keys should be taken from. /// - public RectangleF Rectangle { get; set; } + public RectangleF Rectangle + { + get { return _rectangle; } + set + { + _rectangle = value; + _keyCache = null; + } + } /// /// Gets or sets the minimal percentage overlay a key must have with the to be taken into the keygroup. @@ -91,7 +102,7 @@ namespace CUE.NET.Devices.Keyboard.Keys /// The list containing the keys. protected override IList GetGroupKeys() { - return Keyboard.Where(x => RectangleHelper.CalculateIntersectPercentage(x.KeyRectangle, Rectangle) >= MinOverlayPercentage).ToList(); + return _keyCache ?? (_keyCache = Keyboard.Where(x => RectangleHelper.CalculateIntersectPercentage(x.KeyRectangle, Rectangle) >= MinOverlayPercentage).ToList()); } #endregion