Example #1
0
        public static void WithPrimitiveBlend(this ID2D1DeviceContext context, D2D1_PRIMITIVE_BLEND mode, Action action)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            var old = context.GetPrimitiveBlend();

            try
            {
                context.SetPrimitiveBlend(mode);
                action();
            }
            finally
            {
                context.SetPrimitiveBlend(old);
            }
        }