public static void Energize(this UIElement source)
        {
            source.Hook();
            source.Measure(new Size(2560, 1440));
            source.Arrange(new Rect(source.DesiredSize));

            LightweigtTestsUtils.RunInNewDispathcerFrame(source, () => { });
        }
        public static byte[] TakeSnapshot(this UIElement source, Size size)
        {
            if (source.Hook())
            {
                return(source.GetJpgImage(2));
            }

            source.Measure(size);
            source.Arrange(new Rect(size));

            byte[] snapshot = null;
            LightweigtTestsUtils.RunInNewDispathcerFrame(source, () =>
            {
                snapshot = source.GetJpgImage(2);
            });

            if (snapshot == null)
            {
                throw new Exception(":(");
            }
            return(snapshot);
        }