Ejemplo n.º 1
0
        // Draws this image to a graphics object.  The drawing command originates on the graphics
        // object, but a graphics object generally has no idea how to render a given image.  So,
        // it passes the call to the actual image.  This version crops the image to the given
        // dimensions and allows the user to specify a rectangle within the image to draw.
        internal void DrawUnstretched(Graphics graphics, Rectangle targetRect)
        {
            Rectangle copy = targetRect;

            copy.X += (int)graphics.Transform.OffsetX;
            copy.Y += (int)graphics.Transform.OffsetY;

            using (WindowsGraphics wg = WindowsGraphics.FromGraphics(graphics, ApplyGraphicsProperties.Clipping))
            {
                IntPtr dc = wg.GetHdc();
                DrawIcon(dc, Rectangle.Empty, copy, false);
            }
        }
Ejemplo n.º 2
0
        // Draws this image to a graphics object.  The drawing command originates on the graphics
        // object, but a graphics object generally has no idea how to render a given image.  So,
        // it passes the call to the actual image.  This version stretches the image to the given
        // dimensions and allows the user to specify a rectangle within the image to draw.
        internal void Draw(Graphics graphics, Rectangle targetRect)
        {
            Rectangle copy = targetRect;

            using Matrix transform = graphics.Transform;
            PointF offset = transform.Offset;

            copy.X += (int)offset.X;
            copy.Y += (int)offset.Y;

            using (WindowsGraphics wg = WindowsGraphics.FromGraphics(graphics, ApplyGraphicsProperties.Clipping))
            {
                IntPtr dc = wg.GetHdc();
                DrawIcon(dc, Rectangle.Empty, copy, true);
            }
        }
Ejemplo n.º 3
0
        internal void DrawUnstretched(Graphics graphics, Rectangle targetRect)
        {
            Rectangle rectangle = targetRect;

            rectangle.X += (int)graphics.Transform.OffsetX;
            rectangle.Y += (int)graphics.Transform.OffsetY;
            WindowsGraphics graphics2 = WindowsGraphics.FromGraphics(graphics, ApplyGraphicsProperties.Clipping);
            IntPtr          hdc       = graphics2.GetHdc();

            try
            {
                this.DrawIcon(hdc, Rectangle.Empty, rectangle, false);
            }
            finally
            {
                graphics2.Dispose();
            }
        }
Ejemplo n.º 4
0
        /// <include file='doc\Icon.uex' path='docs/doc[@for="Icon.Draw"]/*' />
        /// <devdoc>
        ///     Draws this image to a graphics object.  The drawing command originates on the graphics
        ///     object, but a graphics object generally has no idea how to render a given image.  So,
        ///     it passes the call to the actual image.  This version stretches the image to the given
        ///     dimensions and allows the user to specify a rectangle within the image to draw.
        /// </devdoc>
        internal void Draw(Graphics graphics, Rectangle targetRect)
        {
            Rectangle copy = targetRect;

            copy.X += (int)graphics.Transform.OffsetX;
            copy.Y += (int)graphics.Transform.OffsetY;

            WindowsGraphics wg = WindowsGraphics.FromGraphics(graphics, ApplyGraphicsProperties.Clipping);
            IntPtr          dc = wg.GetHdc();

            try
            {
                DrawIcon(dc, Rectangle.Empty, copy, true);
            }
            finally
            {
                wg.Dispose();
            }
        }