示例#1
0
        public static void WithTextAntialiasMode(this ID2D1DeviceContext context, D2D1_TEXT_ANTIALIAS_MODE mode, Action action)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

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

            var old = context.GetTextAntialiasMode();

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