Add a call to "OnImageLoaded" to "RadPictureBoxelement.PasteImage()" method or create an event like "ImagePasted" ot be able to tract an image change at this point.
For me I solved this via an Harmony patch that adds a call to OnImageLoaded() on PasteImage() long time ago. Not really elegant, but I'm a noob in patching with Harmony.
Just want to leave it here for anyone that want ot use this solution too or for Telerik to implement a native way to expose an image change via PasteImage.
[HarmonyPatch(typeof(RadPictureBoxElement))]
[HarmonyPatch("PasteImage")]
public class RadPictureBoxElement_PasteImageFixes
{
private static readonly Dictionary<RadPictureBoxElement, Image> images = [];
public static void Prefix(object __instance)
{
if (__instance is RadPictureBoxElement pb)
{
// Remember our image
images.Remove(pb);
images.Add(pb, pb.Image);
}
}
public static void Postfix(object __instance)
{
if (__instance is RadPictureBoxElement pb && images.TryGetValue(pb, out var image) && pb.Image != 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);
}
}
}