internal static void CheckGraphicsForState(Graphics?graphics, DrawingEventFlags flags)
        {
            if (graphics is null || !flags.HasFlag(DrawingEventFlags.CheckState) ||
                flags.HasFlag(DrawingEventFlags.GraphicsStateUnclean))
            {
                return;
            }

            // Check to see if we've actually corrupted the state
            graphics.GetContextInfo(out PointF offset, out Region? clip);

            using (clip)
            {
                bool isInfinite = clip?.IsInfinite(graphics) ?? true;
                Debug.Assert(offset.IsEmpty, "transform has been modified");
                Debug.Assert(isInfinite, "clipping as been applied");
            }
        }
        internal static void CheckGraphicsForState(Graphics?graphics, DrawingEventFlags flags)
        {
            if (graphics is null || !flags.HasFlag(DrawingEventFlags.CheckState) ||
                flags.HasFlag(DrawingEventFlags.GraphicsStateUnclean))
            {
                return;
            }

            // Check to see if we've actually corrupted the state
            object[] data = (object[])graphics.GetContextInfo();

            using Region clipRegion     = (Region)data[0];
            using Matrix worldTransform = (Matrix)data[1];

            float[] elements   = worldTransform?.Elements !;
            bool    isInfinite = clipRegion.IsInfinite(graphics);

            Debug.Assert((int)elements[4] == 0 && (int)elements[5] == 0, "transform has been modified");
            Debug.Assert(isInfinite, "clipping as been applied");
        }