Exemple #1
0
 internal PaintEventArgs(
     Gdi32.HDC hdc,
     Rectangle clipRect,
     DrawingEventFlags flags = DrawingEventFlags.CheckState)
 {
     _event = new DrawingEventArgs(hdc, clipRect, flags);
 }
Exemple #2
0
 internal PaintEventArgs(
     Graphics graphics,
     Rectangle clipRect,
     DrawingEventFlags flags)
 {
     _event = new DrawingEventArgs(graphics, clipRect, flags);
     SaveStateIfNeeded(graphics);
 }
 /// <summary>
 ///  Internal version of constructor for performance. We try to avoid getting the graphics object until needed.
 /// </summary>
 public DrawingEventArgs(
     Gdi32.HDC dc,
     Rectangle clipRect,
     DrawingEventFlags flags)
 {
     _hdc          = dc;
     _graphics     = null;
     _oldPalette   = default;
     Flags         = flags;
     ClipRectangle = clipRect;
 }
 public DrawingEventArgs(
     Graphics graphics,
     Rectangle clipRect,
     DrawingEventFlags flags)
 {
     _graphics   = graphics.OrThrowIfNull();
     _hdc        = default;
     _oldPalette = default;
     CheckGraphicsForState(graphics, flags);
     ClipRectangle = clipRect;
     Flags         = flags;
 }
Exemple #5
0
 public DrawingEventArgs(
     Graphics graphics,
     Rectangle clipRect,
     DrawingEventFlags flags)
 {
     _graphics   = graphics ?? throw new ArgumentNullException(nameof(graphics));
     _hdc        = default;
     _oldPalette = default;
     CheckGraphicsForState(graphics, flags);
     ClipRectangle = clipRect;
     Flags         = flags;
 }
        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");
        }
        /// <summary>
        ///  Internal version of constructor for performance. We try to avoid getting the graphics object until needed.
        /// </summary>
        public DrawingEventArgs(
            Gdi32.HDC dc,
            Rectangle clipRect,
            DrawingEventFlags flags)
        {
            ArgumentValidation.ThrowIfNull(dc);

#if DEBUG
            Gdi32.OBJ type = Gdi32.GetObjectType(dc);
            Debug.Assert(type == Gdi32.OBJ.DC ||
                         type == Gdi32.OBJ.ENHMETADC ||
                         type == Gdi32.OBJ.MEMDC ||
                         type == Gdi32.OBJ.METADC);
#endif

            _hdc          = dc;
            _graphics     = null;
            _oldPalette   = default;
            Flags         = flags;
            ClipRectangle = clipRect;
        }
Exemple #9
0
        /// <summary>
        ///  Internal version of constructor for performance. We try to avoid getting the graphics object until needed.
        /// </summary>
        public DrawingEventArgs(
            Gdi32.HDC dc,
            Rectangle clipRect,
            DrawingEventFlags flags)
        {
            if (dc.IsNull)
            {
                throw new ArgumentNullException(nameof(dc));
            }

#if DEBUG
            Gdi32.OBJ type = Gdi32.GetObjectType(dc);
            Debug.Assert(type == Gdi32.OBJ.DC ||
                         type == Gdi32.OBJ.ENHMETADC ||
                         type == Gdi32.OBJ.MEMDC ||
                         type == Gdi32.OBJ.METADC);
#endif

            _hdc          = dc;
            _graphics     = null;
            _oldPalette   = default;
            Flags         = flags;
            ClipRectangle = clipRect;
        }