From 8d1ac3b4ba385ff888609c44b9332e5a79f0b17e Mon Sep 17 00:00:00 2001 From: Julien Richard Date: Sat, 15 Jan 2022 09:02:18 +0100 Subject: [PATCH] One picker by surface --- src/Greenshot.Editor/Drawing/EmojiContainer.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Greenshot.Editor/Drawing/EmojiContainer.cs b/src/Greenshot.Editor/Drawing/EmojiContainer.cs index a477e1b2f..5845447dc 100644 --- a/src/Greenshot.Editor/Drawing/EmojiContainer.cs +++ b/src/Greenshot.Editor/Drawing/EmojiContainer.cs @@ -22,6 +22,7 @@ using System; using System.Drawing; using System.Drawing.Drawing2D; +using System.Linq; using System.Runtime.Serialization; using System.Windows; using System.Windows.Controls.Primitives; @@ -87,9 +88,7 @@ namespace Greenshot.Editor.Drawing { _currentContainer = this; - CreatePickerControl(); - - _parent.Controls.Add(_emojiPickerHost); + GetOrCreatePickerControl(); var absRectangle = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height); var displayRectangle = Parent.ToSurfaceCoordinates(absRectangle); @@ -102,8 +101,10 @@ namespace Greenshot.Editor.Drawing _emojiPicker.ShowPopup(true); } - private void CreatePickerControl() + private void GetOrCreatePickerControl() { + // Create one picker control by surface + _emojiPickerHost = _parent.Controls.Find("EmojiPickerHost", false).OfType().FirstOrDefault(); if (_emojiPickerHost == null) { _emojiPicker = new Picker(); @@ -116,6 +117,9 @@ namespace Greenshot.Editor.Drawing _emojiPickerHost = new ElementHost(); _emojiPickerHost.Dock = DockStyle.None; _emojiPickerHost.Child = _emojiPicker; + _emojiPickerHost.Name = "EmojiPickerHost"; + + _parent.Controls.Add(_emojiPickerHost); } }