ensure remove picture box also on the same image

This commit is contained in:
2025-05-20 11:15:09 +02:00
parent 247033dbeb
commit 58bb22df90

View File

@@ -21,14 +21,14 @@ public class RadPictureBoxElement_PasteImageFixes
public static void Postfix(object __instance)
{
if (__instance is RadPictureBoxElement pb && images.TryGetValue(pb, out var image) && pb.Image != image)
if (__instance is RadPictureBoxElement pb && images.TryGetValue(pb, out var image))
{
// Remove first to avoid conflicts on error
images.Remove(pb);
// Call "OnImageLoaded"
var method = typeof(RadPictureBoxElement).GetMethod("OnImageLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
method.Invoke(pb, null);
if (pb.Image != image)
typeof(RadPictureBoxElement).GetMethod("OnImageLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)?.Invoke(pb, null);
}
}
}