using (var bitmap = new Bitmap(10, 10))
using (Graphics graphics = Graphics.FromImage(bitmap))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.GetHdc());
using (var image = new Bitmap(10, 10))
using (Graphics graphics = Graphics.FromImage(image))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.CompositingMode);
using (var image = new Bitmap(10, 10))
using (Graphics graphics = Graphics.FromImage(image))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.CompositingQuality);
using (var image = new Bitmap(10, 10))
using (Graphics graphics = Graphics.FromImage(image))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.DpiX);
using (var image = new Bitmap(10, 10))
using (Graphics graphics = Graphics.FromImage(image))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.DpiX);
using (var image = new Bitmap(10, 10))
using (Graphics graphics = Graphics.FromImage(image))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.Flush());
using (var image = new Bitmap(10, 10))
using (Graphics graphics = Graphics.FromImage(image))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.InterpolationMode);
using (var image = new Bitmap(10, 10))
using (Graphics graphics = Graphics.FromImage(image))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.PageScale);
using (var image = new Bitmap(10, 10))
using (Graphics graphics = Graphics.FromImage(image))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.PageUnit);
using (var image = new Bitmap(10, 10))
using (Graphics graphics = Graphics.FromImage(image))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.PixelOffsetMode);
[MemberData(nameof(RenderingOrigin_TestData))]
public void RenderingOrigin_SetToCustom_RendersExpected(Point renderingOrigin, Color[][] expectedRendering)
{
- Color empty = Color.FromArgb(255, 0, 0, 0);
Color red = Color.FromArgb(Color.Red.ToArgb());
using (var image = new Bitmap(3, 3))
using (var image = new Bitmap(10, 10))
using (Graphics graphics = Graphics.FromImage(image))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.RenderingOrigin);
using (var image = new Bitmap(10, 10))
using (Graphics graphics = Graphics.FromImage(image))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.SmoothingMode);
using (var image = new Bitmap(10, 10))
using (Graphics graphics = Graphics.FromImage(image))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.TextContrast);
using (var image = new Bitmap(10, 10))
using (Graphics graphics = Graphics.FromImage(image))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.TextRenderingHint);
using (Graphics graphics = Graphics.FromImage(image))
using (var matrix = new Matrix())
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.Transform);
using (var image = new Bitmap(10, 10))
using (Graphics graphics = Graphics.FromImage(image))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.ResetTransform());
using (Graphics graphics = Graphics.FromImage(image))
using (var matrix = new Matrix())
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.MultiplyTransform(matrix));
using (var image = new Bitmap(10, 10))
using (Graphics graphics = Graphics.FromImage(image))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.TranslateTransform(0, 0));
using (var image = new Bitmap(10, 10))
using (Graphics graphics = Graphics.FromImage(image))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.ScaleTransform(0, 0));
using (var image = new Bitmap(10, 10))
using (Graphics graphics = Graphics.FromImage(image))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.RotateTransform(0));
[InlineData(1, 1, 2, 2, 3, 3)]
public void CopyFromScreen_ValidRange_AffectsGraphics(int sourceX, int sourceY, int destinationX, int destinationY, int width, int height)
{
- Size screenSize = Helpers.GetHWndRect(IntPtr.Zero).Size;
-
Color color = Color.FromArgb(2, 3, 4);
using (var image = new Bitmap(10, 10))
using (Graphics graphics = Graphics.FromImage(image))
using (var image = new Bitmap(10, 10))
using (Graphics graphics = Graphics.FromImage(image))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.CopyFromScreen(0, 0, 0, 0, Size.Empty));
using (var image = new Bitmap(10, 10))
using (Graphics graphics = Graphics.FromImage(image))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Page, new Point[] { Point.Empty }));
using (var image = new Bitmap(10, 10))
using (Graphics graphics = Graphics.FromImage(image))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.GetNearestColor(Color.Red));
using (Graphics graphics = Graphics.FromImage(image))
using (var pen = new Pen(Color.Red))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.DrawArc(pen, new Rectangle(0, 0, 1, 1), 0, 90));
using (Graphics graphics = Graphics.FromImage(image))
using (var pen = new Pen(Color.Red))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.DrawRectangle(pen, new Rectangle(0, 0, 1, 1)));
using (Graphics graphics = Graphics.FromImage(image))
using (var pen = new Pen(Color.Red))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.DrawRectangles(pen, new Rectangle[2]));
using (Graphics graphics = Graphics.FromImage(image))
using (var pen = new Pen(Color.Red))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.DrawEllipse(pen, new Rectangle(0, 0, 1, 1)));
using (Graphics graphics = Graphics.FromImage(image))
using (var pen = new Pen(Color.Red))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.DrawPie(pen, new Rectangle(0, 0, 1, 1), 0, 90));
using (Graphics graphics = Graphics.FromImage(image))
using (var pen = new Pen(Color.Red))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.DrawPolygon(pen, new Point[2]));
using (var pen = new Pen(Color.Red))
using (var graphicsPath = new GraphicsPath())
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.DrawPath(pen, graphicsPath));
using (Graphics graphics = Graphics.FromImage(image))
using (var pen = new Pen(Color.Red))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.DrawCurve(pen, new Point[2]));
using (Graphics graphics = Graphics.FromImage(image))
using (var pen = new Pen(Color.Red))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.DrawClosedCurve(pen, new Point[3]));
using (Graphics graphics = Graphics.FromImage(image))
using (var pen = new Pen(Color.Red))
{
- IntPtr hdc = graphics.GetHdc();
+ graphics.GetHdc();
try
{
Assert.Throws<InvalidOperationException>(() => graphics.Clear(Color.Red));