using System;
using System.Runtime.InteropServices;
+#nullable enable
+
internal static partial class Interop
{
internal static partial class Gdi32
{
[DllImport(Libraries.Gdi32, ExactSpelling = true, CharSet = CharSet.Unicode)]
- public static extern IntPtr CreateDCW(string pwszDriver, string pwszDevice, string pszPort, IntPtr pdm);
+ public static extern IntPtr CreateDCW(string pwszDriver, string pwszDevice, string? pszPort, IntPtr pdm);
}
}
using System;
using System.Runtime.InteropServices;
+#nullable enable
+
internal static partial class Interop
{
internal static partial class Gdi32
{
[DllImport(Libraries.Gdi32, ExactSpelling = true, CharSet = CharSet.Unicode)]
- public static extern IntPtr CreateICW(string pszDriver, string pszDevice, string pszPort, IntPtr pdm);
+ public static extern IntPtr CreateICW(string pszDriver, string pszDevice, string? pszPort, IntPtr pdm);
}
}
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
public uint grfStateBits;
public uint reserved;
- public string GetName() => Marshal.PtrToStringUni(pwcsName);
+ public string? GetName() => Marshal.PtrToStringUni(pwcsName);
/// <summary>
/// Caller is responsible for freeing the name memory.
/// <summary>
/// Callee is repsonsible for allocating the name memory.
/// </summary>
- public void AllocName(string name)
+ public void AllocName(string? name)
{
pwcsName = Marshal.StringToCoTaskMemUni(name);
}
public void Dispose() { }
~BufferedGraphics() { }
public void Render() { }
- public void Render(System.Drawing.Graphics target) { }
+ public void Render(System.Drawing.Graphics? target) { }
public void Render(System.IntPtr targetDC) { }
}
public sealed partial class BufferedGraphicsContext : System.IDisposable
public CharacterRange(int First, int Length) { throw null; }
public int First { get { throw null; } set { } }
public int Length { get { throw null; } set { } }
- public override bool Equals(object obj) { throw null; }
+ public override bool Equals(object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public static bool operator ==(System.Drawing.CharacterRange cr1, System.Drawing.CharacterRange cr2) { throw null; }
public static bool operator !=(System.Drawing.CharacterRange cr1, System.Drawing.CharacterRange cr2) { throw null; }
public System.Drawing.GraphicsUnit Unit { get { throw null; } }
public object Clone() { throw null; }
public void Dispose() { }
- public override bool Equals(object obj) { throw null; }
+ public override bool Equals(object? obj) { throw null; }
~Font() { }
public static System.Drawing.Font FromHdc(System.IntPtr hdc) { throw null; }
public static System.Drawing.Font FromHfont(System.IntPtr hfont) { throw null; }
{
public FontFamily(System.Drawing.Text.GenericFontFamilies genericFamily) { }
public FontFamily(string name) { }
- public FontFamily(string name, System.Drawing.Text.FontCollection fontCollection) { }
+ public FontFamily(string name, System.Drawing.Text.FontCollection? fontCollection) { }
public static System.Drawing.FontFamily[] Families { get { throw null; } }
public static System.Drawing.FontFamily GenericMonospace { get { throw null; } }
public static System.Drawing.FontFamily GenericSansSerif { get { throw null; } }
public static System.Drawing.FontFamily GenericSerif { get { throw null; } }
public string Name { get { throw null; } }
public void Dispose() { }
- public override bool Equals(object obj) { throw null; }
+ public override bool Equals(object? obj) { throw null; }
~FontFamily() { }
public int GetCellAscent(System.Drawing.FontStyle style) { throw null; }
public int GetCellDescent(System.Drawing.FontStyle style) { throw null; }
public void DrawImage(System.Drawing.Image image, System.Drawing.PointF point) { }
public void DrawImage(System.Drawing.Image image, System.Drawing.PointF[] destPoints) { }
public void DrawImage(System.Drawing.Image image, System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes imageAttr) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes imageAttr, System.Drawing.Graphics.DrawImageAbort callback) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes imageAttr, System.Drawing.Graphics.DrawImageAbort callback, int callbackData) { }
+ public void DrawImage(System.Drawing.Image image, System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
+ public void DrawImage(System.Drawing.Image image, System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttr, System.Drawing.Graphics.DrawImageAbort? callback) { }
+ public void DrawImage(System.Drawing.Image image, System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttr, System.Drawing.Graphics.DrawImageAbort? callback, int callbackData) { }
public void DrawImage(System.Drawing.Image image, System.Drawing.Point[] destPoints) { }
public void DrawImage(System.Drawing.Image image, System.Drawing.Point[] destPoints, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Point[] destPoints, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes imageAttr) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Point[] destPoints, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes imageAttr, System.Drawing.Graphics.DrawImageAbort callback) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Point[] destPoints, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes imageAttr, System.Drawing.Graphics.DrawImageAbort callback, int callbackData) { }
+ public void DrawImage(System.Drawing.Image image, System.Drawing.Point[] destPoints, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
+ public void DrawImage(System.Drawing.Image image, System.Drawing.Point[] destPoints, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttr, System.Drawing.Graphics.DrawImageAbort? callback) { }
+ public void DrawImage(System.Drawing.Image image, System.Drawing.Point[] destPoints, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttr, System.Drawing.Graphics.DrawImageAbort? callback, int callbackData) { }
public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle rect) { }
public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit) { }
public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, System.Drawing.GraphicsUnit srcUnit) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes imageAttr) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes imageAttr, System.Drawing.Graphics.DrawImageAbort callback) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes imageAttrs, System.Drawing.Graphics.DrawImageAbort callback, System.IntPtr callbackData) { }
+ public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
+ public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttr, System.Drawing.Graphics.DrawImageAbort? callback) { }
+ public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttrs, System.Drawing.Graphics.DrawImageAbort? callback, System.IntPtr callbackData) { }
public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, System.Drawing.GraphicsUnit srcUnit) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes imageAttrs) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes imageAttrs, System.Drawing.Graphics.DrawImageAbort callback) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes imageAttrs, System.Drawing.Graphics.DrawImageAbort callback, System.IntPtr callbackData) { }
+ public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttrs) { }
+ public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttrs, System.Drawing.Graphics.DrawImageAbort? callback) { }
+ public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttrs, System.Drawing.Graphics.DrawImageAbort? callback, System.IntPtr callbackData) { }
public void DrawImage(System.Drawing.Image image, System.Drawing.RectangleF rect) { }
public void DrawImage(System.Drawing.Image image, System.Drawing.RectangleF destRect, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit) { }
public void DrawImage(System.Drawing.Image image, int x, int y) { }
public void DrawRectangle(System.Drawing.Pen pen, float x, float y, float width, float height) { }
public void DrawRectangles(System.Drawing.Pen pen, System.Drawing.RectangleF[] rects) { }
public void DrawRectangles(System.Drawing.Pen pen, System.Drawing.Rectangle[] rects) { }
- public void DrawString(string s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.PointF point) { }
- public void DrawString(string s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.PointF point, System.Drawing.StringFormat format) { }
- public void DrawString(string s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.RectangleF layoutRectangle) { }
- public void DrawString(string s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.RectangleF layoutRectangle, System.Drawing.StringFormat format) { }
- public void DrawString(string s, System.Drawing.Font font, System.Drawing.Brush brush, float x, float y) { }
- public void DrawString(string s, System.Drawing.Font font, System.Drawing.Brush brush, float x, float y, System.Drawing.StringFormat format) { }
+ public void DrawString(string? s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.PointF point) { }
+ public void DrawString(string? s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.PointF point, System.Drawing.StringFormat? format) { }
+ public void DrawString(string? s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.RectangleF layoutRectangle) { }
+ public void DrawString(string? s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.RectangleF layoutRectangle, System.Drawing.StringFormat? format) { }
+ public void DrawString(string? s, System.Drawing.Font font, System.Drawing.Brush brush, float x, float y) { }
+ public void DrawString(string? s, System.Drawing.Font font, System.Drawing.Brush brush, float x, float y, System.Drawing.StringFormat? format) { }
public void EndContainer(System.Drawing.Drawing2D.GraphicsContainer container) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point destPoint, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point destPoint, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point destPoint, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes imageAttr) { }
+ public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point destPoint, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point destPoint, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point destPoint, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point destPoint, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes imageAttr) { }
+ public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point destPoint, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF destPoint, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF destPoint, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF destPoint, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes imageAttr) { }
+ public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF destPoint, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF destPoint, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF destPoint, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF destPoint, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes imageAttr) { }
+ public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF destPoint, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF[] destPoints, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF[] destPoints, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF[] destPoints, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes imageAttr) { }
+ public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF[] destPoints, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes imageAttr) { }
+ public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point[] destPoints, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point[] destPoints, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point[] destPoints, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes imageAttr) { }
+ public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point[] destPoints, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point[] destPoints, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point[] destPoints, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point[] destPoints, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes imageAttr) { }
+ public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point[] destPoints, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Rectangle destRect, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Rectangle destRect, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Rectangle destRect, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes imageAttr) { }
+ public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Rectangle destRect, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Rectangle destRect, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Rectangle destRect, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Rectangle destRect, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes imageAttr) { }
+ public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Rectangle destRect, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.RectangleF destRect, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.RectangleF destRect, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.RectangleF destRect, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes imageAttr) { }
+ public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.RectangleF destRect, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.RectangleF destRect, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.RectangleF destRect, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.RectangleF destRect, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes imageAttr) { }
+ public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.RectangleF destRect, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
public void ExcludeClip(System.Drawing.Rectangle rect) { }
public void ExcludeClip(System.Drawing.Region region) { }
public void FillClosedCurve(System.Drawing.Brush brush, System.Drawing.PointF[] points) { }
public bool IsVisible(int x, int y, int width, int height) { throw null; }
public bool IsVisible(float x, float y) { throw null; }
public bool IsVisible(float x, float y, float width, float height) { throw null; }
- public System.Drawing.Region[] MeasureCharacterRanges(string text, System.Drawing.Font font, System.Drawing.RectangleF layoutRect, System.Drawing.StringFormat stringFormat) { throw null; }
- public System.Drawing.SizeF MeasureString(string text, System.Drawing.Font font) { throw null; }
- public System.Drawing.SizeF MeasureString(string text, System.Drawing.Font font, System.Drawing.PointF origin, System.Drawing.StringFormat stringFormat) { throw null; }
- public System.Drawing.SizeF MeasureString(string text, System.Drawing.Font font, System.Drawing.SizeF layoutArea) { throw null; }
- public System.Drawing.SizeF MeasureString(string text, System.Drawing.Font font, System.Drawing.SizeF layoutArea, System.Drawing.StringFormat stringFormat) { throw null; }
- public System.Drawing.SizeF MeasureString(string text, System.Drawing.Font font, System.Drawing.SizeF layoutArea, System.Drawing.StringFormat stringFormat, out int charactersFitted, out int linesFilled) { throw null; }
- public System.Drawing.SizeF MeasureString(string text, System.Drawing.Font font, int width) { throw null; }
- public System.Drawing.SizeF MeasureString(string text, System.Drawing.Font font, int width, System.Drawing.StringFormat format) { throw null; }
+ public System.Drawing.Region[] MeasureCharacterRanges(string? text, System.Drawing.Font font, System.Drawing.RectangleF layoutRect, System.Drawing.StringFormat? stringFormat) { throw null; }
+ public System.Drawing.SizeF MeasureString(string? text, System.Drawing.Font font) { throw null; }
+ public System.Drawing.SizeF MeasureString(string? text, System.Drawing.Font font, System.Drawing.PointF origin, System.Drawing.StringFormat? stringFormat) { throw null; }
+ public System.Drawing.SizeF MeasureString(string? text, System.Drawing.Font font, System.Drawing.SizeF layoutArea) { throw null; }
+ public System.Drawing.SizeF MeasureString(string? text, System.Drawing.Font font, System.Drawing.SizeF layoutArea, System.Drawing.StringFormat? stringFormat) { throw null; }
+ public System.Drawing.SizeF MeasureString(string? text, System.Drawing.Font font, System.Drawing.SizeF layoutArea, System.Drawing.StringFormat? stringFormat, out int charactersFitted, out int linesFilled) { throw null; }
+ public System.Drawing.SizeF MeasureString(string? text, System.Drawing.Font font, int width) { throw null; }
+ public System.Drawing.SizeF MeasureString(string? text, System.Drawing.Font font, int width, System.Drawing.StringFormat? format) { throw null; }
public void MultiplyTransform(System.Drawing.Drawing2D.Matrix matrix) { }
public void MultiplyTransform(System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Drawing2D.MatrixOrder order) { }
public void ReleaseHdc() { }
public int Width { get { throw null; } }
public object Clone() { throw null; }
public void Dispose() { }
- public static System.Drawing.Icon ExtractAssociatedIcon(string filePath) { throw null; }
+ public static System.Drawing.Icon? ExtractAssociatedIcon(string filePath) { throw null; }
~Icon() { }
public static System.Drawing.Icon FromHandle(System.IntPtr handle) { throw null; }
public void Save(System.IO.Stream outputStream) { }
public System.Drawing.Size Size { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute(null)]
[System.ComponentModel.LocalizableAttribute(false)]
- public object Tag { get { throw null; } set { } }
+ public object? Tag { get { throw null; } set { } }
public float VerticalResolution { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DefaultValueAttribute(false)]
public static System.Drawing.Image FromStream(System.IO.Stream stream, bool useEmbeddedColorManagement) { throw null; }
public static System.Drawing.Image FromStream(System.IO.Stream stream, bool useEmbeddedColorManagement, bool validateImageData) { throw null; }
public System.Drawing.RectangleF GetBounds(ref System.Drawing.GraphicsUnit pageUnit) { throw null; }
- public System.Drawing.Imaging.EncoderParameters GetEncoderParameterList(System.Guid encoder) { throw null; }
+ public System.Drawing.Imaging.EncoderParameters? GetEncoderParameterList(System.Guid encoder) { throw null; }
public int GetFrameCount(System.Drawing.Imaging.FrameDimension dimension) { throw null; }
public static int GetPixelFormatSize(System.Drawing.Imaging.PixelFormat pixfmt) { throw null; }
- public System.Drawing.Imaging.PropertyItem GetPropertyItem(int propid) { throw null; }
- public System.Drawing.Image GetThumbnailImage(int thumbWidth, int thumbHeight, System.Drawing.Image.GetThumbnailImageAbort callback, System.IntPtr callbackData) { throw null; }
+ public System.Drawing.Imaging.PropertyItem? GetPropertyItem(int propid) { throw null; }
+ public System.Drawing.Image GetThumbnailImage(int thumbWidth, int thumbHeight, System.Drawing.Image.GetThumbnailImageAbort? callback, System.IntPtr callbackData) { throw null; }
public static bool IsAlphaPixelFormat(System.Drawing.Imaging.PixelFormat pixfmt) { throw null; }
public static bool IsCanonicalPixelFormat(System.Drawing.Imaging.PixelFormat pixfmt) { throw null; }
public static bool IsExtendedPixelFormat(System.Drawing.Imaging.PixelFormat pixfmt) { throw null; }
public void RemovePropertyItem(int propid) { }
public void RotateFlip(System.Drawing.RotateFlipType rotateFlipType) { }
- public void Save(System.IO.Stream stream, System.Drawing.Imaging.ImageCodecInfo encoder, System.Drawing.Imaging.EncoderParameters encoderParams) { }
+ public void Save(System.IO.Stream stream, System.Drawing.Imaging.ImageCodecInfo encoder, System.Drawing.Imaging.EncoderParameters? encoderParams) { }
public void Save(System.IO.Stream stream, System.Drawing.Imaging.ImageFormat format) { }
public void Save(string filename) { }
- public void Save(string filename, System.Drawing.Imaging.ImageCodecInfo encoder, System.Drawing.Imaging.EncoderParameters encoderParams) { }
+ public void Save(string filename, System.Drawing.Imaging.ImageCodecInfo encoder, System.Drawing.Imaging.EncoderParameters? encoderParams) { }
public void Save(string filename, System.Drawing.Imaging.ImageFormat format) { }
- public void SaveAdd(System.Drawing.Image image, System.Drawing.Imaging.EncoderParameters encoderParams) { }
- public void SaveAdd(System.Drawing.Imaging.EncoderParameters encoderParams) { }
+ public void SaveAdd(System.Drawing.Image image, System.Drawing.Imaging.EncoderParameters? encoderParams) { }
+ public void SaveAdd(System.Drawing.Imaging.EncoderParameters? encoderParams) { }
public int SelectActiveFrame(System.Drawing.Imaging.FrameDimension dimension, int frameIndex) { throw null; }
public void SetPropertyItem(System.Drawing.Imaging.PropertyItem propitem) { }
void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
{
internal ImageAnimator() { }
public static void Animate(System.Drawing.Image image, System.EventHandler onFrameChangedHandler) { }
- public static bool CanAnimate(System.Drawing.Image image) { throw null; }
+ public static bool CanAnimate(System.Drawing.Image? image) { throw null; }
public static void StopAnimate(System.Drawing.Image image, System.EventHandler onFrameChangedHandler) { }
public static void UpdateFrames() { }
public static void UpdateFrames(System.Drawing.Image image) { }
public static System.Drawing.Region FromHrgn(System.IntPtr hrgn) { throw null; }
public System.Drawing.RectangleF GetBounds(System.Drawing.Graphics g) { throw null; }
public System.IntPtr GetHrgn(System.Drawing.Graphics g) { throw null; }
- public System.Drawing.Drawing2D.RegionData GetRegionData() { throw null; }
+ public System.Drawing.Drawing2D.RegionData? GetRegionData() { throw null; }
public System.Drawing.RectangleF[] GetRegionScans(System.Drawing.Drawing2D.Matrix matrix) { throw null; }
public void Intersect(System.Drawing.Drawing2D.GraphicsPath path) { }
public void Intersect(System.Drawing.Rectangle rect) { }
public bool IsEmpty(System.Drawing.Graphics g) { throw null; }
public bool IsInfinite(System.Drawing.Graphics g) { throw null; }
public bool IsVisible(System.Drawing.Point point) { throw null; }
- public bool IsVisible(System.Drawing.Point point, System.Drawing.Graphics g) { throw null; }
+ public bool IsVisible(System.Drawing.Point point, System.Drawing.Graphics? g) { throw null; }
public bool IsVisible(System.Drawing.PointF point) { throw null; }
- public bool IsVisible(System.Drawing.PointF point, System.Drawing.Graphics g) { throw null; }
+ public bool IsVisible(System.Drawing.PointF point, System.Drawing.Graphics? g) { throw null; }
public bool IsVisible(System.Drawing.Rectangle rect) { throw null; }
- public bool IsVisible(System.Drawing.Rectangle rect, System.Drawing.Graphics g) { throw null; }
+ public bool IsVisible(System.Drawing.Rectangle rect, System.Drawing.Graphics? g) { throw null; }
public bool IsVisible(System.Drawing.RectangleF rect) { throw null; }
- public bool IsVisible(System.Drawing.RectangleF rect, System.Drawing.Graphics g) { throw null; }
+ public bool IsVisible(System.Drawing.RectangleF rect, System.Drawing.Graphics? g) { throw null; }
public bool IsVisible(int x, int y, System.Drawing.Graphics g) { throw null; }
public bool IsVisible(int x, int y, int width, int height) { throw null; }
- public bool IsVisible(int x, int y, int width, int height, System.Drawing.Graphics g) { throw null; }
+ public bool IsVisible(int x, int y, int width, int height, System.Drawing.Graphics? g) { throw null; }
public bool IsVisible(float x, float y) { throw null; }
- public bool IsVisible(float x, float y, System.Drawing.Graphics g) { throw null; }
+ public bool IsVisible(float x, float y, System.Drawing.Graphics? g) { throw null; }
public bool IsVisible(float x, float y, float width, float height) { throw null; }
- public bool IsVisible(float x, float y, float width, float height, System.Drawing.Graphics g) { throw null; }
+ public bool IsVisible(float x, float y, float width, float height, System.Drawing.Graphics? g) { throw null; }
public void MakeEmpty() { }
public void MakeInfinite() { }
public void ReleaseHrgn(System.IntPtr regionHandle) { }
}
public static partial class SystemFonts
{
- public static System.Drawing.Font CaptionFont { get { throw null; } }
+ public static System.Drawing.Font? CaptionFont { get { throw null; } }
public static System.Drawing.Font DefaultFont { get { throw null; } }
public static System.Drawing.Font DialogFont { get { throw null; } }
- public static System.Drawing.Font IconTitleFont { get { throw null; } }
- public static System.Drawing.Font MenuFont { get { throw null; } }
- public static System.Drawing.Font MessageBoxFont { get { throw null; } }
- public static System.Drawing.Font SmallCaptionFont { get { throw null; } }
- public static System.Drawing.Font StatusFont { get { throw null; } }
- public static System.Drawing.Font GetFontByName(string systemFontName) { throw null; }
+ public static System.Drawing.Font? IconTitleFont { get { throw null; } }
+ public static System.Drawing.Font? MenuFont { get { throw null; } }
+ public static System.Drawing.Font? MessageBoxFont { get { throw null; } }
+ public static System.Drawing.Font? SmallCaptionFont { get { throw null; } }
+ public static System.Drawing.Font? StatusFont { get { throw null; } }
+ public static System.Drawing.Font? GetFontByName(string systemFontName) { throw null; }
}
public static partial class SystemIcons
{
public TextureBrush(System.Drawing.Image image, System.Drawing.Drawing2D.WrapMode wrapMode, System.Drawing.Rectangle dstRect) { }
public TextureBrush(System.Drawing.Image image, System.Drawing.Drawing2D.WrapMode wrapMode, System.Drawing.RectangleF dstRect) { }
public TextureBrush(System.Drawing.Image image, System.Drawing.Rectangle dstRect) { }
- public TextureBrush(System.Drawing.Image image, System.Drawing.Rectangle dstRect, System.Drawing.Imaging.ImageAttributes imageAttr) { }
+ public TextureBrush(System.Drawing.Image image, System.Drawing.Rectangle dstRect, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
public TextureBrush(System.Drawing.Image image, System.Drawing.RectangleF dstRect) { }
- public TextureBrush(System.Drawing.Image image, System.Drawing.RectangleF dstRect, System.Drawing.Imaging.ImageAttributes imageAttr) { }
+ public TextureBrush(System.Drawing.Image image, System.Drawing.RectangleF dstRect, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
public System.Drawing.Image Image { get { throw null; } }
public System.Drawing.Drawing2D.Matrix Transform { get { throw null; } set { } }
public System.Drawing.Drawing2D.WrapMode WrapMode { get { throw null; } set { } }
public ToolboxBitmapAttribute(string imageFile) { }
public ToolboxBitmapAttribute(System.Type t) { }
public ToolboxBitmapAttribute(System.Type t, string name) { }
- public override bool Equals(object value) { throw null; }
+ public override bool Equals(object? value) { throw null; }
public override int GetHashCode() { throw null; }
- public System.Drawing.Image GetImage(object component) { throw null; }
- public System.Drawing.Image GetImage(object component, bool large) { throw null; }
- public System.Drawing.Image GetImage(System.Type type) { throw null; }
- public System.Drawing.Image GetImage(System.Type type, bool large) { throw null; }
- public System.Drawing.Image GetImage(System.Type type, string imgName, bool large) { throw null; }
- public static System.Drawing.Image GetImageFromResource(System.Type t, string imageName, bool large) { throw null; }
+ public System.Drawing.Image? GetImage(object? component) { throw null; }
+ public System.Drawing.Image? GetImage(object? component, bool large) { throw null; }
+ public System.Drawing.Image? GetImage(System.Type type) { throw null; }
+ public System.Drawing.Image? GetImage(System.Type type, bool large) { throw null; }
+ public System.Drawing.Image? GetImage(System.Type type, string? imgName, bool large) { throw null; }
+ public static System.Drawing.Image? GetImageFromResource(System.Type t, string? imageName, bool large) { throw null; }
}
}
namespace System.Drawing.Design
}
public partial class CustomLineCap : System.MarshalByRefObject, System.ICloneable, System.IDisposable
{
- public CustomLineCap(System.Drawing.Drawing2D.GraphicsPath fillPath, System.Drawing.Drawing2D.GraphicsPath strokePath) { }
- public CustomLineCap(System.Drawing.Drawing2D.GraphicsPath fillPath, System.Drawing.Drawing2D.GraphicsPath strokePath, System.Drawing.Drawing2D.LineCap baseCap) { }
- public CustomLineCap(System.Drawing.Drawing2D.GraphicsPath fillPath, System.Drawing.Drawing2D.GraphicsPath strokePath, System.Drawing.Drawing2D.LineCap baseCap, float baseInset) { }
+ public CustomLineCap(System.Drawing.Drawing2D.GraphicsPath? fillPath, System.Drawing.Drawing2D.GraphicsPath? strokePath) { }
+ public CustomLineCap(System.Drawing.Drawing2D.GraphicsPath? fillPath, System.Drawing.Drawing2D.GraphicsPath? strokePath, System.Drawing.Drawing2D.LineCap baseCap) { }
+ public CustomLineCap(System.Drawing.Drawing2D.GraphicsPath? fillPath, System.Drawing.Drawing2D.GraphicsPath? strokePath, System.Drawing.Drawing2D.LineCap baseCap, float baseInset) { }
public System.Drawing.Drawing2D.LineCap BaseCap { get { throw null; } set { } }
public float BaseInset { get { throw null; } set { } }
public System.Drawing.Drawing2D.LineJoin StrokeJoin { get { throw null; } set { } }
public void AddRectangle(System.Drawing.RectangleF rect) { }
public void AddRectangles(System.Drawing.RectangleF[] rects) { }
public void AddRectangles(System.Drawing.Rectangle[] rects) { }
- public void AddString(string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.Point origin, System.Drawing.StringFormat format) { }
- public void AddString(string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.PointF origin, System.Drawing.StringFormat format) { }
- public void AddString(string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.Rectangle layoutRect, System.Drawing.StringFormat format) { }
- public void AddString(string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.RectangleF layoutRect, System.Drawing.StringFormat format) { }
+ public void AddString(string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.Point origin, System.Drawing.StringFormat? format) { }
+ public void AddString(string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.PointF origin, System.Drawing.StringFormat? format) { }
+ public void AddString(string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.Rectangle layoutRect, System.Drawing.StringFormat? format) { }
+ public void AddString(string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.RectangleF layoutRect, System.Drawing.StringFormat? format) { }
public void ClearMarkers() { }
public object Clone() { throw null; }
public void CloseAllFigures() { }
public void Dispose() { }
~GraphicsPath() { }
public void Flatten() { }
- public void Flatten(System.Drawing.Drawing2D.Matrix matrix) { }
- public void Flatten(System.Drawing.Drawing2D.Matrix matrix, float flatness) { }
+ public void Flatten(System.Drawing.Drawing2D.Matrix? matrix) { }
+ public void Flatten(System.Drawing.Drawing2D.Matrix? matrix, float flatness) { }
public System.Drawing.RectangleF GetBounds() { throw null; }
- public System.Drawing.RectangleF GetBounds(System.Drawing.Drawing2D.Matrix matrix) { throw null; }
- public System.Drawing.RectangleF GetBounds(System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Pen pen) { throw null; }
+ public System.Drawing.RectangleF GetBounds(System.Drawing.Drawing2D.Matrix? matrix) { throw null; }
+ public System.Drawing.RectangleF GetBounds(System.Drawing.Drawing2D.Matrix? matrix, System.Drawing.Pen? pen) { throw null; }
public System.Drawing.PointF GetLastPoint() { throw null; }
public bool IsOutlineVisible(System.Drawing.Point point, System.Drawing.Pen pen) { throw null; }
- public bool IsOutlineVisible(System.Drawing.Point pt, System.Drawing.Pen pen, System.Drawing.Graphics graphics) { throw null; }
+ public bool IsOutlineVisible(System.Drawing.Point pt, System.Drawing.Pen pen, System.Drawing.Graphics? graphics) { throw null; }
public bool IsOutlineVisible(System.Drawing.PointF point, System.Drawing.Pen pen) { throw null; }
- public bool IsOutlineVisible(System.Drawing.PointF pt, System.Drawing.Pen pen, System.Drawing.Graphics graphics) { throw null; }
+ public bool IsOutlineVisible(System.Drawing.PointF pt, System.Drawing.Pen pen, System.Drawing.Graphics? graphics) { throw null; }
public bool IsOutlineVisible(int x, int y, System.Drawing.Pen pen) { throw null; }
- public bool IsOutlineVisible(int x, int y, System.Drawing.Pen pen, System.Drawing.Graphics graphics) { throw null; }
+ public bool IsOutlineVisible(int x, int y, System.Drawing.Pen pen, System.Drawing.Graphics? graphics) { throw null; }
public bool IsOutlineVisible(float x, float y, System.Drawing.Pen pen) { throw null; }
- public bool IsOutlineVisible(float x, float y, System.Drawing.Pen pen, System.Drawing.Graphics graphics) { throw null; }
+ public bool IsOutlineVisible(float x, float y, System.Drawing.Pen pen, System.Drawing.Graphics? graphics) { throw null; }
public bool IsVisible(System.Drawing.Point point) { throw null; }
- public bool IsVisible(System.Drawing.Point pt, System.Drawing.Graphics graphics) { throw null; }
+ public bool IsVisible(System.Drawing.Point pt, System.Drawing.Graphics? graphics) { throw null; }
public bool IsVisible(System.Drawing.PointF point) { throw null; }
- public bool IsVisible(System.Drawing.PointF pt, System.Drawing.Graphics graphics) { throw null; }
+ public bool IsVisible(System.Drawing.PointF pt, System.Drawing.Graphics? graphics) { throw null; }
public bool IsVisible(int x, int y) { throw null; }
- public bool IsVisible(int x, int y, System.Drawing.Graphics graphics) { throw null; }
+ public bool IsVisible(int x, int y, System.Drawing.Graphics? graphics) { throw null; }
public bool IsVisible(float x, float y) { throw null; }
- public bool IsVisible(float x, float y, System.Drawing.Graphics graphics) { throw null; }
+ public bool IsVisible(float x, float y, System.Drawing.Graphics? graphics) { throw null; }
public void Reset() { }
public void Reverse() { }
public void SetMarkers() { }
public void StartFigure() { }
public void Transform(System.Drawing.Drawing2D.Matrix matrix) { }
public void Warp(System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect) { }
- public void Warp(System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix matrix) { }
- public void Warp(System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Drawing2D.WarpMode warpMode) { }
- public void Warp(System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Drawing2D.WarpMode warpMode, float flatness) { }
+ public void Warp(System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix? matrix) { }
+ public void Warp(System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix? matrix, System.Drawing.Drawing2D.WarpMode warpMode) { }
+ public void Warp(System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix? matrix, System.Drawing.Drawing2D.WarpMode warpMode, float flatness) { }
public void Widen(System.Drawing.Pen pen) { }
- public void Widen(System.Drawing.Pen pen, System.Drawing.Drawing2D.Matrix matrix) { }
- public void Widen(System.Drawing.Pen pen, System.Drawing.Drawing2D.Matrix matrix, float flatness) { }
+ public void Widen(System.Drawing.Pen pen, System.Drawing.Drawing2D.Matrix? matrix) { }
+ public void Widen(System.Drawing.Pen pen, System.Drawing.Drawing2D.Matrix? matrix, float flatness) { }
}
public sealed partial class GraphicsPathIterator : System.MarshalByRefObject, System.IDisposable
{
- public GraphicsPathIterator(System.Drawing.Drawing2D.GraphicsPath path) { }
+ public GraphicsPathIterator(System.Drawing.Drawing2D.GraphicsPath? path) { }
public int Count { get { throw null; } }
public int SubpathCount { get { throw null; } }
public int CopyData(ref System.Drawing.PointF[] points, ref byte[] types, int startIndex, int endIndex) { throw null; }
public LinearGradientBrush(System.Drawing.RectangleF rect, System.Drawing.Color color1, System.Drawing.Color color2, System.Drawing.Drawing2D.LinearGradientMode linearGradientMode) { }
public LinearGradientBrush(System.Drawing.RectangleF rect, System.Drawing.Color color1, System.Drawing.Color color2, float angle) { }
public LinearGradientBrush(System.Drawing.RectangleF rect, System.Drawing.Color color1, System.Drawing.Color color2, float angle, bool isAngleScaleable) { }
- public System.Drawing.Drawing2D.Blend Blend { get { throw null; } set { } }
+ public System.Drawing.Drawing2D.Blend? Blend { get { throw null; } set { } }
public bool GammaCorrection { get { throw null; } set { } }
public System.Drawing.Drawing2D.ColorBlend InterpolationColors { get { throw null; } set { } }
public System.Drawing.Color[] LinearColors { get { throw null; } set { } }
public float OffsetY { get { throw null; } }
public System.Drawing.Drawing2D.Matrix Clone() { throw null; }
public void Dispose() { }
- public override bool Equals(object obj) { throw null; }
+ public override bool Equals(object? obj) { throw null; }
~Matrix() { }
public override int GetHashCode() { throw null; }
public void Invert() { }
public sealed partial class PathData
{
public PathData() { }
- public System.Drawing.PointF[] Points { get { throw null; } set { } }
- public byte[] Types { get { throw null; } set { } }
+ public System.Drawing.PointF[]? Points { get { throw null; } set { } }
+ public byte[]? Types { get { throw null; } set { } }
}
public sealed partial class PathGradientBrush : System.Drawing.Brush
{
ValueTypeRational = 5,
ValueTypeLongRange = 6,
ValueTypeUndefined = 7,
- ValueTypeRationalRange = 8
+ ValueTypeRationalRange = 8,
}
public enum EncoderValue
{
public static System.Drawing.Imaging.FrameDimension Page { get { throw null; } }
public static System.Drawing.Imaging.FrameDimension Resolution { get { throw null; } }
public static System.Drawing.Imaging.FrameDimension Time { get { throw null; } }
- public override bool Equals(object o) { throw null; }
+ public override bool Equals(object? o) { throw null; }
public override int GetHashCode() { throw null; }
public override string ToString() { throw null; }
}
public void SetBrushRemapTable(System.Drawing.Imaging.ColorMap[] map) { }
public void SetColorKey(System.Drawing.Color colorLow, System.Drawing.Color colorHigh) { }
public void SetColorKey(System.Drawing.Color colorLow, System.Drawing.Color colorHigh, System.Drawing.Imaging.ColorAdjustType type) { }
- public void SetColorMatrices(System.Drawing.Imaging.ColorMatrix newColorMatrix, System.Drawing.Imaging.ColorMatrix grayMatrix) { }
- public void SetColorMatrices(System.Drawing.Imaging.ColorMatrix newColorMatrix, System.Drawing.Imaging.ColorMatrix grayMatrix, System.Drawing.Imaging.ColorMatrixFlag flags) { }
- public void SetColorMatrices(System.Drawing.Imaging.ColorMatrix newColorMatrix, System.Drawing.Imaging.ColorMatrix grayMatrix, System.Drawing.Imaging.ColorMatrixFlag mode, System.Drawing.Imaging.ColorAdjustType type) { }
+ public void SetColorMatrices(System.Drawing.Imaging.ColorMatrix newColorMatrix, System.Drawing.Imaging.ColorMatrix? grayMatrix) { }
+ public void SetColorMatrices(System.Drawing.Imaging.ColorMatrix newColorMatrix, System.Drawing.Imaging.ColorMatrix? grayMatrix, System.Drawing.Imaging.ColorMatrixFlag flags) { }
+ public void SetColorMatrices(System.Drawing.Imaging.ColorMatrix newColorMatrix, System.Drawing.Imaging.ColorMatrix? grayMatrix, System.Drawing.Imaging.ColorMatrixFlag mode, System.Drawing.Imaging.ColorAdjustType type) { }
public void SetColorMatrix(System.Drawing.Imaging.ColorMatrix newColorMatrix) { }
public void SetColorMatrix(System.Drawing.Imaging.ColorMatrix newColorMatrix, System.Drawing.Imaging.ColorMatrixFlag flags) { }
public void SetColorMatrix(System.Drawing.Imaging.ColorMatrix newColorMatrix, System.Drawing.Imaging.ColorMatrixFlag mode, System.Drawing.Imaging.ColorAdjustType type) { }
{
internal ImageCodecInfo() { }
public System.Guid Clsid { get { throw null; } set { } }
- public string CodecName { get { throw null; } set { } }
- public string DllName { get { throw null; } set { } }
- public string FilenameExtension { get { throw null; } set { } }
+ public string? CodecName { get { throw null; } set { } }
+ public string? DllName { get { throw null; } set { } }
+ public string? FilenameExtension { get { throw null; } set { } }
public System.Drawing.Imaging.ImageCodecFlags Flags { get { throw null; } set { } }
- public string FormatDescription { get { throw null; } set { } }
+ public string? FormatDescription { get { throw null; } set { } }
public System.Guid FormatID { get { throw null; } set { } }
- public string MimeType { get { throw null; } set { } }
+ public string? MimeType { get { throw null; } set { } }
[System.CLSCompliantAttribute(false)]
- public byte[][] SignatureMasks { get { throw null; } set { } }
+ public byte[][]? SignatureMasks { get { throw null; } set { } }
[System.CLSCompliantAttribute(false)]
- public byte[][] SignaturePatterns { get { throw null; } set { } }
+ public byte[][]? SignaturePatterns { get { throw null; } set { } }
public int Version { get { throw null; } set { } }
public static System.Drawing.Imaging.ImageCodecInfo[] GetImageDecoders() { throw null; }
public static System.Drawing.Imaging.ImageCodecInfo[] GetImageEncoders() { throw null; }
public static System.Drawing.Imaging.ImageFormat Png { get { throw null; } }
public static System.Drawing.Imaging.ImageFormat Tiff { get { throw null; } }
public static System.Drawing.Imaging.ImageFormat Wmf { get { throw null; } }
- public override bool Equals(object o) { throw null; }
+ public override bool Equals(object? o) { throw null; }
public override int GetHashCode() { throw null; }
public override string ToString() { throw null; }
}
{
public Metafile(System.IntPtr henhmetafile, bool deleteEmf) { }
public Metafile(System.IntPtr referenceHdc, System.Drawing.Imaging.EmfType emfType) { }
- public Metafile(System.IntPtr referenceHdc, System.Drawing.Imaging.EmfType emfType, string description) { }
+ public Metafile(System.IntPtr referenceHdc, System.Drawing.Imaging.EmfType emfType, string? description) { }
public Metafile(System.IntPtr hmetafile, System.Drawing.Imaging.WmfPlaceableFileHeader wmfHeader) { }
public Metafile(System.IntPtr hmetafile, System.Drawing.Imaging.WmfPlaceableFileHeader wmfHeader, bool deleteWmf) { }
public Metafile(System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect) { }
public Metafile(System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit) { }
public Metafile(System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type) { }
- public Metafile(System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type, string desc) { }
+ public Metafile(System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type, string? desc) { }
public Metafile(System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect) { }
public Metafile(System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit) { }
public Metafile(System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type) { }
- public Metafile(System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type, string description) { }
+ public Metafile(System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type, string? description) { }
public Metafile(System.IO.Stream stream) { }
public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc) { }
public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.Imaging.EmfType type) { }
- public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.Imaging.EmfType type, string description) { }
+ public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.Imaging.EmfType type, string? description) { }
public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect) { }
public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit) { }
public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type) { }
- public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type, string description) { }
+ public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type, string? description) { }
public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect) { }
public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit) { }
public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type) { }
- public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type, string description) { }
+ public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type, string? description) { }
public Metafile(string filename) { }
public Metafile(string fileName, System.IntPtr referenceHdc) { }
public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.Imaging.EmfType type) { }
- public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.Imaging.EmfType type, string description) { }
+ public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.Imaging.EmfType type, string? description) { }
public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect) { }
public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit) { }
public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type) { }
- public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type, string description) { }
- public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, string description) { }
+ public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type, string? description) { }
+ public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, string? description) { }
public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect) { }
public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit) { }
public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type) { }
- public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type, string description) { }
- public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, string desc) { }
+ public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type, string? description) { }
+ public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, string? desc) { }
public System.IntPtr GetHenhmetafile() { throw null; }
public System.Drawing.Imaging.MetafileHeader GetMetafileHeader() { throw null; }
public static System.Drawing.Imaging.MetafileHeader GetMetafileHeader(System.IntPtr henhmetafile) { throw null; }
public int Id { get { throw null; } set { } }
public int Len { get { throw null; } set { } }
public short Type { get { throw null; } set { } }
- public byte[] Value { get { throw null; } set { } }
+ public byte[]? Value { get { throw null; } set { } }
}
public sealed partial class WmfPlaceableFileHeader
{
public int Right { get { throw null; } set { } }
public int Top { get { throw null; } set { } }
public object Clone() { throw null; }
- public override bool Equals(object obj) { throw null; }
+ public override bool Equals(object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public static bool operator ==(System.Drawing.Printing.Margins m1, System.Drawing.Printing.Margins m2) { throw null; }
public static bool operator !=(System.Drawing.Printing.Margins m1, System.Drawing.Printing.Margins m2) { throw null; }
public virtual bool IsPreview { get { throw null; } }
public virtual void OnEndPage(System.Drawing.Printing.PrintDocument document, System.Drawing.Printing.PrintPageEventArgs e) { }
public virtual void OnEndPrint(System.Drawing.Printing.PrintDocument document, System.Drawing.Printing.PrintEventArgs e) { }
- public virtual System.Drawing.Graphics OnStartPage(System.Drawing.Printing.PrintDocument document, System.Drawing.Printing.PrintPageEventArgs e) { throw null; }
+ public virtual System.Drawing.Graphics? OnStartPage(System.Drawing.Printing.PrintDocument document, System.Drawing.Printing.PrintPageEventArgs e) { throw null; }
public virtual void OnStartPrint(System.Drawing.Printing.PrintDocument document, System.Drawing.Printing.PrintEventArgs e) { }
}
public partial class PrintDocument : System.ComponentModel.Component
public event System.Drawing.Printing.PrintEventHandler EndPrint { add { } remove { } }
public event System.Drawing.Printing.PrintPageEventHandler PrintPage { add { } remove { } }
public event System.Drawing.Printing.QueryPageSettingsEventHandler QueryPageSettings { add { } remove { } }
- protected virtual void OnBeginPrint(System.Drawing.Printing.PrintEventArgs e) { }
- protected virtual void OnEndPrint(System.Drawing.Printing.PrintEventArgs e) { }
- protected virtual void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e) { }
- protected virtual void OnQueryPageSettings(System.Drawing.Printing.QueryPageSettingsEventArgs e) { }
+ protected internal virtual void OnBeginPrint(System.Drawing.Printing.PrintEventArgs e) { }
+ protected internal virtual void OnEndPrint(System.Drawing.Printing.PrintEventArgs e) { }
+ protected internal virtual void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e) { }
+ protected internal virtual void OnQueryPageSettings(System.Drawing.Printing.QueryPageSettingsEventArgs e) { }
public void Print() { }
public override string ToString() { throw null; }
}
public delegate void PrintEventHandler(object sender, System.Drawing.Printing.PrintEventArgs e);
public partial class PrintPageEventArgs : System.EventArgs
{
- public PrintPageEventArgs(System.Drawing.Graphics graphics, System.Drawing.Rectangle marginBounds, System.Drawing.Rectangle pageBounds, System.Drawing.Printing.PageSettings pageSettings) { }
+ public PrintPageEventArgs(System.Drawing.Graphics? graphics, System.Drawing.Rectangle marginBounds, System.Drawing.Rectangle pageBounds, System.Drawing.Printing.PageSettings pageSettings) { }
public bool Cancel { get { throw null; } set { } }
- public System.Drawing.Graphics Graphics { get { throw null; } }
+ public System.Drawing.Graphics? Graphics { get { throw null; } }
public bool HasMorePages { get { throw null; } set { } }
public System.Drawing.Rectangle MarginBounds { get { throw null; } }
public System.Drawing.Rectangle PageBounds { get { throw null; } }
<PropertyGroup>
<TargetFrameworks>netcoreapp3.0;$(NetCoreAppCurrent)</TargetFrameworks>
<ExcludeCurrentNetCoreAppFromPackage>true</ExcludeCurrentNetCoreAppFromPackage>
+ <Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Include="System.Drawing.Common.cs" />
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<TargetFrameworks>netcoreapp3.0-Windows_NT;netcoreapp3.0-Unix;$(NetCoreAppCurrent)-Windows_NT;$(NetCoreAppCurrent)-Unix</TargetFrameworks>
<ExcludeCurrentNetCoreAppFromPackage>true</ExcludeCurrentNetCoreAppFromPackage>
+ <Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Include="System\Drawing\Bitmap.cs" />
if (type == null)
throw new NullReferenceException();
- Stream s = type.GetTypeInfo().Assembly.GetManifestResourceStream(type, resource);
+ Stream? s = type.GetTypeInfo().Assembly.GetManifestResourceStream(type, resource);
if (s == null)
{
string msg = string.Format("Resource '{0}' was not found.", resource);
{
public Bitmap(Type type, string resource)
{
- Stream stream = type.Module.Assembly.GetManifestResourceStream(type, resource);
+ Stream? stream = type.Module.Assembly.GetManifestResourceStream(type, resource);
if (stream == null)
{
throw new ArgumentException(SR.Format(SR.ResourceNotFound, type, resource));
/// For performance, the suffix is cached in a static variable so it only has to be read
/// once per appdomain.
/// </remarks>
- private static string s_suffix;
- internal static string Suffix
+ private static string? s_suffix;
+ internal static string? Suffix
{
get
{
}
// Calls assembly.GetManifestResourceStream in a try/catch and returns null if not found
- private static Stream GetResourceStreamHelper(Assembly assembly, Type type, string name)
+ private static Stream? GetResourceStreamHelper(Assembly assembly, Type type, string name)
{
- Stream stream = null;
+ Stream? stream = null;
try
{
stream = assembly.GetManifestResourceStream(type, name);
return DoesAssemblyHaveCustomAttribute(assembly, assembly.GetType(typeName));
}
- private static bool DoesAssemblyHaveCustomAttribute(Assembly assembly, Type attrType)
+ private static bool DoesAssemblyHaveCustomAttribute(Assembly assembly, Type? attrType)
{
if (attrType != null)
{
/// The manifest resource stream corresponding to <paramref name="originalName"/> with the
/// current suffix applied; or if that is not found, the stream corresponding to <paramref name="originalName"/>.
/// </returns>
- public static Stream GetResourceStream(Assembly assembly, Type type, string originalName)
+ public static Stream? GetResourceStream(Assembly assembly, Type type, string originalName)
{
if (Suffix != string.Empty)
{
if (SameAssemblyOptIn(assembly))
{
string newName = AppendSuffix(originalName);
- Stream stream = GetResourceStreamHelper(assembly, type, newName);
+ Stream? stream = GetResourceStreamHelper(assembly, type, newName);
if (stream != null)
{
return stream;
Assembly satellite = Assembly.Load(assemblyName);
if (satellite != null)
{
- Stream stream = GetResourceStreamHelper(satellite, type, originalName);
+ Stream? stream = GetResourceStreamHelper(satellite, type, originalName);
if (stream != null)
{
return stream;
/// The manifest resource stream corresponding to <paramref name="originalName"/> with the
/// current suffix applied; or if that is not found, the stream corresponding to <paramref name="originalName"/>.
/// </returns>
- public static Stream GetResourceStream(Type type, string originalName)
+ public static Stream? GetResourceStream(Type type, string originalName)
{
return GetResourceStream(type.Module.Assembly, type, originalName);
}
/// </returns>
public static Icon CreateIcon(Type type, string originalName)
{
- return new Icon(GetResourceStream(type, originalName));
+ return new Icon(GetResourceStream(type, originalName)!);
}
/// <summary>
/// </returns>
public static Bitmap CreateBitmap(Type type, string originalName)
{
- return new Bitmap(GetResourceStream(type, originalName));
+ return new Bitmap(GetResourceStream(type, originalName)!);
}
}
}
private static Brush GetBrush(object key, Color color)
{
- Brush brush = (Brush)Gdip.ThreadData[key];
+ Brush? brush = (Brush?)Gdip.ThreadData[key];
if (brush == null)
{
brush = new SolidBrush(color);
public sealed partial class BufferedGraphics
{
private Rectangle size;
- private Bitmap membmp = null;
- private Graphics source = null;
+ private Bitmap membmp;
+ private Graphics? source;
- internal BufferedGraphics(Graphics targetGraphics, IntPtr targetDc, Rectangle targetRectangle)
+ internal BufferedGraphics(Graphics? targetGraphics, IntPtr targetDc, Rectangle targetRectangle)
{
_targetGraphics = targetGraphics;
_targetDC = targetDc;
source = Graphics.FromImage(membmp);
}
- return source;
+ return source!;
}
}
if (membmp != null)
{
membmp.Dispose();
- membmp = null;
+ membmp = null!;
}
if (source != null)
_targetGraphics = null;
}
- public void Render(Graphics target)
+ public void Render(Graphics? target)
{
if (target == null)
return;
/// <summary>
/// Internal constructor, this class is created by BufferedGraphicsContext.
/// </summary>
- internal BufferedGraphics(Graphics bufferedGraphicsSurface, BufferedGraphicsContext context, Graphics targetGraphics,
+ internal BufferedGraphics(Graphics bufferedGraphicsSurface, BufferedGraphicsContext context, Graphics? targetGraphics,
IntPtr targetDC, Point targetLoc, Size virtualSize)
{
_context = context;
if (DisposeContext)
{
_context.Dispose();
- _context = null;
+ _context = null!;
}
}
if (_bufferedGraphicsSurface != null)
{
_bufferedGraphicsSurface.Dispose();
- _bufferedGraphicsSurface = null;
+ _bufferedGraphicsSurface = null!;
}
}
/// <summary>
/// Renders the buffer to the specified target graphics.
/// </summary>
- public void Render(Graphics target)
+ public void Render(Graphics? target)
{
if (target != null)
{
/// </summary>
public sealed partial class BufferedGraphics : IDisposable
{
- private Graphics _targetGraphics;
+ private Graphics? _targetGraphics;
private readonly IntPtr _targetDC;
/// <summary>
{
public sealed partial class BufferedGraphicsContext : IDisposable
{
- private BufferedGraphics AllocBuffer(Graphics targetGraphics, IntPtr targetDC, Rectangle targetRectangle)
+ private BufferedGraphics AllocBuffer(Graphics? targetGraphics, IntPtr targetDC, Rectangle targetRectangle)
{
BufferedGraphics graphics = new BufferedGraphics(targetGraphics, targetDC, targetRectangle);
return graphics;
private IntPtr _compatDC;
private IntPtr _dib;
private IntPtr _oldBitmap;
- private Graphics _compatGraphics;
- private BufferedGraphics _buffer;
+ private Graphics? _compatGraphics;
+ private BufferedGraphics? _buffer;
private int _busy;
private bool _invalidateWhenFree;
/// <summary>
/// Returns a BufferedGraphics that is matched for the specified target HDC object.
/// </summary>
- private BufferedGraphics AllocBuffer(Graphics targetGraphics, IntPtr targetDC, Rectangle targetRectangle)
+ private BufferedGraphics AllocBuffer(Graphics? targetGraphics, IntPtr targetDC, Rectangle targetRectangle)
{
int oldBusy = Interlocked.CompareExchange(ref _busy, BufferBusyPainting, BufferFree);
// Create the DIB section. Let Win32 allocate the memory and return
// a pointer to the bitmap surface.
hbmRet = SafeNativeMethods.CreateDIBSection(new HandleRef(null, hdc), ref pbmi, NativeMethods.DIB_RGB_COLORS, ref ppvBits, IntPtr.Zero, 0);
- Win32Exception ex = null;
+ Win32Exception? ex = null;
if (hbmRet == IntPtr.Zero)
{
ex = new Win32Exception(Marshal.GetLastWin32Error());
/// <summary>
/// Returns a BufferedGraphics that is matched for the specified target HDC object.
/// </summary>
- private BufferedGraphics AllocBufferInTempManager(Graphics targetGraphics, IntPtr targetDC, Rectangle targetRectangle)
+ private BufferedGraphics AllocBufferInTempManager(Graphics? targetGraphics, IntPtr targetDC, Rectangle targetRectangle)
{
- BufferedGraphicsContext tempContext = null;
- BufferedGraphics tempBuffer = null;
+ BufferedGraphicsContext? tempContext = null;
+ BufferedGraphics? tempBuffer = null;
try
{
/// Called on process exit
/// </summary>
[PrePrepareMethod]
- private static void OnShutdown(object sender, EventArgs e) => Current.Invalidate();
+ private static void OnShutdown(object? sender, EventArgs e) => Current.Invalidate();
}
}
set => _length = value;
}
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (!(obj is CharacterRange cr))
{
using System.Collections;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.Security;
namespace System.Drawing
/// </summary>
public int RefCheckThreshold { get; set; } = int.MaxValue;
- public object this[int index]
+ public object? this[int index]
{
get
{
int currentCount = Count;
for (int i = 0; i < currentCount; i++)
{
- object item = this[currentIndex];
+ object? item = this[currentIndex];
if (item == null)
{
}
}
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (!(obj is WeakRefCollection other))
{
{
if (InnerList[i] != other.InnerList[i])
{
- if (InnerList[i] == null || !InnerList[i].Equals(other.InnerList[i]))
+ // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34644
+ if (InnerList[i] == null || !InnerList[i]!.Equals(other.InnerList[i]))
{
return false;
}
public override int GetHashCode() => base.GetHashCode();
- private WeakRefObject CreateWeakRefObject(object value)
+ [return: NotNullIfNotNull("value")]
+ private WeakRefObject? CreateWeakRefObject(object? value)
{
if (value == null)
{
for (int idx = 0; idx < InnerList.Count; idx++)
{
- if (InnerList[idx] != null && InnerList[idx].GetHashCode() == hash)
+ if (InnerList[idx] != null && InnerList[idx]!.GetHashCode() == hash)
{
RemoveAt(idx);
return;
public bool IsFixedSize => InnerList.IsFixedSize;
- public bool Contains(object value) => InnerList.Contains(CreateWeakRefObject(value));
+ public bool Contains(object? value) => InnerList.Contains(CreateWeakRefObject(value));
public void RemoveAt(int index) => InnerList.RemoveAt(index);
- public void Remove(object value) => InnerList.Remove(CreateWeakRefObject(value));
+ public void Remove(object? value) => InnerList.Remove(CreateWeakRefObject(value));
- public int IndexOf(object value) => InnerList.IndexOf(CreateWeakRefObject(value));
+ public int IndexOf(object? value) => InnerList.IndexOf(CreateWeakRefObject(value));
- public void Insert(int index, object value) => InnerList.Insert(index, CreateWeakRefObject(value));
+ public void Insert(int index, object? value) => InnerList.Insert(index, CreateWeakRefObject(value));
- public int Add(object value)
+ public int Add(object? value)
{
if (Count > RefCheckThreshold)
{
internal bool IsAlive => _weakHolder.IsAlive;
- internal object Target => _weakHolder.Target;
+ internal object? Target => _weakHolder.Target;
public override int GetHashCode() => _hash;
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
- WeakRefObject other = obj as WeakRefObject;
+ WeakRefObject? other = obj as WeakRefObject;
if (other == this)
{
/// <summary>
/// Represents the entry at the specified index of the <see cref='string'/>.
/// </summary>
- public string this[int index] => ((string)(InnerList[index]));
+ public string this[int index] => ((string)(InnerList[index])!);
/// <summary>
/// Gets a value indicating whether the <see cref='CategoryNameCollection'/> contains the specified
#endif
// Handle to native line cap object
- internal SafeCustomLineCapHandle nativeCap = null;
+ internal SafeCustomLineCapHandle nativeCap = null!;
private bool _disposed = false;
// For subclass creation
internal CustomLineCap() { }
- public CustomLineCap(GraphicsPath fillPath, GraphicsPath strokePath) : this(fillPath, strokePath, LineCap.Flat) { }
+ public CustomLineCap(GraphicsPath? fillPath, GraphicsPath? strokePath) : this(fillPath, strokePath, LineCap.Flat) { }
- public CustomLineCap(GraphicsPath fillPath, GraphicsPath strokePath, LineCap baseCap) : this(fillPath, strokePath, baseCap, 0) { }
+ public CustomLineCap(GraphicsPath? fillPath, GraphicsPath? strokePath, LineCap baseCap) : this(fillPath, strokePath, baseCap, 0) { }
- public CustomLineCap(GraphicsPath fillPath, GraphicsPath strokePath, LineCap baseCap, float baseInset)
+ public CustomLineCap(GraphicsPath? fillPath, GraphicsPath? strokePath, LineCap baseCap, float baseInset)
{
IntPtr nativeLineCap;
int status = Gdip.GdipCreateCustomLineCap(
Gdip.CheckStatus(status);
}
- public void AddString(string s, FontFamily family, int style, float emSize, Point origin, StringFormat format)
+ public void AddString(string s, FontFamily family, int style, float emSize, Point origin, StringFormat? format)
{
Rectangle layout = default;
layout.X = origin.X;
AddString(s, family, style, emSize, layout, format);
}
- public void AddString(string s, FontFamily family, int style, float emSize, PointF origin, StringFormat format)
+ public void AddString(string s, FontFamily family, int style, float emSize, PointF origin, StringFormat? format)
{
RectangleF layout = default;
layout.X = origin.X;
AddString(s, family, style, emSize, layout, format);
}
- public void AddString(string s, FontFamily family, int style, float emSize, Rectangle layoutRect, StringFormat format)
+ public void AddString(string s, FontFamily family, int style, float emSize, Rectangle layoutRect, StringFormat? format)
{
if (family == null)
throw new ArgumentException(nameof(family));
Gdip.CheckStatus(status);
}
- public void AddString(string s, FontFamily family, int style, float emSize, RectangleF layoutRect, StringFormat format)
+ public void AddString(string s, FontFamily family, int style, float emSize, RectangleF layoutRect, StringFormat? format)
{
if (family == null)
throw new ArgumentException(nameof(family));
Flatten(matrix, FlatnessDefault);
}
- public void Flatten(Matrix matrix, float flatness)
+ public void Flatten(Matrix? matrix, float flatness)
{
IntPtr m = (matrix == null) ? IntPtr.Zero : matrix.NativeMatrix;
int status = Gdip.GdipFlattenPath(_nativePath, m, flatness);
return GetBounds(null, null);
}
- public RectangleF GetBounds(Matrix matrix)
+ public RectangleF GetBounds(Matrix? matrix)
{
return GetBounds(matrix, null);
}
- public RectangleF GetBounds(Matrix matrix, Pen pen)
+ public RectangleF GetBounds(Matrix? matrix, Pen? pen)
{
RectangleF retval;
IntPtr m = (matrix == null) ? IntPtr.Zero : matrix.NativeMatrix;
return IsOutlineVisible(x, y, pen, null);
}
- public bool IsOutlineVisible(Point pt, Pen pen, Graphics graphics)
+ public bool IsOutlineVisible(Point pt, Pen pen, Graphics? graphics)
{
return IsOutlineVisible(pt.X, pt.Y, pen, graphics);
}
- public bool IsOutlineVisible(PointF pt, Pen pen, Graphics graphics)
+ public bool IsOutlineVisible(PointF pt, Pen pen, Graphics? graphics)
{
return IsOutlineVisible(pt.X, pt.Y, pen, graphics);
}
- public bool IsOutlineVisible(int x, int y, Pen pen, Graphics graphics)
+ public bool IsOutlineVisible(int x, int y, Pen pen, Graphics? graphics)
{
if (pen == null)
throw new ArgumentNullException(nameof(pen));
return result;
}
- public bool IsOutlineVisible(float x, float y, Pen pen, Graphics graphics)
+ public bool IsOutlineVisible(float x, float y, Pen pen, Graphics? graphics)
{
if (pen == null)
throw new ArgumentNullException(nameof(pen));
return IsVisible(x, y, null);
}
- public bool IsVisible(Point pt, Graphics graphics)
+ public bool IsVisible(Point pt, Graphics? graphics)
{
return IsVisible(pt.X, pt.Y, graphics);
}
- public bool IsVisible(PointF pt, Graphics graphics)
+ public bool IsVisible(PointF pt, Graphics? graphics)
{
return IsVisible(pt.X, pt.Y, graphics);
}
- public bool IsVisible(int x, int y, Graphics graphics)
+ public bool IsVisible(int x, int y, Graphics? graphics)
{
bool retval;
return retval;
}
- public bool IsVisible(float x, float y, Graphics graphics)
+ public bool IsVisible(float x, float y, Graphics? graphics)
{
bool retval;
Warp(destPoints, srcRect, null, WarpMode.Perspective, FlatnessDefault);
}
- public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix)
+ public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix? matrix)
{
Warp(destPoints, srcRect, matrix, WarpMode.Perspective, FlatnessDefault);
}
- public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode)
+ public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix? matrix, WarpMode warpMode)
{
Warp(destPoints, srcRect, matrix, warpMode, FlatnessDefault);
}
- public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode, float flatness)
+ public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix? matrix, WarpMode warpMode, float flatness)
{
if (destPoints == null)
throw new ArgumentNullException(nameof(destPoints));
Widen(pen, null, FlatnessDefault);
}
- public void Widen(Pen pen, Matrix matrix)
+ public void Widen(Pen pen, Matrix? matrix)
{
Widen(pen, matrix, FlatnessDefault);
}
- public void Widen(Pen pen, Matrix matrix, float flatness)
+ public void Widen(Pen pen, Matrix? matrix, float flatness)
{
if (pen == null)
throw new ArgumentNullException(nameof(pen));
public bool IsVisible(PointF point) => IsVisible(point, null);
- public bool IsVisible(float x, float y, Graphics graphics) => IsVisible(new PointF(x, y), graphics);
+ public bool IsVisible(float x, float y, Graphics? graphics) => IsVisible(new PointF(x, y), graphics);
- public bool IsVisible(PointF pt, Graphics graphics)
+ public bool IsVisible(PointF pt, Graphics? graphics)
{
Gdip.CheckStatus(Gdip.GdipIsVisiblePathPoint(
new HandleRef(this, _nativePath),
public bool IsVisible(Point point) => IsVisible(point, null);
- public bool IsVisible(int x, int y, Graphics graphics) => IsVisible(new Point(x, y), graphics);
+ public bool IsVisible(int x, int y, Graphics? graphics) => IsVisible(new Point(x, y), graphics);
- public bool IsVisible(Point pt, Graphics graphics)
+ public bool IsVisible(Point pt, Graphics? graphics)
{
Gdip.CheckStatus(Gdip.GdipIsVisiblePathPointI(
new HandleRef(this, _nativePath),
public bool IsOutlineVisible(PointF point, Pen pen) => IsOutlineVisible(point, pen, null);
- public bool IsOutlineVisible(float x, float y, Pen pen, Graphics graphics)
+ public bool IsOutlineVisible(float x, float y, Pen pen, Graphics? graphics)
{
return IsOutlineVisible(new PointF(x, y), pen, graphics);
}
- public bool IsOutlineVisible(PointF pt, Pen pen, Graphics graphics)
+ public bool IsOutlineVisible(PointF pt, Pen pen, Graphics? graphics)
{
if (pen == null)
throw new ArgumentNullException(nameof(pen));
public bool IsOutlineVisible(Point point, Pen pen) => IsOutlineVisible(point, pen, null);
- public bool IsOutlineVisible(int x, int y, Pen pen, Graphics graphics) => IsOutlineVisible(new Point(x, y), pen, graphics);
+ public bool IsOutlineVisible(int x, int y, Pen pen, Graphics? graphics) => IsOutlineVisible(new Point(x, y), pen, graphics);
- public bool IsOutlineVisible(Point pt, Pen pen, Graphics graphics)
+ public bool IsOutlineVisible(Point pt, Pen pen, Graphics? graphics)
{
if (pen == null)
throw new ArgumentNullException(nameof(pen));
new HandleRef(this, _nativePath), new HandleRef(addingPath, addingPath._nativePath), connect));
}
- public void AddString(string s, FontFamily family, int style, float emSize, PointF origin, StringFormat format)
+ public void AddString(string s, FontFamily family, int style, float emSize, PointF origin, StringFormat? format)
{
AddString(s, family, style, emSize, new RectangleF(origin.X, origin.Y, 0, 0), format);
}
- public void AddString(string s, FontFamily family, int style, float emSize, Point origin, StringFormat format)
+ public void AddString(string s, FontFamily family, int style, float emSize, Point origin, StringFormat? format)
{
AddString(s, family, style, emSize, new Rectangle(origin.X, origin.Y, 0, 0), format);
}
- public void AddString(string s, FontFamily family, int style, float emSize, RectangleF layoutRect, StringFormat format)
+ public void AddString(string s, FontFamily family, int style, float emSize, RectangleF layoutRect, StringFormat? format)
{
Gdip.CheckStatus(Gdip.GdipAddPathString(
new HandleRef(this, _nativePath),
new HandleRef(format, format?.nativeFormat ?? IntPtr.Zero)));
}
- public void AddString(string s, FontFamily family, int style, float emSize, Rectangle layoutRect, StringFormat format)
+ public void AddString(string s, FontFamily family, int style, float emSize, Rectangle layoutRect, StringFormat? format)
{
Gdip.CheckStatus(Gdip.GdipAddPathStringI(
new HandleRef(this, _nativePath),
public RectangleF GetBounds() => GetBounds(null);
- public RectangleF GetBounds(Matrix matrix) => GetBounds(matrix, null);
+ public RectangleF GetBounds(Matrix? matrix) => GetBounds(matrix, null);
- public RectangleF GetBounds(Matrix matrix, Pen pen)
+ public RectangleF GetBounds(Matrix? matrix, Pen? pen)
{
Gdip.CheckStatus(Gdip.GdipGetPathWorldBounds(
new HandleRef(this, _nativePath),
public void Flatten() => Flatten(null);
- public void Flatten(Matrix matrix) => Flatten(matrix, 0.25f);
+ public void Flatten(Matrix? matrix) => Flatten(matrix, 0.25f);
- public void Flatten(Matrix matrix, float flatness)
+ public void Flatten(Matrix? matrix, float flatness)
{
Gdip.CheckStatus(Gdip.GdipFlattenPath(
new HandleRef(this, _nativePath),
public void Widen(Pen pen) => Widen(pen, null, Flatness);
- public void Widen(Pen pen, Matrix matrix) => Widen(pen, matrix, Flatness);
+ public void Widen(Pen pen, Matrix? matrix) => Widen(pen, matrix, Flatness);
- public void Widen(Pen pen, Matrix matrix, float flatness)
+ public void Widen(Pen pen, Matrix? matrix, float flatness)
{
if (pen == null)
throw new ArgumentNullException(nameof(pen));
public void Warp(PointF[] destPoints, RectangleF srcRect) => Warp(destPoints, srcRect, null);
- public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix) => Warp(destPoints, srcRect, matrix, WarpMode.Perspective);
+ public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix? matrix) => Warp(destPoints, srcRect, matrix, WarpMode.Perspective);
- public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode)
+ public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix? matrix, WarpMode warpMode)
{
Warp(destPoints, srcRect, matrix, warpMode, 0.25f);
}
- public unsafe void Warp(PointF[] destPoints, RectangleF srcRect, Matrix matrix, WarpMode warpMode, float flatness)
+ public unsafe void Warp(PointF[] destPoints, RectangleF srcRect, Matrix? matrix, WarpMode warpMode, float flatness)
{
if (destPoints == null)
throw new ArgumentNullException(nameof(destPoints));
{
public sealed class GraphicsPathIterator : MarshalByRefObject, IDisposable
{
- public GraphicsPathIterator(GraphicsPath path)
+ public GraphicsPathIterator(GraphicsPath? path)
{
IntPtr nativeIter = IntPtr.Zero;
int status = Gdip.GdipCreatePathIter(out nativeIter, new HandleRef(path, (path == null) ? IntPtr.Zero : path._nativePath));
}
}
- public Blend Blend
+ public Blend? Blend
{
get
{
return isIdentity != 0;
}
}
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
- Matrix matrix2 = obj as Matrix;
- if (matrix2 == null)
+ if (!(obj is Matrix matrix2))
return false;
Gdip.CheckStatus(Gdip.GdipIsMatrixEqual(
{
public PathData() { }
- public PointF[] Points { get; set; }
+ public PointF[]? Points { get; set; }
- public byte[] Types { get; set; }
+ public byte[]? Types { get; set; }
}
}
using System.ComponentModel;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.Drawing.Internal;
using System.Runtime.InteropServices;
using Gdip = System.Drawing.SafeNativeMethods.Gdip;
GC.SuppressFinalize(_fontFamily);
}
- private static string StripVerticalName(string familyName)
+ [return: NotNullIfNotNull("familyName")]
+ private static string? StripVerticalName(string? familyName)
{
if (familyName?.Length > 1 && familyName[0] == '@')
{
private IntPtr _nativeFont;
private float _fontSize;
private FontStyle _fontStyle;
- private FontFamily _fontFamily;
+ private FontFamily _fontFamily = null!;
private GraphicsUnit _fontUnit;
private byte _gdiCharSet = SafeNativeMethods.DEFAULT_CHARSET;
private bool _gdiVerticalFont;
private string _systemFontName = "";
- private string _originalFontName;
+ private string _originalFontName = null!;
// Return value is in Unit (the unit the font was created in)
/// <summary>
private Font(SerializationInfo info, StreamingContext context)
{
- string name = info.GetString("Name"); // Do not rename (binary serialization)
- FontStyle style = (FontStyle)info.GetValue("Style", typeof(FontStyle)); // Do not rename (binary serialization)
- GraphicsUnit unit = (GraphicsUnit)info.GetValue("Unit", typeof(GraphicsUnit)); // Do not rename (binary serialization)
+ string name = info.GetString("Name")!; // Do not rename (binary serialization)
+ FontStyle style = (FontStyle)info.GetValue("Style", typeof(FontStyle))!; // Do not rename (binary serialization)
+ GraphicsUnit unit = (GraphicsUnit)info.GetValue("Unit", typeof(GraphicsUnit))!; // Do not rename (binary serialization)
float size = info.GetSingle("Size"); // Do not rename (binary serialization)
Initialize(name, size, style, unit, SafeNativeMethods.DEFAULT_CHARSET, IsVerticalName(name));
/// Returns a value indicating whether the specified object is a <see cref='Font'/> equivalent to this
/// <see cref='Font'/>.
/// </summary>
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (obj == this)
{
/// </summary>
public sealed partial class FontFamily : MarshalByRefObject, IDisposable
{
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (obj == this)
{
/// </summary>
public sealed partial class FontFamily : MarshalByRefObject, IDisposable
{
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (obj == this)
{
/// Initializes a new instance of the <see cref='FontFamily'/> class in the specified
/// <see cref='FontCollection'/> and with the specified name.
/// </summary>
- public FontFamily(string name, FontCollection fontCollection) => CreateFontFamily(name, fontCollection);
+ public FontFamily(string name, FontCollection? fontCollection) => CreateFontFamily(name, fontCollection);
// Creates the native font family object.
// Note: GDI+ creates singleton font family objects (from the corresponding font file) and reference count them.
- private void CreateFontFamily(string name, FontCollection fontCollection)
+ private void CreateFontFamily(string name, FontCollection? fontCollection)
{
IntPtr fontfamily = IntPtr.Zero;
IntPtr nativeFontCollection = (fontCollection == null) ? IntPtr.Zero : fontCollection._nativeFontCollection;
char* name = stackalloc char[32]; // LF_FACESIZE is 32
int status = Gdip.GdipGetFamilyName(new HandleRef(this, NativeFamily), name, language);
Gdip.CheckStatus(status);
- return Marshal.PtrToStringUni((IntPtr)name);
+ return Marshal.PtrToStringUni((IntPtr)name)!;
}
/// <summary>
get
{
LocalDataStoreSlot slot = Thread.GetNamedDataSlot(ThreadDataSlotName);
- IDictionary threadData = (IDictionary)Thread.GetData(slot);
+ IDictionary? threadData = (IDictionary?)Thread.GetData(slot);
if (threadData == null)
{
threadData = new Hashtable();
public static extern int DocumentProperties(HandleRef hwnd, HandleRef hPrinter, string pDeviceName, IntPtr /*DEVMODE*/ pDevModeOutput, IntPtr /*DEVMODE*/ pDevModeInput, int fMode);
[DllImport(ExternDll.Winspool, SetLastError = true, CharSet = CharSet.Auto)]
- public static extern int EnumPrinters(int flags, string name, int level, IntPtr pPrinterEnum/*buffer*/,
+ public static extern int EnumPrinters(int flags, string? name, int level, IntPtr pPrinterEnum/*buffer*/,
int cbBuf, out int pcbNeeded, out int pcReturned);
[DllImport(ExternDll.Gdi32, SetLastError = true, CharSet = CharSet.Auto)]
public class DOCINFO
{
public int cbSize = 20;
- public string lpszDocName;
- public string lpszOutput;
- public string lpszDatatype;
+ public string? lpszDocName;
+ public string? lpszOutput;
+ public string? lpszDatatype;
public int fwType;
}
public IntPtr lCustData;
public IntPtr lpfnPrintHook;
public IntPtr lpfnSetupHook;
- public string lpPrintTemplateName;
- public string lpSetupTemplateName;
+ public string? lpPrintTemplateName;
+ public string? lpSetupTemplateName;
public IntPtr hPrintTemplate;
public IntPtr hSetupTemplate;
}
public IntPtr lCustData;
public IntPtr lpfnPrintHook;
public IntPtr lpfnSetupHook;
- public string lpPrintTemplateName;
- public string lpSetupTemplateName;
+ public string? lpPrintTemplateName;
+ public string? lpSetupTemplateName;
public IntPtr hPrintTemplate;
public IntPtr hSetupTemplate;
}
public class DEVMODE
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
- public string dmDeviceName;
+ public string? dmDeviceName;
public short dmSpecVersion;
public short dmDriverVersion;
public short dmSize;
public short dmTTOption;
public short dmCollate;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
- public string dmFormName;
+ public string? dmFormName;
public short dmLogPixels;
public int dmBitsPerPel;
public int dmPelsWidth;
internal static extern int GdipRecordMetafileFromDelegate_linux(StreamGetHeaderDelegate getHeader,
StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek,
StreamCloseDelegate close, StreamSizeDelegate size, IntPtr hdc, EmfType type, ref RectangleF frameRect,
- MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+ MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
[DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
internal static extern int GdipRecordMetafileFromDelegateI_linux(StreamGetHeaderDelegate getHeader,
StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek,
StreamCloseDelegate close, StreamSizeDelegate size, IntPtr hdc, EmfType type, ref Rectangle frameRect,
- MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+ MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
[DllImport(LibraryName, ExactSpelling = true)]
internal static extern int GdipGetPostScriptGraphicsContext(
internal static extern int GdipGetImageBounds(HandleRef image, out RectangleF gprectf, out GraphicsUnit unit);
[DllImport(LibraryName, ExactSpelling = true)]
- internal static extern int GdipGetImageThumbnail(HandleRef image, int thumbWidth, int thumbHeight, out IntPtr thumbImage, Image.GetThumbnailImageAbort callback, IntPtr callbackdata);
+ internal static extern int GdipGetImageThumbnail(HandleRef image, int thumbWidth, int thumbHeight, out IntPtr thumbImage, Image.GetThumbnailImageAbort? callback, IntPtr callbackdata);
[DllImport(LibraryName, ExactSpelling = true)]
internal static extern int GdipGetImagePalette(HandleRef image, IntPtr palette, int size);
internal static extern int GdipCreateMetafileFromStream(Interop.Ole32.IStream stream, out IntPtr metafile);
[DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
- internal static extern int GdipRecordMetafileStream(Interop.Ole32.IStream stream, IntPtr referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+ internal static extern int GdipRecordMetafileStream(Interop.Ole32.IStream stream, IntPtr referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
[DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
- internal static extern int GdipRecordMetafileStream(Interop.Ole32.IStream stream, IntPtr referenceHdc, EmfType emfType, IntPtr pframeRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+ internal static extern int GdipRecordMetafileStream(Interop.Ole32.IStream stream, IntPtr referenceHdc, EmfType emfType, IntPtr pframeRect, MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
[DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
- internal static extern int GdipRecordMetafileStreamI(Interop.Ole32.IStream stream, IntPtr referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+ internal static extern int GdipRecordMetafileStreamI(Interop.Ole32.IStream stream, IntPtr referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
[DllImport(LibraryName, ExactSpelling = true)]
internal static extern int GdipComment(HandleRef graphics, int sizeData, byte[] data);
internal static extern int GdipDisposeImageAttributes(HandleRef imageattr);
[DllImport(LibraryName, ExactSpelling = true)]
- internal static extern int GdipSetImageAttributesColorMatrix(HandleRef imageattr, ColorAdjustType type, bool enableFlag, ColorMatrix colorMatrix, ColorMatrix grayMatrix, ColorMatrixFlag flags);
+ internal static extern int GdipSetImageAttributesColorMatrix(HandleRef imageattr, ColorAdjustType type, bool enableFlag, ColorMatrix? colorMatrix, ColorMatrix? grayMatrix, ColorMatrixFlag flags);
[DllImport(LibraryName, ExactSpelling = true)]
internal static extern int GdipSetImageAttributesThreshold(HandleRef imageattr, ColorAdjustType type, bool enableFlag, float threshold);
internal static extern int GdipCreateMetafileFromFile(string file, out IntPtr metafile);
[DllImport(LibraryName, ExactSpelling = true)]
- internal static extern int GdipRecordMetafile(IntPtr referenceHdc, EmfType emfType, IntPtr pframeRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+ internal static extern int GdipRecordMetafile(IntPtr referenceHdc, EmfType emfType, IntPtr pframeRect, MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
[DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
- internal static extern int GdipRecordMetafile(IntPtr referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+ internal static extern int GdipRecordMetafile(IntPtr referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
[DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
- internal static extern int GdipRecordMetafileI(IntPtr referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+ internal static extern int GdipRecordMetafileI(IntPtr referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
[DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
- internal static extern int GdipRecordMetafileFileName(string fileName, IntPtr referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+ internal static extern int GdipRecordMetafileFileName(string fileName, IntPtr referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
[DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
- internal static extern int GdipRecordMetafileFileName(string fileName, IntPtr referenceHdc, EmfType emfType, IntPtr pframeRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+ internal static extern int GdipRecordMetafileFileName(string fileName, IntPtr referenceHdc, EmfType emfType, IntPtr pframeRect, MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
[DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
- internal static extern int GdipRecordMetafileFileNameI(string fileName, IntPtr referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+ internal static extern int GdipRecordMetafileFileNameI(string fileName, IntPtr referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
[DllImport(LibraryName, ExactSpelling = true)]
internal static extern int GdipPlayMetafileRecord(HandleRef metafile, EmfPlusRecordType recordType, int flags, int dataSize, byte[] data);
internal static extern int GdipDrawImagePointsI(HandleRef graphics, HandleRef image, Point* points, int count);
[DllImport(LibraryName, ExactSpelling = true)]
- internal static extern int GdipDrawImageRectRectI(HandleRef graphics, HandleRef image, int dstx, int dsty, int dstwidth, int dstheight, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcunit, HandleRef imageAttributes, Graphics.DrawImageAbort callback, HandleRef callbackdata);
+ internal static extern int GdipDrawImageRectRectI(HandleRef graphics, HandleRef image, int dstx, int dsty, int dstwidth, int dstheight, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcunit, HandleRef imageAttributes, Graphics.DrawImageAbort? callback, HandleRef callbackdata);
[DllImport(LibraryName, ExactSpelling = true)]
- internal static extern int GdipDrawImagePointsRect(HandleRef graphics, HandleRef image, PointF* points, int count, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcunit, HandleRef imageAttributes, Graphics.DrawImageAbort callback, HandleRef callbackdata);
+ internal static extern int GdipDrawImagePointsRect(HandleRef graphics, HandleRef image, PointF* points, int count, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcunit, HandleRef imageAttributes, Graphics.DrawImageAbort? callback, HandleRef callbackdata);
[DllImport(LibraryName, ExactSpelling = true)]
- internal static extern int GdipDrawImageRectRect(HandleRef graphics, HandleRef image, float dstx, float dsty, float dstwidth, float dstheight, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcunit, HandleRef imageAttributes, Graphics.DrawImageAbort callback, HandleRef callbackdata);
+ internal static extern int GdipDrawImageRectRect(HandleRef graphics, HandleRef image, float dstx, float dsty, float dstwidth, float dstheight, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcunit, HandleRef imageAttributes, Graphics.DrawImageAbort? callback, HandleRef callbackdata);
[DllImport(LibraryName, ExactSpelling = true)]
- internal static extern int GdipDrawImagePointsRectI(HandleRef graphics, HandleRef image, Point* points, int count, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcunit, HandleRef imageAttributes, Graphics.DrawImageAbort callback, HandleRef callbackdata);
+ internal static extern int GdipDrawImagePointsRectI(HandleRef graphics, HandleRef image, Point* points, int count, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcunit, HandleRef imageAttributes, Graphics.DrawImageAbort? callback, HandleRef callbackdata);
[DllImport(LibraryName, ExactSpelling = true)]
internal static extern int GdipDrawImageRect(HandleRef graphics, HandleRef image, float x, float y, float width, float height);
{
public sealed partial class Graphics : MarshalByRefObject, IDisposable, IDeviceContext
{
- internal IMacContext maccontext;
+ internal IMacContext? maccontext;
private bool disposed = false;
private static float defDpiX = 0;
private static float defDpiY = 0;
/* Get XVisualInfo for this visual */
visual.visualid = LibX11Functions.XVisualIDFromVisual(defvisual);
vPtr = LibX11Functions.XGetVisualInfo(Gdip.Display, 0x1 /* VisualIDMask */, ref visual, ref nitems);
- visual = (XVisualInfo)Marshal.PtrToStructure(vPtr, typeof(XVisualInfo));
+ visual = (XVisualInfo)Marshal.PtrToStructure(vPtr, typeof(XVisualInfo))!;
image = LibX11Functions.XGetImage(Gdip.Display, window, sourceX, sourceY, blockRegionSize.Width,
blockRegionSize.Height, AllPlanes, 2 /* ZPixmap*/);
if (image == IntPtr.Zero)
Gdip.CheckStatus(status);
}
- public void EnumerateMetafile(Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ public void EnumerateMetafile(Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes? imageAttr)
{
throw new NotImplementedException();
}
- public void EnumerateMetafile(Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ public void EnumerateMetafile(Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes? imageAttr)
{
throw new NotImplementedException();
}
- public void EnumerateMetafile(Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ public void EnumerateMetafile(Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes? imageAttr)
{
throw new NotImplementedException();
}
- public void EnumerateMetafile(Metafile metafile, Point[] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ public void EnumerateMetafile(Metafile metafile, Point[] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes? imageAttr)
{
throw new NotImplementedException();
}
- public void EnumerateMetafile(Metafile metafile, PointF[] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ public void EnumerateMetafile(Metafile metafile, PointF[] destPoints, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes? imageAttr)
{
throw new NotImplementedException();
}
- public void EnumerateMetafile(Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ public void EnumerateMetafile(Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes? imageAttr)
{
throw new NotImplementedException();
}
- public void EnumerateMetafile(Metafile metafile, Point[] destPoints, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ public void EnumerateMetafile(Metafile metafile, Point[] destPoints, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes? imageAttr)
{
throw new NotImplementedException();
}
- public void EnumerateMetafile(Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ public void EnumerateMetafile(Metafile metafile, Rectangle destRect, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes? imageAttr)
{
throw new NotImplementedException();
}
- public void EnumerateMetafile(Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ public void EnumerateMetafile(Metafile metafile, Point destPoint, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes? imageAttr)
{
throw new NotImplementedException();
}
- public void EnumerateMetafile(Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ public void EnumerateMetafile(Metafile metafile, RectangleF destRect, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes? imageAttr)
{
throw new NotImplementedException();
}
- public void EnumerateMetafile(Metafile metafile, PointF[] destPoints, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ public void EnumerateMetafile(Metafile metafile, PointF[] destPoints, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes? imageAttr)
{
throw new NotImplementedException();
}
- public void EnumerateMetafile(Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
+ public void EnumerateMetafile(Metafile metafile, PointF destPoint, RectangleF srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes? imageAttr)
{
throw new NotImplementedException();
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
- public static Graphics FromHdcInternal(IntPtr hdc)
+ public static Graphics? FromHdcInternal(IntPtr hdc)
{
Gdip.Display = hdc;
return null;
/// We don't keep a GraphicsContext for the current context since it is available at any time from GDI+ and
/// we don't want to keep track of changes in it.
/// </summary>
- private GraphicsContext _previousContext;
+ private GraphicsContext? _previousContext;
private static readonly object s_syncObject = new object();
// Object reference used for printing; it could point to a PrintPreviewGraphics to obtain the VisibleClipBounds, or
// a DeviceContext holding a printer DC.
- private object _printingHelper;
+ private object? _printingHelper;
// GDI+'s preferred HPALETTE.
private static IntPtr s_halftonePalette;
// pointer back to the Image backing a specific graphic object
- private Image _backingImage;
+ private Image? _backingImage;
/// <summary>
/// Constructor to initialize this object from a native GDI+ Graphics pointer.
while (_previousContext != null)
{
// Dispose entire stack.
- GraphicsContext context = _previousContext.Previous;
+ GraphicsContext? context = _previousContext.Previous;
_previousContext.Dispose();
_previousContext = context;
}
/// Represents an object used in connection with the printing API, it is used to hold a reference to a
/// PrintPreviewGraphics (fake graphics) or a printer DeviceContext (and maybe more in the future).
/// </summary>
- internal object PrintingHelper
+ internal object? PrintingHelper
{
get => _printingHelper;
set
PointF destPoint,
EnumerateMetafileProc callback,
IntPtr callbackData,
- ImageAttributes imageAttr)
+ ImageAttributes? imageAttr)
{
Gdip.CheckStatus(Gdip.GdipEnumerateMetafileDestPoint(
new HandleRef(this, NativeGraphics),
Point destPoint,
EnumerateMetafileProc callback,
IntPtr callbackData,
- ImageAttributes imageAttr)
+ ImageAttributes? imageAttr)
{
Gdip.CheckStatus(Gdip.GdipEnumerateMetafileDestPointI(
new HandleRef(this, NativeGraphics),
RectangleF destRect,
EnumerateMetafileProc callback,
IntPtr callbackData,
- ImageAttributes imageAttr)
+ ImageAttributes? imageAttr)
{
Gdip.CheckStatus(Gdip.GdipEnumerateMetafileDestRect(
new HandleRef(this, NativeGraphics),
Rectangle destRect,
EnumerateMetafileProc callback,
IntPtr callbackData,
- ImageAttributes imageAttr)
+ ImageAttributes? imageAttr)
{
Gdip.CheckStatus(Gdip.GdipEnumerateMetafileDestRectI(
new HandleRef(this, NativeGraphics),
PointF[] destPoints,
EnumerateMetafileProc callback,
IntPtr callbackData,
- ImageAttributes imageAttr)
+ ImageAttributes? imageAttr)
{
if (destPoints == null)
throw new ArgumentNullException(nameof(destPoints));
Point[] destPoints,
EnumerateMetafileProc callback,
IntPtr callbackData,
- ImageAttributes imageAttr)
+ ImageAttributes? imageAttr)
{
if (destPoints == null)
throw new ArgumentNullException(nameof(destPoints));
GraphicsUnit unit,
EnumerateMetafileProc callback,
IntPtr callbackData,
- ImageAttributes imageAttr)
+ ImageAttributes? imageAttr)
{
Gdip.CheckStatus(Gdip.GdipEnumerateMetafileSrcRectDestPoint(
new HandleRef(this, NativeGraphics),
GraphicsUnit unit,
EnumerateMetafileProc callback,
IntPtr callbackData,
- ImageAttributes imageAttr)
+ ImageAttributes? imageAttr)
{
Gdip.CheckStatus(Gdip.GdipEnumerateMetafileSrcRectDestPointI(
new HandleRef(this, NativeGraphics),
GraphicsUnit unit,
EnumerateMetafileProc callback,
IntPtr callbackData,
- ImageAttributes imageAttr)
+ ImageAttributes? imageAttr)
{
Gdip.CheckStatus(Gdip.GdipEnumerateMetafileSrcRectDestRect(
new HandleRef(this, NativeGraphics),
GraphicsUnit unit,
EnumerateMetafileProc callback,
IntPtr callbackData,
- ImageAttributes imageAttr)
+ ImageAttributes? imageAttr)
{
Gdip.CheckStatus(Gdip.GdipEnumerateMetafileSrcRectDestRectI(
new HandleRef(this, NativeGraphics),
GraphicsUnit unit,
EnumerateMetafileProc callback,
IntPtr callbackData,
- ImageAttributes imageAttr)
+ ImageAttributes? imageAttr)
{
if (destPoints == null)
throw new ArgumentNullException(nameof(destPoints));
GraphicsUnit unit,
EnumerateMetafileProc callback,
IntPtr callbackData,
- ImageAttributes imageAttr)
+ ImageAttributes? imageAttr)
{
if (destPoints == null)
throw new ArgumentNullException(nameof(destPoints));
currentOffset.Y = elements[5];
}
- GraphicsContext context = _previousContext;
+ GraphicsContext? context = _previousContext;
while (context != null)
{
{
context = context.Previous;
- if (context == null || !context.Next.IsCumulative)
+ if (context == null || !context.Next!.IsCumulative)
{
break;
}
private void PopContext(int currentContextState)
{
Debug.Assert(_previousContext != null, "Trying to restore a context when the stack is empty");
- GraphicsContext context = _previousContext;
+ GraphicsContext? context = _previousContext;
// Pop all contexts up the stack.
while (context != null)
// This is called from AppDomain.ProcessExit and AppDomain.DomainUnload.
[PrePrepareMethod]
- private static void OnDomainUnload(object sender, EventArgs e)
+ private static void OnDomainUnload(object? sender, EventArgs e)
{
if (s_halftonePalette != IntPtr.Zero)
{
/// <summary>
/// Draws a string with the specified font.
/// </summary>
- public void DrawString(string s, Font font, Brush brush, float x, float y)
+ public void DrawString(string? s, Font font, Brush brush, float x, float y)
{
DrawString(s, font, brush, new RectangleF(x, y, 0, 0), null);
}
- public void DrawString(string s, Font font, Brush brush, PointF point)
+ public void DrawString(string? s, Font font, Brush brush, PointF point)
{
DrawString(s, font, brush, new RectangleF(point.X, point.Y, 0, 0), null);
}
- public void DrawString(string s, Font font, Brush brush, float x, float y, StringFormat format)
+ public void DrawString(string? s, Font font, Brush brush, float x, float y, StringFormat? format)
{
DrawString(s, font, brush, new RectangleF(x, y, 0, 0), format);
}
- public void DrawString(string s, Font font, Brush brush, PointF point, StringFormat format)
+ public void DrawString(string? s, Font font, Brush brush, PointF point, StringFormat? format)
{
DrawString(s, font, brush, new RectangleF(point.X, point.Y, 0, 0), format);
}
- public void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle)
+ public void DrawString(string? s, Font font, Brush brush, RectangleF layoutRectangle)
{
DrawString(s, font, brush, layoutRectangle, null);
}
- public void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
+ public void DrawString(string? s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat? format)
{
if (brush == null)
throw new ArgumentNullException(nameof(brush));
}
public SizeF MeasureString(
- string text,
+ string? text,
Font font,
SizeF layoutArea,
- StringFormat stringFormat,
+ StringFormat? stringFormat,
out int charactersFitted,
out int linesFilled)
{
return boundingBox.Size;
}
- public SizeF MeasureString(string text, Font font, PointF origin, StringFormat stringFormat)
+ public SizeF MeasureString(string? text, Font font, PointF origin, StringFormat? stringFormat)
{
if (string.IsNullOrEmpty(text))
return SizeF.Empty;
return boundingBox.Size;
}
- public SizeF MeasureString(string text, Font font, SizeF layoutArea) => MeasureString(text, font, layoutArea, null);
+ public SizeF MeasureString(string? text, Font font, SizeF layoutArea) => MeasureString(text, font, layoutArea, null);
- public SizeF MeasureString(string text, Font font, SizeF layoutArea, StringFormat stringFormat)
+ public SizeF MeasureString(string? text, Font font, SizeF layoutArea, StringFormat? stringFormat)
{
if (string.IsNullOrEmpty(text))
return SizeF.Empty;
return boundingBox.Size;
}
- public SizeF MeasureString(string text, Font font)
+ public SizeF MeasureString(string? text, Font font)
{
return MeasureString(text, font, new SizeF(0, 0));
}
- public SizeF MeasureString(string text, Font font, int width)
+ public SizeF MeasureString(string? text, Font font, int width)
{
return MeasureString(text, font, new SizeF(width, 999999));
}
- public SizeF MeasureString(string text, Font font, int width, StringFormat format)
+ public SizeF MeasureString(string? text, Font font, int width, StringFormat? format)
{
return MeasureString(text, font, new SizeF(width, 999999), format);
}
- public Region[] MeasureCharacterRanges(string text, Font font, RectangleF layoutRect, StringFormat stringFormat)
+ public Region[] MeasureCharacterRanges(string? text, Font font, RectangleF layoutRect, StringFormat? stringFormat)
{
if (string.IsNullOrEmpty(text))
return Array.Empty<Region>();
}
}
- public void DrawImage(Image image, PointF[] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr)
+ public void DrawImage(Image image, PointF[] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes? imageAttr)
{
DrawImage(image, destPoints, srcRect, srcUnit, imageAttr, null, 0);
}
PointF[] destPoints,
RectangleF srcRect,
GraphicsUnit srcUnit,
- ImageAttributes imageAttr,
- DrawImageAbort callback)
+ ImageAttributes? imageAttr,
+ DrawImageAbort? callback)
{
DrawImage(image, destPoints, srcRect, srcUnit, imageAttr, callback, 0);
}
PointF[] destPoints,
RectangleF srcRect,
GraphicsUnit srcUnit,
- ImageAttributes imageAttr,
- DrawImageAbort callback,
+ ImageAttributes? imageAttr,
+ DrawImageAbort? callback,
int callbackData)
{
if (destPoints == null)
Point[] destPoints,
Rectangle srcRect,
GraphicsUnit srcUnit,
- ImageAttributes imageAttr)
+ ImageAttributes? imageAttr)
{
DrawImage(image, destPoints, srcRect, srcUnit, imageAttr, null, 0);
}
Point[] destPoints,
Rectangle srcRect,
GraphicsUnit srcUnit,
- ImageAttributes imageAttr,
- DrawImageAbort callback)
+ ImageAttributes? imageAttr,
+ DrawImageAbort? callback)
{
DrawImage(image, destPoints, srcRect, srcUnit, imageAttr, callback, 0);
}
Point[] destPoints,
Rectangle srcRect,
GraphicsUnit srcUnit,
- ImageAttributes imageAttr,
- DrawImageAbort callback,
+ ImageAttributes? imageAttr,
+ DrawImageAbort? callback,
int callbackData)
{
if (destPoints == null)
float srcWidth,
float srcHeight,
GraphicsUnit srcUnit,
- ImageAttributes imageAttrs)
+ ImageAttributes? imageAttrs)
{
DrawImage(image, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit, imageAttrs, null);
}
float srcWidth,
float srcHeight,
GraphicsUnit srcUnit,
- ImageAttributes imageAttrs,
- DrawImageAbort callback)
+ ImageAttributes? imageAttrs,
+ DrawImageAbort? callback)
{
DrawImage(image, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit, imageAttrs, callback, IntPtr.Zero);
}
float srcWidth,
float srcHeight,
GraphicsUnit srcUnit,
- ImageAttributes imageAttrs,
- DrawImageAbort callback,
+ ImageAttributes? imageAttrs,
+ DrawImageAbort? callback,
IntPtr callbackData)
{
if (image == null)
int srcWidth,
int srcHeight,
GraphicsUnit srcUnit,
- ImageAttributes imageAttr)
+ ImageAttributes? imageAttr)
{
DrawImage(image, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit, imageAttr, null);
}
int srcWidth,
int srcHeight,
GraphicsUnit srcUnit,
- ImageAttributes imageAttr,
- DrawImageAbort callback)
+ ImageAttributes? imageAttr,
+ DrawImageAbort? callback)
{
DrawImage(image, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit, imageAttr, callback, IntPtr.Zero);
}
int srcWidth,
int srcHeight,
GraphicsUnit srcUnit,
- ImageAttributes imageAttrs,
- DrawImageAbort callback,
+ ImageAttributes? imageAttrs,
+ DrawImageAbort? callback,
IntPtr callbackData)
{
if (image == null)
/// <summary>
/// The context's clip region.
/// </summary>
- private Region _clipRegion;
+ private Region? _clipRegion;
/// <summary>
/// The next context up the stack.
/// </summary>
- private GraphicsContext _nextContext;
+ private GraphicsContext? _nextContext;
/// <summary>
/// The previous context down the stack.
/// </summary>
- private GraphicsContext _prevContext;
+ private GraphicsContext? _prevContext;
/// <summary>
/// Flags that determines whether the context was created for a Graphics.Save() operation.
/// </summary>
private bool _isCumulative;
- private GraphicsContext()
- {
- }
-
public GraphicsContext(Graphics g)
{
Matrix transform = g.Transform;
/// <summary>
/// The clipping region the GraphicsContext.
/// </summary>
- public Region Clip
+ public Region? Clip
{
get
{
/// <summary>
/// The next GraphicsContext object in the stack.
/// </summary>
- public GraphicsContext Next
+ public GraphicsContext? Next
{
get
{
/// <summary>
/// The previous GraphicsContext object in the stack.
/// </summary>
- public GraphicsContext Previous
+ public GraphicsContext? Previous
{
get
{
internal class IconImage : ImageData
{
internal BitmapInfoHeader iconHeader; //image header
- internal uint[] iconColors; //colors table
- internal byte[] iconXOR; // bits for XOR mask
- internal byte[] iconAND; //bits for AND mask
+ internal uint[]? iconColors; //colors table
+ internal byte[]? iconXOR; // bits for XOR mask
+ internal byte[]? iconAND; //bits for AND mask
};
[StructLayout(LayoutKind.Sequential)]
internal class IconDump : ImageData
{
- internal byte[] data;
+ internal byte[]? data;
};
private Size iconSize;
private IntPtr handle = IntPtr.Zero;
private IconDir iconDir;
private ushort id;
- private ImageData[] imageData;
+ private ImageData[]? imageData;
private bool undisposable;
private bool disposed;
- private Bitmap bitmap;
+ private Bitmap? bitmap;
private Icon()
{
if (type == null)
throw new NullReferenceException();
- using (Stream s = type.GetTypeInfo().Assembly.GetManifestResourceStream(type, resource))
+ using (Stream? s = type.GetTypeInfo().Assembly.GetManifestResourceStream(type, resource))
{
if (s == null)
{
internal Icon(string resourceName, bool undisposable)
{
- using (Stream s = typeof(Icon).GetTypeInfo().Assembly.GetManifestResourceStream(resourceName))
+ using (Stream? s = typeof(Icon).GetTypeInfo().Assembly.GetManifestResourceStream(resourceName))
{
if (s == null)
{
private Icon(SerializationInfo info, StreamingContext context)
{
- byte[] iconData = (byte[])info.GetValue("IconData", typeof(byte[])); // Do not rename (binary serialization)
- Size iconSize = (Size)info.GetValue("IconSize", typeof(Size)); // Do not rename (binary serialization)
+ byte[] iconData = (byte[])info.GetValue("IconData", typeof(byte[]))!; // Do not rename (binary serialization)
+ Size iconSize = (Size)info.GetValue("IconSize", typeof(Size))!; // Do not rename (binary serialization)
var dataStream = new MemoryStream(iconData);
InitFromStreamWithSize(dataStream, iconSize.Width, iconSize.Height);
writer.Write(bih.biClrImportant);
//now write color table
- int colCount = ii.iconColors.Length;
+ int colCount = ii.iconColors!.Length;
for (int j = 0; j < colCount; j++)
writer.Write(ii.iconColors[j]);
//now write XOR Mask
- writer.Write(ii.iconXOR);
+ writer.Write(ii.iconXOR!);
//now write AND Mask
- writer.Write(ii.iconAND);
+ writer.Write(ii.iconAND!);
}
private void SaveIconDump(BinaryWriter writer, IconDump id)
{
- writer.Write(id.data);
+ writer.Write(id.data!);
}
private void SaveIconDirEntry(BinaryWriter writer, IconDirEntry ide, uint offset)
while (writer.BaseStream.Length < iconDir.idEntries[i].imageOffset)
writer.Write((byte)0);
- if (imageData[i] is IconDump)
+ if (imageData![i] is IconDump)
SaveIconDump(writer, (IconDump)imageData[i]);
else
SaveIconImage(writer, (IconImage)imageData[i]);
}
SaveIconDirEntry(writer, iconDir.idEntries[best], 22);
- SaveIconImage(writer, (IconImage)imageData[best]);
+ SaveIconImage(writer, (IconImage)imageData![best]);
}
private void SaveBitmapAsIcon(BinaryWriter writer)
// when transformed into a bitmap only a single image exists
IconDirEntry ide = default;
- ide.width = (byte)bitmap.Width;
+ ide.width = (byte)bitmap!.Width;
ide.height = (byte)bitmap.Height;
ide.colorCount = 0; // 32 bbp == 0, for palette size
ide.reserved = 0; // always 0
{
ColorPalette pal = bmp.Palette; // Managed palette
- for (int i = 0; i < ii.iconColors.Length; i++)
+ for (int i = 0; i < ii.iconColors!.Length; i++)
{
pal.Entries[i] = Color.FromArgb((int)ii.iconColors[i] | unchecked((int)0xff000000));
}
for (int y = 0; y < biHeight; y++)
{
- Marshal.Copy(ii.iconXOR, bytesPerLine * y,
+ Marshal.Copy(ii.iconXOR!, bytesPerLine * y,
(IntPtr)(bits.Scan0.ToInt64() + bits.Stride * (biHeight - 1 - y)), bytesPerLine);
}
{
for (int bit = 7; bit >= 0; bit--)
{
- if (((ii.iconAND[y * bytesPerLine + x] >> bit) & 1) != 0)
+ if (((ii.iconAND![y * bytesPerLine + x] >> bit) & 1) != 0)
{
bmp.SetPixel(x * 8 + 7 - bit, biHeight - y - 1, Color.Transparent);
}
private const int PNGSignature2 = 13 + (10 << 8) + (26 << 16) + (10 << 24);
// Icon data
- private readonly byte[] _iconData;
+ private readonly byte[]? _iconData;
private uint _bestImageOffset;
private uint _bestBitDepth;
private uint _bestBytesInRes;
public Icon(Type type, string resource) : this()
{
- Stream stream = type.Module.Assembly.GetManifestResourceStream(type, resource);
+ Stream? stream = type.Module.Assembly.GetManifestResourceStream(type, resource);
if (stream == null)
{
throw new ArgumentException(SR.Format(SR.ResourceNotFound, type, resource));
private Icon(SerializationInfo info, StreamingContext context)
{
- _iconData = (byte[])info.GetValue("IconData", typeof(byte[])); // Do not rename (binary serialization)
- _iconSize = (Size)info.GetValue("IconSize", typeof(Size)); // Do not rename (binary serialization)
+ _iconData = (byte[])info.GetValue("IconData", typeof(byte[]))!; // Do not rename (binary serialization)
+ _iconSize = (Size)info.GetValue("IconSize", typeof(Size))!; // Do not rename (binary serialization)
Initialize(_iconSize.Width, _iconSize.Height);
}
si.AddValue("IconSize", _iconSize, typeof(Size)); // Do not rename (binary serialization)
}
- public static Icon ExtractAssociatedIcon(string filePath) => ExtractAssociatedIcon(filePath, 0);
+ public static Icon? ExtractAssociatedIcon(string filePath) => ExtractAssociatedIcon(filePath, 0);
- private static unsafe Icon ExtractAssociatedIcon(string filePath, int index)
+ private static unsafe Icon? ExtractAssociatedIcon(string filePath, int index)
{
if (filePath == null)
{
private unsafe Bitmap BmpFrame()
{
- Bitmap bitmap = null;
+ Bitmap? bitmap = null;
if (_iconData != null && _bestBitDepth == 32)
{
// GDI+ doesnt handle 32 bpp icons with alpha properly
SafeNativeMethods.GetObject(new HandleRef(null, info.hbmColor), sizeof(SafeNativeMethods.BITMAP), ref bmp);
if (bmp.bmBitsPixel == 32)
{
- Bitmap tmpBitmap = null;
- BitmapData bmpData = null;
- BitmapData targetData = null;
+ Bitmap? tmpBitmap = null;
+ BitmapData? bmpData = null;
+ BitmapData? targetData = null;
try
{
tmpBitmap = Image.FromHbitmap(info.hbmColor);
Size size = Size;
bitmap = new Bitmap(size.Width, size.Height); // initialized to transparent
- Graphics graphics = null;
+ Graphics? graphics = null;
using (graphics = Graphics.FromImage(bitmap))
{
try
status = Gdip.GdipGetPropertyItem(nativeImage, propid, propSize, property);
Gdip.CheckStatus(status);
gdipProperty = (GdipPropertyItem)Marshal.PtrToStructure(property,
- typeof(GdipPropertyItem));
+ typeof(GdipPropertyItem))!;
GdipPropertyItem.MarshalTo(gdipProperty, item);
}
finally
return item;
}
- public Image GetThumbnailImage(int thumbWidth, int thumbHeight, Image.GetThumbnailImageAbort callback, IntPtr callbackData)
+ public Image GetThumbnailImage(int thumbWidth, int thumbHeight, Image.GetThumbnailImageAbort? callback, IntPtr callbackData)
{
if ((thumbWidth <= 0) || (thumbHeight <= 0))
throw new OutOfMemoryException(SR.InvalidThumbnailSize);
return ThumbNail;
}
- internal ImageCodecInfo FindEncoderForFormat(ImageFormat format)
+ internal ImageCodecInfo? FindEncoderForFormat(ImageFormat format)
{
ImageCodecInfo[] encoders = ImageCodecInfo.GetImageEncoders();
- ImageCodecInfo encoder = null;
+ ImageCodecInfo? encoder = null;
if (format.Guid.Equals(ImageFormat.MemoryBmp.Guid))
format = ImageFormat.Png;
public void Save(string filename, ImageFormat format)
{
- ImageCodecInfo encoder = FindEncoderForFormat(format);
+ ImageCodecInfo? encoder = FindEncoderForFormat(format);
if (encoder == null)
{
// second chance
Save(filename, encoder, null);
}
- public void Save(string filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
+ public void Save(string filename, ImageCodecInfo encoder, EncoderParameters? encoderParams)
{
int st;
Guid guid = encoder.Clsid;
dest = ImageFormat.Png;
// If we don't find an Encoder (for things like Icon), we just switch back to PNG...
- ImageCodecInfo codec = FindEncoderForFormat(dest) ?? FindEncoderForFormat(ImageFormat.Png);
+ ImageCodecInfo codec = FindEncoderForFormat(dest) ?? FindEncoderForFormat(ImageFormat.Png)!;
Save(stream, codec, null);
}
public void Save(Stream stream, ImageFormat format)
{
- ImageCodecInfo encoder = FindEncoderForFormat(format);
+ ImageCodecInfo? encoder = FindEncoderForFormat(format);
if (encoder == null)
throw new ArgumentException(SR.Format(SR.NoCodecAvailableForFormat, format.Guid));
Save(stream, encoder, null);
}
- public void Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
+ public void Save(Stream stream, ImageCodecInfo encoder, EncoderParameters? encoderParams)
{
int st;
IntPtr nativeEncoderParams;
if (propitem == null)
throw new ArgumentNullException(nameof(propitem));
- int nItemSize = Marshal.SizeOf(propitem.Value[0]);
+ int nItemSize = Marshal.SizeOf(propitem.Value![0]);
int size = nItemSize * propitem.Value.Length;
IntPtr dest = Marshal.AllocHGlobal(size);
try
for (int i = 0; i < propNums; i++, propPtr = new IntPtr(propPtr.ToInt64() + propSize))
{
gdipProperty = (GdipPropertyItem)Marshal.PtrToStructure
- (propPtr, typeof(GdipPropertyItem));
+ (propPtr, typeof(GdipPropertyItem))!;
items[i] = new PropertyItem();
GdipPropertyItem.MarshalTo(gdipProperty, items[i]);
}
if (format == null)
throw new ArgumentNullException(nameof(format));
- ImageCodecInfo codec = format.FindEncoder();
+ ImageCodecInfo? codec = format.FindEncoder();
if (codec == null)
- codec = ImageFormat.Png.FindEncoder();
+ codec = ImageFormat.Png.FindEncoder()!;
Save(filename, codec, null);
}
/// <summary>
/// Saves this <see cref='Image'/> to the specified file in the specified format and with the specified encoder parameters.
/// </summary>
- public void Save(string filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
+ public void Save(string filename, ImageCodecInfo encoder, EncoderParameters? encoderParams)
{
if (filename == null)
throw new ArgumentNullException(nameof(filename));
if (_rawData != null)
{
- ImageCodecInfo rawEncoder = RawFormat.FindEncoder();
+ ImageCodecInfo? rawEncoder = RawFormat.FindEncoder();
if (rawEncoder != null && rawEncoder.Clsid == g)
{
using (FileStream fs = File.OpenWrite(filename))
dest = ImageFormat.Png;
// If we don't find an Encoder (for things like Icon), we just switch back to PNG...
- ImageCodecInfo codec = dest.FindEncoder() ?? ImageFormat.Png.FindEncoder();
+ ImageCodecInfo codec = dest.FindEncoder() ?? ImageFormat.Png.FindEncoder()!;
Save(stream, codec, null);
}
if (format == null)
throw new ArgumentNullException(nameof(format));
- ImageCodecInfo codec = format.FindEncoder();
+ ImageCodecInfo codec = format.FindEncoder()!;
Save(stream, codec, null);
}
/// <summary>
/// Saves this <see cref='Image'/> to the specified stream in the specified format.
/// </summary>
- public void Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
+ public void Save(Stream stream, ImageCodecInfo encoder, EncoderParameters? encoderParams)
{
if (stream == null)
throw new ArgumentNullException(nameof(stream));
if (_rawData != null)
{
- ImageCodecInfo rawEncoder = RawFormat.FindEncoder();
+ ImageCodecInfo? rawEncoder = RawFormat.FindEncoder();
if (rawEncoder != null && rawEncoder.Clsid == g)
{
stream.Write(_rawData, 0, _rawData.Length);
/// <summary>
/// Adds an <see cref='EncoderParameters'/> to this <see cref='Image'/>.
/// </summary>
- public void SaveAdd(EncoderParameters encoderParams)
+ public void SaveAdd(EncoderParameters? encoderParams)
{
IntPtr encoder = IntPtr.Zero;
if (encoderParams != null)
/// <summary>
/// Adds an <see cref='EncoderParameters'/> to the specified <see cref='Image'/>.
/// </summary>
- public void SaveAdd(Image image, EncoderParameters encoderParams)
+ public void SaveAdd(Image image, EncoderParameters? encoderParams)
{
IntPtr encoder = IntPtr.Zero;
/// <summary>
/// Returns the thumbnail for this <see cref='Image'/>.
/// </summary>
- public Image GetThumbnailImage(int thumbWidth, int thumbHeight, GetThumbnailImageAbort callback, IntPtr callbackData)
+ public Image GetThumbnailImage(int thumbWidth, int thumbHeight, GetThumbnailImageAbort? callback, IntPtr callbackData)
{
IntPtr thumbImage = IntPtr.Zero;
/// <summary>
/// Gets the specified property item from this <see cref='Image'/>.
/// </summary>
- public PropertyItem GetPropertyItem(int propid)
+ public PropertyItem? GetPropertyItem(int propid)
{
Gdip.CheckStatus(Gdip.GdipGetPropertyItemSize(new HandleRef(this, nativeImage), propid, out int size));
internal IntPtr nativeImage;
- private object _userData;
+ private object? _userData;
// used to work around lack of animated gif encoder... rarely set...
- private byte[] _rawData;
+ private byte[]? _rawData;
[Localizable(false)]
[DefaultValue(null)]
- public object Tag
+ public object? Tag
{
get => _userData;
set => _userData = value;
private protected Image(SerializationInfo info, StreamingContext context)
#pragma warning restore CA2229
{
- byte[] dat = (byte[])info.GetValue("Data", typeof(byte[])); // Do not rename (binary serialization)
+ byte[] dat = (byte[])info.GetValue("Data", typeof(byte[]))!; // Do not rename (binary serialization)
try
{
/// <summary>
/// Returns information about the codecs used for this <see cref='Image'/>.
/// </summary>
- public EncoderParameters GetEncoderParameterList(Guid encoder)
+ public EncoderParameters? GetEncoderParameterList(Guid encoder)
{
EncoderParameters p;
}
}
- internal static unsafe void EnsureSave(Image image, string filename, Stream dataStream)
+ internal static unsafe void EnsureSave(Image image, string? filename, Stream? dataStream)
{
if (image.RawFormat.Equals(ImageFormat.Gif))
{
{
try
{
- Stream created = null;
+ Stream? created = null;
long lastPos = 0;
if (dataStream != null)
{
{
if (dataStream == null)
{
- created = dataStream = File.OpenRead(filename);
+ created = dataStream = File.OpenRead(filename!);
}
image._rawData = new byte[(int)dataStream.Length];
}
else
{
- dataStream.Position = lastPos;
+ dataStream!.Position = lastPos;
}
}
}
private int frameCount;
private int activeFrame;
- private Thread thread;
+ private Thread? thread;
public AnimateEventArgs(Image image)
{
frameCount = image.GetFrameCount(FrameDimension.Time);
}
- public Thread RunThread
+ public Thread? RunThread
{
get { return thread; }
set { thread = value; }
return;
PropertyItem item = image.GetPropertyItem(0x5100); // FrameDelay in libgdiplus
- byte[] value = item.Value;
+ byte[] value = item.Value!;
int[] delay = new int[(value.Length >> 2)];
for (int i = 0, n = 0; i < value.Length; i += 4, n++)
{
thread.Start();
}
- public static bool CanAnimate(Image image)
+ public static bool CanAnimate(Image? image)
{
if (image == null)
return false;
if (ht.ContainsKey(image))
{
- AnimateEventArgs evtArgs = (AnimateEventArgs)ht[image];
- evtArgs.RunThread.Abort();
+ AnimateEventArgs evtArgs = (AnimateEventArgs)ht[image]!;
+ evtArgs.RunThread!.Abort();
ht.Remove(image);
}
}
public static void UpdateFrames()
{
- foreach (Image image in ht.Keys)
- UpdateImageFrame(image);
+ foreach (Image? image in ht.Keys)
+ UpdateImageFrame(image!);
}
// this method avoid checks that aren't requied for UpdateFrames()
private static void UpdateImageFrame(Image image)
{
- AnimateEventArgs aea = (AnimateEventArgs)ht[image];
+ AnimateEventArgs aea = (AnimateEventArgs)ht[image]!;
image.SelectActiveFrame(FrameDimension.Time, aea.GetNextFrame());
}
}
/// <summary>
/// A list of images to be animated.
/// </summary>
- private static List<ImageInfo> s_imageInfoList;
+ private static List<ImageInfo>? s_imageInfoList;
/// <summary>
/// A variable to flag when an image or images need to be updated due to the selection of a new frame
/// <summary>
/// The thread used for animating the images.
/// </summary>
- private static Thread s_animationThread;
+ private static Thread? s_animationThread;
/// <summary>
/// Lock that allows either concurrent read-access to the images list for multiple threads, or write-
return;
}
- ImageInfo imageInfo = null;
+ ImageInfo? imageInfo = null;
// See comment in the class header about locking the image ref.
#pragma warning disable CA2002
/// <summary>
/// Whether or not the image has multiple time-based frames.
/// </summary>
- public static bool CanAnimate(Image image)
+ public static bool CanAnimate(Image? image)
{
if (image == null)
{
private readonly int _frameCount;
private bool _frameDirty;
private readonly bool _animated;
- private EventHandler _onFrameChangedHandler;
+ private EventHandler? _onFrameChangedHandler;
private readonly int[] _frameDelay;
private int _frameTimer;
{
_image = image;
_animated = ImageAnimator.CanAnimate(image);
+ _frameDelay = null!; // guaranteed to be initialized by the final check
if (_animated)
{
_frameCount = image.GetFrameCount(FrameDimension.Time);
- PropertyItem frameDelayItem = image.GetPropertyItem(PropertyTagFrameDelay);
+ PropertyItem? frameDelayItem = image.GetPropertyItem(PropertyTagFrameDelay);
// If the image does not have a frame delay, we just return 0.
//
{
// Convert the frame delay from byte[] to int
//
- byte[] values = frameDelayItem.Value;
+ byte[] values = frameDelayItem.Value!;
Debug.Assert(values.Length == 4 * FrameCount, "PropertyItem has invalid value byte array");
_frameDelay = new int[FrameCount];
for (int i = 0; i < FrameCount; ++i)
}
}
- public EventHandler FrameChangedHandler
+ public EventHandler? FrameChangedHandler
{
get
{
/// </summary>
public int FrameDelay(int frame)
{
- return _frameDelay[frame];
+ return _frameDelay![frame];
}
internal int FrameTimer
for (int i = 0; i < count; i++)
{
- Guid guid = (Guid)Marshal.PtrToStructure((IntPtr)(i * size + arrayOffset), typeof(Guid));
+ Guid guid = (Guid)Marshal.PtrToStructure((IntPtr)(i * size + arrayOffset), typeof(Guid))!;
int numberOfValues = Marshal.ReadInt32((IntPtr)(i * size + arrayOffset + 16));
EncoderParameterValueType type = (EncoderParameterValueType)Marshal.ReadInt32((IntPtr)(i * size + arrayOffset + 20));
IntPtr value = Marshal.ReadIntPtr((IntPtr)(i * size + arrayOffset + 24));
p.Dispose();
}
}
- _param = null;
+ _param = null!;
}
}
}
/// Returns a value indicating whether the specified object is an <see cref='FrameDimension'/> equivalent to
/// this <see cref='FrameDimension'/>.
/// </summary>
- public override bool Equals(object o)
+ public override bool Equals(object? o)
{
- FrameDimension format = o as FrameDimension;
+ FrameDimension? format = o as FrameDimension;
if (format == null)
return false;
return _guid == format._guid;
/// <summary>
/// Sets a color adjust matrix for image colors and a separate gray scale adjust matrix for gray scale values.
/// </summary>
- public void SetColorMatrices(ColorMatrix newColorMatrix, ColorMatrix grayMatrix)
+ public void SetColorMatrices(ColorMatrix newColorMatrix, ColorMatrix? grayMatrix)
{
SetColorMatrices(newColorMatrix, grayMatrix, ColorMatrixFlag.Default, ColorAdjustType.Default);
}
- public void SetColorMatrices(ColorMatrix newColorMatrix, ColorMatrix grayMatrix, ColorMatrixFlag flags)
+ public void SetColorMatrices(ColorMatrix newColorMatrix, ColorMatrix? grayMatrix, ColorMatrixFlag flags)
{
SetColorMatrices(newColorMatrix, grayMatrix, flags, ColorAdjustType.Default);
}
- public void SetColorMatrices(ColorMatrix newColorMatrix, ColorMatrix grayMatrix, ColorMatrixFlag mode,
+ public void SetColorMatrices(ColorMatrix newColorMatrix, ColorMatrix? grayMatrix, ColorMatrixFlag mode,
ColorAdjustType type)
{
int status = Gdip.GdipSetImageAttributesColorMatrix(
{
private Guid _clsid;
private Guid _formatID;
- private string _codecName;
- private string _dllName;
- private string _formatDescription;
- private string _filenameExtension;
- private string _mimeType;
+ private string? _codecName;
+ private string? _dllName;
+ private string? _formatDescription;
+ private string? _filenameExtension;
+ private string? _mimeType;
private ImageCodecFlags _flags;
private int _version;
- private byte[][] _signaturePatterns;
- private byte[][] _signatureMasks;
+ private byte[][]? _signaturePatterns;
+ private byte[][]? _signatureMasks;
internal ImageCodecInfo()
{
set { _formatID = value; }
}
- public string CodecName
+ public string? CodecName
{
get { return _codecName; }
set { _codecName = value; }
}
- public string DllName
+ public string? DllName
{
get
{
}
}
- public string FormatDescription
+ public string? FormatDescription
{
get { return _formatDescription; }
set { _formatDescription = value; }
}
- public string FilenameExtension
+ public string? FilenameExtension
{
get { return _filenameExtension; }
set { _filenameExtension = value; }
}
- public string MimeType
+ public string? MimeType
{
get { return _mimeType; }
set { _mimeType = value; }
}
[CLSCompliant(false)]
- public byte[][] SignaturePatterns
+ public byte[][]? SignaturePatterns
{
get { return _signaturePatterns; }
set { _signaturePatterns = value; }
}
[CLSCompliant(false)]
- public byte[][] SignatureMasks
+ public byte[][]? SignatureMasks
{
get { return _signatureMasks; }
set { _signatureMasks = value; }
for (int j = 0; j < codecp.SigCount; j++)
{
- codecs[index].SignaturePatterns[j] = new byte[codecp.SigSize];
- codecs[index].SignatureMasks[j] = new byte[codecp.SigSize];
+ codecs[index].SignaturePatterns![j] = new byte[codecp.SigSize];
+ codecs[index].SignatureMasks![j] = new byte[codecp.SigSize];
- Marshal.Copy((IntPtr)((long)codecp.SigMask + j * codecp.SigSize), codecs[index].SignatureMasks[j], 0, codecp.SigSize);
- Marshal.Copy((IntPtr)((long)codecp.SigPattern + j * codecp.SigSize), codecs[index].SignaturePatterns[j], 0, codecp.SigSize);
+ Marshal.Copy((IntPtr)((long)codecp.SigMask + j * codecp.SigSize), codecs[index].SignatureMasks![j], 0, codecp.SigSize);
+ Marshal.Copy((IntPtr)((long)codecp.SigPattern + j * codecp.SigSize), codecs[index].SignaturePatterns![j], 0, codecp.SigSize);
}
}
/// Returns a value indicating whether the specified object is an <see cref='ImageFormat'/> equivalent to this
/// <see cref='ImageFormat'/>.
/// </summary>
- public override bool Equals(object o)
+ public override bool Equals(object? o)
{
- ImageFormat format = o as ImageFormat;
+ ImageFormat? format = o as ImageFormat;
if (format == null)
return false;
return _guid == format._guid;
}
// Find any random encoder which supports this format
- internal ImageCodecInfo FindEncoder()
+ internal ImageCodecInfo? FindEncoder()
{
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
foreach (ImageCodecInfo codec in codecs)
Gdip.CheckStatus(status);
}
- public Metafile(IntPtr referenceHdc, EmfType emfType, string description) :
+ public Metafile(IntPtr referenceHdc, EmfType emfType, string? description) :
this(referenceHdc, default(RectangleF), MetafileFrameUnit.GdiCompatible, emfType, description)
{
}
- public Metafile(Stream stream, IntPtr referenceHdc, EmfType type, string description) :
+ public Metafile(Stream stream, IntPtr referenceHdc, EmfType type, string? description) :
this(stream, referenceHdc, default(RectangleF), MetafileFrameUnit.GdiCompatible, type, description)
{
}
- public Metafile(string fileName, IntPtr referenceHdc, EmfType type, string description) :
+ public Metafile(string fileName, IntPtr referenceHdc, EmfType type, string? description) :
this(fileName, referenceHdc, default(RectangleF), MetafileFrameUnit.GdiCompatible, type, description)
{
}
public Metafile(IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type,
- string desc)
+ string? desc)
{
int status = Gdip.GdipRecordMetafileI(referenceHdc, type, ref frameRect, frameUnit,
desc, out nativeImage);
}
public Metafile(Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit,
- EmfType type, string description)
+ EmfType type, string? description)
{
if (stream == null)
throw new NullReferenceException(nameof(stream));
}
public Metafile(Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit,
- EmfType type, string description)
+ EmfType type, string? description)
{
if (stream == null)
throw new NullReferenceException(nameof(stream));
}
public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit,
- EmfType type, string description)
+ EmfType type, string? description)
{
// Called in order to emulate exception behavior from .NET Framework related to invalid file paths.
Path.GetFullPath(fileName);
/// <summary>
/// Initializes a new instance of the <see cref='Metafile'/> class from the specified handle to a device context.
/// </summary>
- public Metafile(IntPtr referenceHdc, EmfType emfType, string description)
+ public Metafile(IntPtr referenceHdc, EmfType emfType, string? description)
{
Gdip.CheckStatus(Gdip.GdipRecordMetafile(
referenceHdc,
/// Initializes a new instance of the <see cref='Metafile'/> class from the specified device context, bounded
/// by the specified rectangle.
/// </summary>
- public Metafile(IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type, string desc)
+ public Metafile(IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type, string? desc)
{
IntPtr metafile = IntPtr.Zero;
/// <summary>
/// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
/// </summary>
- public Metafile(string fileName, IntPtr referenceHdc, EmfType type, string description)
+ public Metafile(string fileName, IntPtr referenceHdc, EmfType type, string? description)
{
// Called in order to emulate exception behavior from .NET Framework related to invalid file paths.
Path.GetFullPath(fileName);
/// <summary>
/// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
/// </summary>
- public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type, string description)
+ public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type, string? description)
{
// Called in order to emulate exception behavior from .NET Framework related to invalid file paths.
Path.GetFullPath(fileName);
/// <summary>
/// Initializes a new instance of the <see cref='Metafile'/> class from the specified data stream.
/// </summary>
- public Metafile(Stream stream, IntPtr referenceHdc, EmfType type, string description)
+ public Metafile(Stream stream, IntPtr referenceHdc, EmfType type, string? description)
{
Gdip.CheckStatus(Gdip.GdipRecordMetafileStream(
new GPStream(stream),
/// <summary>
/// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
/// </summary>
- public Metafile(Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type, string description)
+ public Metafile(Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type, string? description)
{
Gdip.CheckStatus(Gdip.GdipRecordMetafileStream(
new GPStream(stream),
/// <summary>
/// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
/// </summary>
- public Metafile(Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type, string description)
+ public Metafile(Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type, string? description)
{
IntPtr metafile = IntPtr.Zero;
metafileType == MetafileType.WmfPlaceable)
{
// WMF header
- header.wmf = (MetafileHeaderWmf)Marshal.PtrToStructure(memory, typeof(MetafileHeaderWmf));
+ header.wmf = (MetafileHeaderWmf)Marshal.PtrToStructure(memory, typeof(MetafileHeaderWmf))!;
header.emf = null;
}
else
{
// EMF header
header.wmf = null;
- header.emf = (MetafileHeaderEmf)Marshal.PtrToStructure(memory, typeof(MetafileHeaderEmf));
+ header.emf = (MetafileHeaderEmf)Marshal.PtrToStructure(memory, typeof(MetafileHeaderEmf))!;
}
}
finally
metafileType == MetafileType.WmfPlaceable)
{
// WMF header
- header.wmf = (MetafileHeaderWmf)Marshal.PtrToStructure(memory, typeof(MetafileHeaderWmf));
+ header.wmf = (MetafileHeaderWmf)Marshal.PtrToStructure(memory, typeof(MetafileHeaderWmf))!;
header.emf = null;
}
else
{
// EMF header
header.wmf = null;
- header.emf = (MetafileHeaderEmf)Marshal.PtrToStructure(memory, typeof(MetafileHeaderEmf));
+ header.emf = (MetafileHeaderEmf)Marshal.PtrToStructure(memory, typeof(MetafileHeaderEmf))!;
}
}
finally
metafileType == MetafileType.WmfPlaceable)
{
// WMF header
- header.wmf = (MetafileHeaderWmf)Marshal.PtrToStructure(memory, typeof(MetafileHeaderWmf));
+ header.wmf = (MetafileHeaderWmf)Marshal.PtrToStructure(memory, typeof(MetafileHeaderWmf))!;
header.emf = null;
}
else
{
// EMF header
header.wmf = null;
- header.emf = (MetafileHeaderEmf)Marshal.PtrToStructure(memory, typeof(MetafileHeaderEmf));
+ header.emf = (MetafileHeaderEmf)Marshal.PtrToStructure(memory, typeof(MetafileHeaderEmf))!;
}
}
finally
/// Initializes a new instance of the <see cref='Metafile'/> class from the specified device context, bounded
/// by the specified rectangle.
/// </summary>
- public Metafile(IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type, string description)
+ public Metafile(IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type, string? description)
{
Gdip.CheckStatus(Gdip.GdipRecordMetafile(
referenceHdc,
/// <summary>
/// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
/// </summary>
- public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, string desc) :
+ public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, string? desc) :
this(fileName, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual, desc)
{
}
/// <summary>
/// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
/// </summary>
- public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type, string description)
+ public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type, string? description)
{
// Called in order to emulate exception behavior from .NET Framework related to invalid file paths.
Path.GetFullPath(fileName);
/// <summary>
/// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
/// </summary>
- public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, string description) :
+ public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, string? description) :
this(fileName, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual, description)
{
}
public sealed class MetafileHeader
{
// determine which to use by nullity
- internal MetafileHeaderWmf wmf;
- internal MetafileHeaderEmf emf;
+ internal MetafileHeaderWmf? wmf;
+ internal MetafileHeaderEmf? emf;
internal MetafileHeader()
{
{
get
{
- return IsWmf() ? wmf.type : emf.type;
+ return IsWmf() ? wmf!.type : emf!.type;
}
}
{
get
{
- return IsWmf() ? wmf.size : emf.size;
+ return IsWmf() ? wmf!.size : emf!.size;
}
}
{
get
{
- return IsWmf() ? wmf.version : emf.version;
+ return IsWmf() ? wmf!.version : emf!.version;
}
}
{
get
{
- return IsWmf() ? wmf.dpiX : emf.dpiX;
+ return IsWmf() ? wmf!.dpiX : emf!.dpiX;
}
}
{
get
{
- return IsWmf() ? wmf.dpiY : emf.dpiY;
+ return IsWmf() ? wmf!.dpiY : emf!.dpiY;
}
}
get
{
return IsWmf() ?
- new Rectangle(wmf.X, wmf.Y, wmf.Width, wmf.Height) :
- new Rectangle(emf.X, emf.Y, emf.Width, emf.Height);
+ new Rectangle(wmf!.X, wmf.Y, wmf.Width, wmf.Height) :
+ new Rectangle(emf!.X, emf.Y, emf.Width, emf.Height);
}
}
public bool IsDisplay()
{
return IsEmfPlus() &&
- (((unchecked((int)emf.emfPlusFlags)) & ((int)EmfPlusFlags.Display)) != 0);
+ (((unchecked((int)emf!.emfPlusFlags)) & ((int)EmfPlusFlags.Display)) != 0);
}
/// <summary>
if (wmf == null && emf == null)
throw Gdip.StatusException(Gdip.InvalidParameter);
- return IsWmf() ? wmf.EmfPlusHeaderSize : emf.EmfPlusHeaderSize;
+ return IsWmf() ? wmf!.EmfPlusHeaderSize : emf!.EmfPlusHeaderSize;
}
}
if (wmf == null && emf == null)
throw Gdip.StatusException(Gdip.InvalidParameter);
- return IsWmf() ? wmf.LogicalDpiX : emf.LogicalDpiX;
+ return IsWmf() ? wmf!.LogicalDpiX : emf!.LogicalDpiX;
}
}
if (wmf == null && emf == null)
throw Gdip.StatusException(Gdip.InvalidParameter);
- return IsWmf() ? wmf.LogicalDpiY : emf.LogicalDpiX;
+ return IsWmf() ? wmf!.LogicalDpiY : emf!.LogicalDpiX;
}
}
}
public int Y;
public int Width;
public int Height;
- public SafeNativeMethods.ENHMETAHEADER EmfHeader;
+ public SafeNativeMethods.ENHMETAHEADER? EmfHeader;
public int EmfPlusHeaderSize;
public int LogicalDpiX;
public int LogicalDpiY;
private int _id;
private int _len;
private short _type;
- private byte[] _value;
+ private byte[]? _value;
internal PropertyItem()
{
/// <summary>
/// Contains the property value.
/// </summary>
- public byte[] Value
+ public byte[]? Value
{
get { return _value; }
set { _value = value; }
for (int i = 0; i < count; i++)
{
Debug.Assert(list[i] != null, "null value in active part of list");
- ISystemColorTracker tracker = (ISystemColorTracker)list[i].Target;
+ ISystemColorTracker? tracker = (ISystemColorTracker?)list[i].Target;
if (tracker != null)
{
// If object still around
int nPointSize = Marshal.SizeOf(pts[0]);
IntPtr pos = prt;
for (int i = 0; i < pts.Length; i++, pos = new IntPtr(pos.ToInt64() + nPointSize))
- pts[i] = (Point)Marshal.PtrToStructure(pos, typeof(Point));
+ pts[i] = (Point)Marshal.PtrToStructure(pos, typeof(Point))!;
Marshal.FreeHGlobal(prt);
}
int nPointSize = Marshal.SizeOf(pts[0]);
IntPtr pos = prt;
for (int i = 0; i < pts.Length; i++, pos = new IntPtr(pos.ToInt64() + nPointSize))
- pts[i] = (PointF)Marshal.PtrToStructure(pos, typeof(PointF));
+ pts[i] = (PointF)Marshal.PtrToStructure(pos, typeof(PointF))!;
Marshal.FreeHGlobal(prt);
}
// libgdiplus does not implement GdipGetPenCustomEndCap, so we cache the last-known value here.
// Note that this value is not necessarily in sync with the true native value of this property,
// as it could have been set outside of the CustomEndCap property on this type.
- private CustomLineCap _cachedEndCap;
+ private CustomLineCap? _cachedEndCap;
/// <summary>
/// Gets or sets a custom cap style to use at the beginning of lines drawn with this <see cref='Pen'/>.
}
// Windows GDI+ clones the CustomLineCap before storing it in the Pen.
- CustomLineCap clone = value == null ? null : (CustomLineCap)value.Clone();
+ CustomLineCap? clone = value == null ? null : (CustomLineCap)value.Clone();
int status = Gdip.GdipSetPenCustomEndCap(
new HandleRef(this, NativePen),
{
get
{
- Brush brush = null;
+ Brush? brush = null;
switch (PenType)
{
break;
}
- return brush;
+ return brush!;
}
set
{
private static Pen GetPen(object key, Color color)
{
- Pen Pen = (Pen)Gdip.ThreadData[key];
+ Pen? Pen = (Pen?)Gdip.ThreadData[key];
if (Pen == null)
{
Pen = new Pen(color, true);
/// </summary>
public class StandardPrintController : PrintController
{
- private DeviceContext _dc;
- private Graphics _graphics;
+ private DeviceContext? _dc;
+ private Graphics? _graphics;
/// <summary>
/// Implements StartPrint for printing to a physical printer.
public override void OnStartPrint(PrintDocument document, PrintEventArgs e)
{
Debug.Assert(_dc == null && _graphics == null, "PrintController methods called in the wrong order?");
+ Debug.Assert(_modeHandle != null);
base.OnStartPrint(document, e);
// the win32 methods below SuppressUnmanagedCodeAttributes so assertin on UnmanagedCodePermission is redundant
public override Graphics OnStartPage(PrintDocument document, PrintPageEventArgs e)
{
Debug.Assert(_dc != null && _graphics == null, "PrintController methods called in the wrong order?");
+ Debug.Assert(_modeHandle != null);
base.OnStartPage(document, e);
e.PageSettings.CopyToHdevmode(_modeHandle);
_graphics = Graphics.FromHdcInternal(_dc.Hdc);
- if (_graphics != null && document.OriginAtMargins)
+ if (document.OriginAtMargins)
{
// Adjust the origin of the graphics object to be at the
// user-specified margin location
[Serializable]
public partial class InvalidPrinterException : SystemException
{
- private readonly PrinterSettings _settings;
+ private readonly PrinterSettings? _settings;
/// <summary>
/// Initializes a new instance of the <see cref='InvalidPrinterException'/> class.
/// Compares this <see cref='Margins'/> to a specified <see cref='Margins'/> to see whether they
/// are equal.
/// </summary>
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (!(obj is Margins margins))
{
/// <summary>
/// Tests whether two <see cref='Margins'/> objects are identical.
/// </summary>
- public static bool operator ==(Margins m1, Margins m2)
+ public static bool operator ==(Margins? m1, Margins? m2)
{
if (m1 is null)
{
/// <summary>
/// Tests whether two <see cref='Margins'/> objects are different.
/// </summary>
- public static bool operator !=(Margins m1, Margins m2) => !(m1 == m2);
+ public static bool operator !=(Margins? m1, Margins? m2) => !(m1 == m2);
/// <summary>
/// Provides some interesting information for the Margins in String form.
private float hardMarginX;
private float hardMarginY;
private RectangleF printableArea;
- private PrinterSettings printerSettings;
+ private PrinterSettings printerSettings = null!;
#pragma warning restore 649
public PageSettings() : this(new PrinterSettings())
internal PrinterSettings printerSettings;
private TriState _color = TriState.Default;
- private PaperSize _paperSize;
- private PaperSource _paperSource;
- private PrinterResolution _printerResolution;
+ private PaperSize? _paperSize;
+ private PaperSource? _paperSource;
+ private PrinterResolution? _printerResolution;
private TriState _landscape = TriState.Default;
private Margins _margins = new Margins();
{
IntPtr modeHandle = printerSettings.GetHdevmode();
IntPtr modePointer = Interop.Kernel32.GlobalLock(new HandleRef(this, modeHandle));
- SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE)Marshal.PtrToStructure(modePointer, typeof(SafeNativeMethods.DEVMODE));
+ SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE)Marshal.PtrToStructure(modePointer, typeof(SafeNativeMethods.DEVMODE))!;
PaperSource result = PaperSourceFromMode(mode);
{
IntPtr modeHandle = printerSettings.GetHdevmode();
IntPtr modePointer = Interop.Kernel32.GlobalLock(new HandleRef(this, modeHandle));
- SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE)Marshal.PtrToStructure(modePointer, typeof(SafeNativeMethods.DEVMODE));
+ SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE)Marshal.PtrToStructure(modePointer, typeof(SafeNativeMethods.DEVMODE))!;
PrinterResolution result = PrinterResolutionFromMode(mode);
public void CopyToHdevmode(IntPtr hdevmode)
{
IntPtr modePointer = Interop.Kernel32.GlobalLock(hdevmode);
- SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE)Marshal.PtrToStructure(modePointer, typeof(SafeNativeMethods.DEVMODE));
+ SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE)Marshal.PtrToStructure(modePointer, typeof(SafeNativeMethods.DEVMODE))!;
if (_color.IsNotDefault && ((mode.dmFields & SafeNativeMethods.DM_COLOR) == SafeNativeMethods.DM_COLOR))
mode.dmColor = unchecked((short)(((bool)_color) ? SafeNativeMethods.DMCOLOR_COLOR : SafeNativeMethods.DMCOLOR_MONOCHROME));
{
IntPtr modeHandle = printerSettings.GetHdevmodeInternal();
IntPtr modePointer = Interop.Kernel32.GlobalLock(new HandleRef(this, modeHandle));
- SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE)Marshal.PtrToStructure(modePointer, typeof(SafeNativeMethods.DEVMODE));
+ SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE)Marshal.PtrToStructure(modePointer, typeof(SafeNativeMethods.DEVMODE))!;
short result = mode?.dmDriverExtra ?? 0;
}
IntPtr modePointer = Interop.Kernel32.GlobalLock(modeHandle);
- SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE)Marshal.PtrToStructure(modePointer, typeof(SafeNativeMethods.DEVMODE));
+ SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE)Marshal.PtrToStructure(modePointer, typeof(SafeNativeMethods.DEVMODE))!;
PaperSize result = PaperSizeFromMode(mode);
}
IntPtr pointer = Interop.Kernel32.GlobalLock(hdevmode);
- SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE)Marshal.PtrToStructure(pointer, typeof(SafeNativeMethods.DEVMODE));
+ SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE)Marshal.PtrToStructure(pointer, typeof(SafeNativeMethods.DEVMODE))!;
if ((mode.dmFields & SafeNativeMethods.DM_COLOR) == SafeNativeMethods.DM_COLOR)
{
throw new InvalidPrinterException(document.PrinterSettings);
}
- foreach (PreviewPageInfo pi in _list)
+ foreach (PreviewPageInfo? pi in _list)
{
- pi.Image.Dispose();
+ pi!.Image.Dispose();
}
_list.Clear();
/// </summary>
public partial class PreviewPrintController : PrintController
{
- private Graphics _graphics;
- private DeviceContext _dc;
+ private Graphics? _graphics;
+ private DeviceContext? _dc;
/// <summary>
/// Implements StartPrint for generating print preview information.
// We need a DC as a reference; we don't actually draw on it.
// We make sure to reuse the same one to improve performance.
- _dc = document.PrinterSettings.CreateInformationContext(_modeHandle);
+ _dc = document.PrinterSettings.CreateInformationContext(_modeHandle!);
}
/// <summary>
if (e.CopySettingsToDevMode)
{
- e.PageSettings.CopyToHdevmode(_modeHandle);
+ e.PageSettings.CopyToHdevmode(_modeHandle!);
}
Size size = e.PageBounds.Size;
// is sufficiently large and has more than 254 colors.
// This code path can easily be avoided by requesting
// an EmfPlusOnly EMF..
- Metafile metafile = new Metafile(_dc.Hdc, new Rectangle(0, 0, metafileSize.Width, metafileSize.Height), MetafileFrameUnit.GdiCompatible, EmfType.EmfPlusOnly);
+ Metafile metafile = new Metafile(_dc!.Hdc, new Rectangle(0, 0, metafileSize.Width, metafileSize.Height), MetafileFrameUnit.GdiCompatible, EmfType.EmfPlusOnly);
PreviewPageInfo info = new PreviewPageInfo(metafile, size);
_list.Add(info);
PrintPreviewGraphics printGraphics = new PrintPreviewGraphics(document, e);
_graphics = Graphics.FromImage(metafile);
- if (_graphics != null && document.OriginAtMargins)
+ if (document.OriginAtMargins)
{
// Adjust the origin of the graphics object to be at the
// user-specified margin location
}
}
- private protected SafeDeviceModeHandle _modeHandle = null;
+ private protected SafeDeviceModeHandle? _modeHandle = null;
/// <remarks>
/// If you have nested PrintControllers, this method won't get called on the inner one.
}
PrintPageEventArgs pageEvent = CreatePrintPageEvent(queryEvent.PageSettings);
- Graphics graphics = OnStartPage(document, pageEvent);
+ Graphics? graphics = OnStartPage(document, pageEvent);
pageEvent.SetGraphics(graphics);
try
private bool PrintLoopOptimized(PrintDocument document)
{
- PrintPageEventArgs pageEvent = null;
+ PrintPageEventArgs? pageEvent = null;
PageSettings documentPageSettings = (PageSettings)document.DefaultPageSettings.Clone();
QueryPageSettingsEventArgs queryEvent = new QueryPageSettingsEventArgs(documentPageSettings);
while (true)
pageEvent.CopySettingsToDevMode = false;
}
- Graphics graphics = OnStartPage(document, pageEvent);
+ Graphics? graphics = OnStartPage(document, pageEvent);
pageEvent.SetGraphics(graphics);
}
else
{
// Page settings were customized, so use the customized ones in the start page event.
pageEvent = CreatePrintPageEvent(queryEvent.PageSettings);
- Graphics graphics = OnStartPage(document, pageEvent);
+ Graphics? graphics = OnStartPage(document, pageEvent);
pageEvent.SetGraphics(graphics);
}
}
finally
{
- pageEvent.Graphics.Dispose();
+ pageEvent.Graphics!.Dispose();
pageEvent.SetGraphics(null);
}
/// <summary>
/// When overridden in a derived class, begins the control sequence of when and how to print a page in a document.
/// </summary>
- public virtual Graphics OnStartPage(PrintDocument document, PrintPageEventArgs e)
+ public virtual Graphics? OnStartPage(PrintDocument document, PrintPageEventArgs e)
{
return null;
}
if (printArgs.Cancel)
return;
- Graphics g = null;
+ Graphics? g = null;
if (printArgs.GraphicsContext != null)
{
do
{
QueryPageSettingsEventArgs queryPageSettingsArgs = new QueryPageSettingsEventArgs(
- DefaultPageSettings.Clone() as PageSettings);
+ (DefaultPageSettings.Clone() as PageSettings)!);
OnQueryPageSettings(queryPageSettingsArgs);
PageSettings pageSettings = queryPageSettingsArgs.PageSettings;
// size, orientation, etc. We use a single graphic for now to keep Cairo using a single PDF file.
printPageArgs.GraphicsContext = printArgs.GraphicsContext;
- Graphics pg = PrintController.OnStartPage(this, printPageArgs);
+ Graphics? pg = PrintController.OnStartPage(this, printPageArgs);
// assign Graphics in printPageArgs
printPageArgs.SetGraphics(pg);
}
[SRDescription("Raised when printing begins")]
- public event PrintEventHandler BeginPrint;
+ public event PrintEventHandler? BeginPrint;
[SRDescription("Raised when printing ends")]
- public event PrintEventHandler EndPrint;
+ public event PrintEventHandler? EndPrint;
[SRDescription("Raised when printing of a new page begins")]
- public event PrintPageEventHandler PrintPage;
+ public event PrintPageEventHandler? PrintPage;
[SRDescription("Raised before printing of a new page begins")]
- public event QueryPageSettingsEventHandler QueryPageSettings;
+ public event QueryPageSettingsEventHandler? QueryPageSettings;
}
}
{
private string _documentName = "document";
- private PrintEventHandler _beginPrintHandler;
- private PrintEventHandler _endPrintHandler;
- private PrintPageEventHandler _printPageHandler;
- private QueryPageSettingsEventHandler _queryHandler;
+ private PrintEventHandler? _beginPrintHandler;
+ private PrintEventHandler? _endPrintHandler;
+ private PrintPageEventHandler? _printPageHandler;
+ private QueryPageSettingsEventHandler? _queryHandler;
private PrinterSettings _printerSettings = new PrinterSettings();
private PageSettings _defaultPageSettings;
- private PrintController _printController;
+ private PrintController? _printController;
private bool _originAtMargins;
private bool _userSetPageSettings;
/// </summary>
public class PrintEventArgs : System.ComponentModel.CancelEventArgs
{
- private GraphicsPrinter graphics_context;
+ private GraphicsPrinter? graphics_context;
private PrintAction action;
public PrintEventArgs()
get { return action; }
}
- internal GraphicsPrinter GraphicsContext
+ internal GraphicsPrinter? GraphicsContext
{
get { return graphics_context; }
set { graphics_context = value; }
public class PrintPageEventArgs : EventArgs
{
private bool cancel;
- private Graphics graphics;
+ private Graphics? graphics;
private bool hasmorePages;
private Rectangle marginBounds;
private Rectangle pageBounds;
private PageSettings pageSettings;
- private GraphicsPrinter graphics_context;
+ private GraphicsPrinter? graphics_context;
- public PrintPageEventArgs(Graphics graphics, Rectangle marginBounds,
+ public PrintPageEventArgs(Graphics? graphics, Rectangle marginBounds,
Rectangle pageBounds, PageSettings pageSettings)
{
this.graphics = graphics;
cancel = value;
}
}
- public Graphics Graphics
+ public Graphics? Graphics
{
get
{
}
// used in PrintDocument.Print()
- internal void SetGraphics(Graphics g)
+ internal void SetGraphics(Graphics? g)
{
graphics = g;
}
- internal GraphicsPrinter GraphicsContext
+ internal GraphicsPrinter? GraphicsContext
{
get { return graphics_context; }
set { graphics_context = value; }
private bool _hasMorePages;
private bool _cancel;
- private Graphics _graphics;
+ private Graphics? _graphics;
private readonly Rectangle _marginBounds;
private readonly Rectangle _pageBounds;
private readonly PageSettings _pageSettings;
/// <summary>
/// Initializes a new instance of the <see cref='PrintPageEventArgs'/> class.
/// </summary>
- public PrintPageEventArgs(Graphics graphics, Rectangle marginBounds, Rectangle pageBounds, PageSettings pageSettings)
+ public PrintPageEventArgs(Graphics? graphics, Rectangle marginBounds, Rectangle pageBounds, PageSettings pageSettings)
{
_graphics = graphics; // may be null, see PrintController
_marginBounds = marginBounds;
/// <summary>
/// Gets the <see cref='System.Drawing.Graphics'/> used to paint the item.
/// </summary>
- public Graphics Graphics
+ public Graphics? Graphics
{
get
{
/// </summary>
internal void Dispose()
{
- _graphics.Dispose();
+ _graphics!.Dispose();
}
- internal void SetGraphics(Graphics value)
+ internal void SetGraphics(Graphics? value)
{
_graphics = value;
}
public class PrinterSettings : ICloneable
{
private string printer_name;
- private string print_filename;
+ private string? print_filename;
private short copies;
private int maximum_page;
private int minimum_page;
internal bool supports_color;
internal int landscape_angle;
private bool print_tofile;
- internal PrinterSettings.PrinterResolutionCollection printer_resolutions;
- internal PrinterSettings.PaperSizeCollection paper_sizes;
- internal PrinterSettings.PaperSourceCollection paper_sources;
- private PageSettings default_pagesettings;
+ internal PrinterSettings.PrinterResolutionCollection? printer_resolutions;
+ internal PrinterSettings.PaperSizeCollection? paper_sizes;
+ internal PrinterSettings.PaperSourceCollection? paper_sources;
+ private PageSettings? default_pagesettings;
private Duplex duplex;
internal bool is_plotter;
- internal NameValueCollection printer_capabilities; // this stores a list of all the printer options. Used only in cups, but might come in handy on win too.
+ internal NameValueCollection? printer_capabilities; // this stores a list of all the printer options. Used only in cups, but might come in handy on win too.
public PrinterSettings()
{
}
}
- public PrinterSettings.PaperSizeCollection PaperSizes
+ public PrinterSettings.PaperSizeCollection? PaperSizes
{
get
{
}
}
- public PrinterSettings.PaperSourceCollection PaperSources
+ public PrinterSettings.PaperSourceCollection? PaperSources
{
get
{
return paper_sources;
}
}
- public
- string PrintFileName
+ public string? PrintFileName
{
get { return print_filename; }
set { print_filename = value; }
bool ICollection.IsSynchronized { get { return false; } }
object ICollection.SyncRoot { get { return this; } }
[EditorBrowsable(EditorBrowsableState.Never)]
- public int Add(PaperSource paperSource) { return _PaperSources.Add(paperSource); }
+ public int Add(PaperSource? paperSource) { return _PaperSources.Add(paperSource); }
public void CopyTo(PaperSource[] paperSources, int index) { throw new NotImplementedException(); }
- public virtual PaperSource this[int index]
+ public virtual PaperSource? this[int index]
{
get { return _PaperSources[index] as PaperSource; }
}
bool ICollection.IsSynchronized { get { return false; } }
object ICollection.SyncRoot { get { return this; } }
[EditorBrowsable(EditorBrowsableState.Never)]
- public int Add(PaperSize paperSize) { return _PaperSizes.Add(paperSize); }
+ public int Add(PaperSize? paperSize) { return _PaperSizes.Add(paperSize); }
public void CopyTo(PaperSize[] paperSizes, int index) { throw new NotImplementedException(); }
- public virtual PaperSize this[int index]
+ public virtual PaperSize? this[int index]
{
get { return _PaperSizes[index] as PaperSize; }
}
bool ICollection.IsSynchronized { get { return false; } }
object ICollection.SyncRoot { get { return this; } }
[EditorBrowsable(EditorBrowsableState.Never)]
- public int Add(PrinterResolution printerResolution) { return _PrinterResolutions.Add(printerResolution); }
+ public int Add(PrinterResolution? printerResolution) { return _PrinterResolutions.Add(printerResolution); }
public void CopyTo(PrinterResolution[] printerResolutions, int index) { throw new NotImplementedException(); }
- public virtual PrinterResolution this[int index]
+ public virtual PrinterResolution? this[int index]
{
get { return _PrinterResolutions[index] as PrinterResolution; }
}
public virtual string this[int index]
{
- get { return _Strings[index] as string; }
+ get { return (_Strings[index] as string)!; }
}
[EditorBrowsable(EditorBrowsableState.Never)]
public int Add(string value) { return _Strings.Add(value); }
// Also, all properties have hidden tri-state logic -- yes/no/default
private const int Padding64Bit = 4;
- private string _printerName; // default printer.
+ private string? _printerName; // default printer.
private string _driverName = "";
private string _outputPort = "";
private bool _printToFile;
private bool _printDialogDisplayed;
private short _extrabytes;
- private byte[] _extrainfo;
+ private byte[]? _extrainfo;
private short _copies = -1;
private Duplex _duplex = System.Drawing.Printing.Duplex.Default;
private PrintRange _printRange;
private short _devmodebytes;
- private byte[] _cachedDevmode;
+ private byte[]? _cachedDevmode;
/// <summary>
/// Initializes a new instance of the <see cref='PrinterSettings'/> class.
// The printer name is at offset 0
//
IntPtr namePointer = (IntPtr)Marshal.ReadIntPtr((IntPtr)(checked((long)buffer + i * sizeofstruct)));
- array[i] = Marshal.PtrToStringAuto(namePointer);
+ array[i] = Marshal.PtrToStringAuto(namePointer)!;
}
Marshal.FreeCoTaskMem(buffer);
internal DeviceContext CreateDeviceContext(PageSettings pageSettings)
{
IntPtr modeHandle = GetHdevmodeInternal();
- DeviceContext dc = null;
+ DeviceContext? dc = null;
try
{
internal DeviceContext CreateDeviceContext(IntPtr hdevmode)
{
IntPtr modePointer = Interop.Kernel32.GlobalLock(hdevmode);
- DeviceContext dc = DeviceContext.CreateDC(DriverName, PrinterNameInternal, (string)null, modePointer);
+ DeviceContext dc = DeviceContext.CreateDC(DriverName, PrinterNameInternal, fileName:null, modePointer); ;
Interop.Kernel32.GlobalUnlock(hdevmode);
return dc;
}
internal DeviceContext CreateInformationContext(IntPtr hdevmode)
{
IntPtr modePointer = Interop.Kernel32.GlobalLock(hdevmode);
- DeviceContext dc = DeviceContext.CreateIC(DriverName, PrinterNameInternal, (string)null, modePointer);
+ DeviceContext dc = DeviceContext.CreateIC(DriverName, PrinterNameInternal, fileName:null, modePointer);
Interop.Kernel32.GlobalUnlock(hdevmode);
return dc;
}
public Graphics CreateMeasurementGraphics(bool honorOriginAtMargins)
{
Graphics g = CreateMeasurementGraphics();
- if (g != null && honorOriginAtMargins)
+ if (honorOriginAtMargins)
{
g.TranslateTransform(-_defaultPageSettings.HardMarginX, -_defaultPageSettings.HardMarginY);
g.TranslateTransform(_defaultPageSettings.Margins.Left, _defaultPageSettings.Margins.Top);
public Graphics CreateMeasurementGraphics(PageSettings pageSettings, bool honorOriginAtMargins)
{
Graphics g = CreateMeasurementGraphics();
- if (g != null && honorOriginAtMargins)
+ if (honorOriginAtMargins)
{
g.TranslateTransform(-pageSettings.HardMarginX, -pageSettings.HardMarginY);
g.TranslateTransform(pageSettings.Margins.Left, pageSettings.Margins.Top);
}
}
- SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE)Marshal.PtrToStructure(pointer, typeof(SafeNativeMethods.DEVMODE));
+ SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE)Marshal.PtrToStructure(pointer, typeof(SafeNativeMethods.DEVMODE))!;
if (_extrainfo != null)
}
IntPtr modePointer = Interop.Kernel32.GlobalLock(new HandleRef(this, modeHandle));
- SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE)Marshal.PtrToStructure(modePointer, typeof(SafeNativeMethods.DEVMODE));
+ SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE)Marshal.PtrToStructure(modePointer, typeof(SafeNativeMethods.DEVMODE))!;
switch (field)
{
case ModeField.Orientation:
PaperSize[] result = new PaperSize[count];
for (int i = 0; i < count; i++)
{
- string name = Marshal.PtrToStringAuto((IntPtr)(checked((long)namesBuffer + stringSize * i)), 64);
+ string name = Marshal.PtrToStringAuto((IntPtr)(checked((long)namesBuffer + stringSize * i)), 64)!;
int index = name.IndexOf('\0');
if (index > -1)
{
PaperSource[] result = new PaperSource[count];
for (int i = 0; i < count; i++)
{
- string name = Marshal.PtrToStringAuto((IntPtr)(checked((long)namesBuffer + stringSize * i)), 24);
+ string name = Marshal.PtrToStringAuto((IntPtr)(checked((long)namesBuffer + stringSize * i)), 24)!;
int index = name.IndexOf('\0');
if (index > -1)
{
private static string ReadOneDEVNAME(IntPtr pDevnames, int slot)
{
int offset = checked(Marshal.SystemDefaultCharSize * Marshal.ReadInt16((IntPtr)(checked((long)pDevnames + slot * 2))));
- string result = Marshal.PtrToStringAuto((IntPtr)(checked((long)pDevnames + offset)));
+ string result = Marshal.PtrToStringAuto((IntPtr)(checked((long)pDevnames + offset)))!;
return result;
}
throw new ArgumentException(SR.Format(SR.InvalidPrinterHandle, hdevmode));
IntPtr pointer = Interop.Kernel32.GlobalLock(hdevmode);
- SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE)Marshal.PtrToStructure(pointer, typeof(SafeNativeMethods.DEVMODE));
+ SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE)Marshal.PtrToStructure(pointer, typeof(SafeNativeMethods.DEVMODE))!;
//Copy entire public devmode as a byte array...
_devmodebytes = mode.dmSize;
private readonly object[] _array;
private readonly int _endIndex;
private int _index;
- private object _item;
+ private object? _item;
public ArrayEnumerator(object[] array, int count)
{
_endIndex = count;
}
- public object Current => _item;
+ public object? Current => _item;
public bool MoveNext()
{
private static readonly bool s_cupsInitialized = CheckCupsInstalled();
private static readonly Hashtable s_docInfo = Hashtable.Synchronized(new Hashtable());
- private static Tuple<string, Dictionary<string, SysPrn.Printer>> s_printers; // cached default printer name and collection of all printers from cups
+ private static Tuple<string, Dictionary<string, SysPrn.Printer>>? s_printers; // cached default printer name and collection of all printers from cups
#endregion
try
{
IntPtr ptr = LibcupsNative.cupsGetPPD(printer);
- string ppd_filename = Marshal.PtrToStringAnsi(ptr);
+ string ppd_filename = Marshal.PtrToStringAnsi(ptr)!;
IntPtr ppd_handle = LibcupsNative.ppdOpenFile(ppd_filename);
return ppd_handle;
}
Dictionary<string, SysPrn.Printer> printers = EnsurePrintersInitialized().Item2;
- if (!printers.TryGetValue(printer, out SysPrn.Printer p))
+ if (!printers.TryGetValue(printer, out SysPrn.Printer? p))
return;
- PrinterSettings currentSettings = p.Settings;
+ PrinterSettings? currentSettings = p.Settings;
if (currentSettings != null)
{
settings.can_duplex = currentSettings.can_duplex;
for (int i = 0; i < ret; i++)
{
ptr_printer = (IntPtr)Marshal.ReadIntPtr(ptr);
- if (Marshal.PtrToStringAnsi(ptr_printer).Equals(printer))
+ if (Marshal.PtrToStringAnsi(ptr_printer)!.Equals(printer))
{
name = printer;
break;
if (ppd_handle == IntPtr.Zero)
return;
- printer_dest = (CUPS_DESTS)Marshal.PtrToStructure(ptr, typeof(CUPS_DESTS));
+ printer_dest = (CUPS_DESTS)Marshal.PtrToStructure(ptr, typeof(CUPS_DESTS))!;
options = new NameValueCollection();
paper_names = new NameValueCollection();
paper_sources = new NameValueCollection();
- string defsize;
- string defsource;
+ string? defsize;
+ string? defsource;
LoadPrinterOptions(printer_dest.options, printer_dest.num_options, ppd_handle, options,
paper_names, out defsize,
paper_sources, out defsource);
else
settings.paper_sources.Clear();
- settings.DefaultPageSettings.PaperSource = LoadPrinterPaperSources(settings, defsource, paper_sources);
+ settings.DefaultPageSettings.PaperSource = LoadPrinterPaperSources(settings, defsource, paper_sources)!;
settings.DefaultPageSettings.PaperSize = LoadPrinterPaperSizes(ppd_handle, settings, defsize, paper_names);
LoadPrinterResolutionsAndDefault(printer, settings, ppd_handle);
- ppd = (PPD_FILE)Marshal.PtrToStructure(ppd_handle, typeof(PPD_FILE));
+ ppd = (PPD_FILE)Marshal.PtrToStructure(ppd_handle, typeof(PPD_FILE))!;
settings.landscape_angle = ppd.landscape;
settings.supports_color = (ppd.color_device == 0) ? false : true;
settings.can_duplex = options["Duplex"] != null;
/// <param name="defsource">The default source tray, set by LoadOptionList</param>
private static void LoadPrinterOptions(IntPtr options, int numOptions, IntPtr ppd,
NameValueCollection list,
- NameValueCollection paper_names, out string defsize,
- NameValueCollection paper_sources, out string defsource)
+ NameValueCollection paper_names, out string? defsize,
+ NameValueCollection paper_sources, out string? defsource)
{
CUPS_OPTIONS cups_options;
- string option_name, option_value;
+ string? option_name, option_value;
int cups_size = Marshal.SizeOf(typeof(CUPS_OPTIONS));
LoadOptionList(ppd, "PageSize", paper_names, out defsize);
for (int j = 0; j < numOptions; j++)
{
- cups_options = (CUPS_OPTIONS)Marshal.PtrToStructure(options, typeof(CUPS_OPTIONS));
+ cups_options = (CUPS_OPTIONS)Marshal.PtrToStructure(options, typeof(CUPS_OPTIONS))!;
option_name = Marshal.PtrToStringAnsi(cups_options.name);
option_value = Marshal.PtrToStringAnsi(cups_options.val);
private static NameValueCollection LoadPrinterOptions(IntPtr options, int numOptions)
{
CUPS_OPTIONS cups_options;
- string option_name, option_value;
+ string? option_name, option_value;
int cups_size = Marshal.SizeOf(typeof(CUPS_OPTIONS));
NameValueCollection list = new NameValueCollection();
for (int j = 0; j < numOptions; j++)
{
- cups_options = (CUPS_OPTIONS)Marshal.PtrToStructure(options, typeof(CUPS_OPTIONS));
+ cups_options = (CUPS_OPTIONS)Marshal.PtrToStructure(options, typeof(CUPS_OPTIONS))!;
option_name = Marshal.PtrToStringAnsi(cups_options.name);
option_value = Marshal.PtrToStringAnsi(cups_options.val);
/// <param name="option_name">Name of the option group to load</param>
/// <param name="list">List of loaded options</param>
/// <param name="defoption">The default option from the loaded options list</param>
- private static void LoadOptionList(IntPtr ppd, string option_name, NameValueCollection list, out string defoption)
+ private static void LoadOptionList(IntPtr ppd, string option_name, NameValueCollection list, out string? defoption)
{
IntPtr ptr = IntPtr.Zero;
ptr = LibcupsNative.ppdFindOption(ppd, option_name);
if (ptr != IntPtr.Zero)
{
- ppd_option = (PPD_OPTION)Marshal.PtrToStructure(ptr, typeof(PPD_OPTION));
+ ppd_option = (PPD_OPTION)Marshal.PtrToStructure(ptr, typeof(PPD_OPTION))!;
#if PrintDebug
Console.WriteLine (" OPTION key:{0} def:{1} text: {2}", ppd_option.keyword, ppd_option.defchoice, ppd_option.text);
#endif
ptr = ppd_option.choices;
for (int c = 0; c < ppd_option.num_choices; c++)
{
- choice = (PPD_CHOICE)Marshal.PtrToStructure(ptr, typeof(PPD_CHOICE));
+ choice = (PPD_CHOICE)Marshal.PtrToStructure(ptr, typeof(PPD_CHOICE))!;
list.Add(choice.choice, choice.text);
#if PrintDebug
Console.WriteLine (" choice:{0} - text: {1}", choice.choice, choice.text);
/// Create a PrinterResolution from a string Resolution that is set in the PPD option.
/// An example of Resolution is "600x600dpi" or "600dpi". Returns null if malformed or "Unknown".
/// </summary>
- private static PrinterResolution ParseResolution(string resolution)
+ private static PrinterResolution? ParseResolution(string? resolution)
{
if (string.IsNullOrEmpty(resolution))
return null;
/// <param name="def_size">Default paper size, from the global options of the printer</param>
/// <param name="paper_names">List of available paper sizes that gets filled</param>
private static PaperSize LoadPrinterPaperSizes(IntPtr ppd_handle, PrinterSettings settings,
- string def_size, NameValueCollection paper_names)
+ string? def_size, NameValueCollection paper_names)
{
IntPtr ptr;
string real_name;
PaperSize ps;
PaperSize defsize = new PaperSize(GetPaperKind(827, 1169), "A4", 827, 1169);
- ppd = (PPD_FILE)Marshal.PtrToStructure(ppd_handle, typeof(PPD_FILE));
+ ppd = (PPD_FILE)Marshal.PtrToStructure(ppd_handle, typeof(PPD_FILE))!;
ptr = ppd.sizes;
float w, h;
for (int i = 0; i < ppd.num_sizes; i++)
{
- size = (PPD_SIZE)Marshal.PtrToStructure(ptr, typeof(PPD_SIZE));
- real_name = paper_names[size.name];
+ size = (PPD_SIZE)Marshal.PtrToStructure(ptr, typeof(PPD_SIZE))!;
+ real_name = paper_names[size.name]!;
w = size.width * 100 / 72;
h = size.length * 100 / 72;
PaperKind kind = GetPaperKind((int)w, (int)h);
ps.RawKind = (int)kind;
if (def_size == ps.Kind.ToString())
defsize = ps;
- settings.paper_sizes.Add(ps);
+ settings.paper_sizes!.Add(ps);
ptr = (IntPtr)((long)ptr + Marshal.SizeOf(size));
}
/// <param name="settings">PrinterSettings object to fill</param>
/// <param name="def_source">Default paper source, from the global options of the printer</param>
/// <param name="paper_sources">List of available paper sizes that gets filled</param>
- private static PaperSource LoadPrinterPaperSources(PrinterSettings settings, string def_source,
+ private static PaperSource? LoadPrinterPaperSources(PrinterSettings settings, string? def_source,
NameValueCollection paper_sources)
{
PaperSourceKind kind;
- PaperSource defsource = null;
- foreach (string source in paper_sources)
+ PaperSource? defsource = null;
+ foreach (string? source in paper_sources)
{
switch (source)
{
kind = PaperSourceKind.Custom;
break;
}
- settings.paper_sources.Add(new PaperSource(kind, paper_sources[source]));
+ settings.paper_sources!.Add(new PaperSource(kind, paper_sources[source]!));
if (def_source == source)
defsource = settings.paper_sources[settings.paper_sources.Count - 1];
}
- if (defsource == null && settings.paper_sources.Count > 0)
+ if (defsource == null && settings.paper_sources!.Count > 0)
return settings.paper_sources[0];
return defsource;
}
settings.printer_resolutions.Clear();
var printer_resolutions = new NameValueCollection();
- string defresolution;
+ string? defresolution;
LoadOptionList(ppd_handle, "Resolution", printer_resolutions, out defresolution);
foreach (var resolution in printer_resolutions.Keys)
{
- var new_resolution = ParseResolution(resolution.ToString());
+ var new_resolution = ParseResolution(resolution!.ToString());
settings.PrinterResolutions.Add(new_resolution);
}
var default_resolution = ParseResolution(defresolution);
if (default_resolution == null)
- default_resolution = ParseResolution("300dpi");
+ default_resolution = ParseResolution("300dpi")!;
if (printer_resolutions.Count == 0)
settings.PrinterResolutions.Add(default_resolution);
IntPtr ptr_printers = dests;
for (int i = 0; i < n_printers; i++)
{
- var printer = (CUPS_DESTS)Marshal.PtrToStructure(ptr_printers, typeof(CUPS_DESTS));
- string name = Marshal.PtrToStringAnsi(printer.name);
+ var printer = (CUPS_DESTS)Marshal.PtrToStructure(ptr_printers, typeof(CUPS_DESTS))!;
+ string name = Marshal.PtrToStringAnsi(printer.name)!;
if (printer.is_default == 1 ||
string.IsNullOrEmpty(defaultPrinterName))
for (int i = 0; i < count; i++)
{
ptr_printer = (IntPtr)Marshal.ReadIntPtr(ptr_printers);
- if (Marshal.PtrToStringAnsi(ptr_printer).Equals(printer))
+ if (Marshal.PtrToStringAnsi(ptr_printer)!.Equals(printer))
{
found = true;
break;
if (!found)
return;
- cups_dests = (CUPS_DESTS)Marshal.PtrToStructure(ptr_printers, typeof(CUPS_DESTS));
+ cups_dests = (CUPS_DESTS)Marshal.PtrToStructure(ptr_printers, typeof(CUPS_DESTS))!;
NameValueCollection options = LoadPrinterOptions(cups_dests.options, cups_dests.num_options);
if (options["printer-state"] != null)
- state = int.Parse(options["printer-state"]);
+ // TODO-NULLABLE dotnet/roslyn#34644
+ state = int.Parse(options["printer-state"]!);
if (options["printer-comment"] != null)
- comment = options["printer-state"];
+ // TODO-NULLABLE dotnet/roslyn#34644
+ comment = options["printer-state"]!;
switch (state)
{
#region Print job methods
- private static string tmpfile;
+ private static string? tmpfile;
/// <summary>
/// Gets a pointer to an options list parsed from the printer's current settings, to use when setting up the printing job
internal static bool StartDoc(GraphicsPrinter gr, string doc_name, string output_file)
{
- DOCINFO doc = (DOCINFO)s_docInfo[gr.Hdc];
+ DOCINFO doc = (DOCINFO)s_docInfo[gr.Hdc]!;
doc.title = doc_name;
return true;
}
internal static bool EndDoc(GraphicsPrinter gr)
{
- DOCINFO doc = (DOCINFO)s_docInfo[gr.Hdc];
+ DOCINFO doc = (DOCINFO)s_docInfo[gr.Hdc]!;
- gr.Graphics.Dispose(); // Dispose object to force surface finish
+ gr.Graphics!.Dispose(); // Dispose object to force surface finish
IntPtr options;
int options_count = GetCupsOptions(doc.settings, doc.default_page_settings, out options);
internal static IntPtr CreateGraphicsContext(PrinterSettings settings, PageSettings default_page_settings)
{
IntPtr graphics = IntPtr.Zero;
- string name;
+ string? name;
if (!settings.PrintToFile)
{
StringBuilder sb = new StringBuilder(1024);
tmpfile = name;
}
else
- name = settings.PrintFileName;
+ name = settings.PrintFileName!;
PaperSize psize = default_page_settings.PaperSize;
int width, height;
public readonly string Port;
public readonly string Type;
public readonly string Status;
- public PrinterSettings Settings;
+ public PrinterSettings? Settings;
public Printer(string port, string type, string status, string comment)
{
internal class GraphicsPrinter
{
- private Graphics graphics;
+ private Graphics? graphics;
private IntPtr hDC;
- internal GraphicsPrinter(Graphics gr, IntPtr dc)
+ internal GraphicsPrinter(Graphics? gr, IntPtr dc)
{
graphics = gr;
hDC = dc;
}
- internal Graphics Graphics
+ internal Graphics? Graphics
{
get { return graphics; }
set { graphics = value; }
public override void OnEndPage(PrintDocument document, PrintPageEventArgs e)
{
- PrintingServices.EndPage(e.GraphicsContext);
+ PrintingServices.EndPage(e.GraphicsContext!);
}
public override void OnStartPrint(PrintDocument document, PrintEventArgs e)
public override void OnEndPrint(PrintDocument document, PrintEventArgs e)
{
- PrintingServices.EndDoc(e.GraphicsContext);
+ PrintingServices.EndDoc(e.GraphicsContext!);
}
- public override Graphics OnStartPage(PrintDocument document, PrintPageEventArgs e)
+ public override Graphics? OnStartPage(PrintDocument document, PrintPageEventArgs e)
{
- PrintingServices.StartPage(e.GraphicsContext);
+ PrintingServices.StartPage(e.GraphicsContext!);
return e.Graphics;
}
}
return !(left == right);
}
- public override bool Equals(object o)
+ public override bool Equals(object? o)
{
- TriState state = (TriState)o;
+ TriState state = (TriState)o!;
return _value == state._value;
}
propItemInternal.len = 0;
propItemInternal.type = propItem.Type;
- byte[] propItemValue = propItem.Value;
+ byte[]? propItemValue = propItem.Value;
if (propItemValue != null)
{
int length = propItemValue.Length;
for (int i = 0; i < count; i++)
{
- PropertyItemInternal propcopy = null;
+ PropertyItemInternal? propcopy = null;
try
{
propcopy = (PropertyItemInternal)Marshal.PtrToStructure(propdata,
- typeof(PropertyItemInternal));
+ typeof(PropertyItemInternal))!;
props[i] = new PropertyItem();
props[i].Id = propcopy.id;
return props;
}
- public byte[] Value
+ public byte[]? Value
{
get
{
return isEqual != 0;
}
- public RegionData GetRegionData()
+ public RegionData? GetRegionData()
{
Gdip.CheckStatus(Gdip.GdipGetRegionDataSize(new HandleRef(this, NativeRegion), out int regionSize));
public bool IsVisible(PointF point) => IsVisible(point, null);
- public bool IsVisible(float x, float y, Graphics g) => IsVisible(new PointF(x, y), g);
+ public bool IsVisible(float x, float y, Graphics? g) => IsVisible(new PointF(x, y), g);
- public bool IsVisible(PointF point, Graphics g)
+ public bool IsVisible(PointF point, Graphics? g)
{
Gdip.CheckStatus(Gdip.GdipIsVisibleRegionPoint(
new HandleRef(this, NativeRegion),
public bool IsVisible(RectangleF rect) => IsVisible(rect, null);
- public bool IsVisible(float x, float y, float width, float height, Graphics g) => IsVisible(new RectangleF(x, y, width, height), g);
+ public bool IsVisible(float x, float y, float width, float height, Graphics? g) => IsVisible(new RectangleF(x, y, width, height), g);
- public bool IsVisible(RectangleF rect, Graphics g)
+ public bool IsVisible(RectangleF rect, Graphics? g)
{
Gdip.CheckStatus(Gdip.GdipIsVisibleRegionRect(
new HandleRef(this, NativeRegion),
return isVisible != 0;
}
- public bool IsVisible(int x, int y, Graphics g) => IsVisible(new Point(x, y), g);
+ public bool IsVisible(int x, int y, Graphics? g) => IsVisible(new Point(x, y), g);
public bool IsVisible(Point point) => IsVisible(point, null);
- public bool IsVisible(Point point, Graphics g)
+ public bool IsVisible(Point point, Graphics? g)
{
Gdip.CheckStatus(Gdip.GdipIsVisibleRegionPointI(
new HandleRef(this, NativeRegion),
public bool IsVisible(Rectangle rect) => IsVisible(rect, null);
- public bool IsVisible(int x, int y, int width, int height, Graphics g) => IsVisible(new Rectangle(x, y, width, height), g);
+ public bool IsVisible(int x, int y, int width, int height, Graphics? g) => IsVisible(new Rectangle(x, y, width, height), g);
- public bool IsVisible(Rectangle rect, Graphics g)
+ public bool IsVisible(Rectangle rect, Graphics? g)
{
Gdip.CheckStatus(Gdip.GdipIsVisibleRegionRectI(
new HandleRef(this, NativeRegion),
throw new ArgumentException(SR.Format(SR.ColorNotSystemColor, c.ToString()));
}
- Brush[] systemBrushes = (Brush[])Gdip.ThreadData[s_systemBrushesKey];
+ Brush[]? systemBrushes = (Brush[]?)Gdip.ThreadData[s_systemBrushesKey];
if (systemBrushes == null)
{
systemBrushes = new Brush[(int)KnownColor.WindowText + (int)KnownColor.MenuHighlight - (int)KnownColor.YellowGreen];
}
}
- public static Font CaptionFont
+ public static Font? CaptionFont
{
get
{
- Font captionFont = null;
+ Font? captionFont = null;
if (GetNonClientMetrics(out Interop.User32.NONCLIENTMETRICS metrics))
{
}
}
- public static Font SmallCaptionFont
+ public static Font? SmallCaptionFont
{
get
{
- Font smcaptionFont = null;
+ Font? smcaptionFont = null;
if (GetNonClientMetrics(out Interop.User32.NONCLIENTMETRICS metrics))
{
}
}
- public static Font MenuFont
+ public static Font? MenuFont
{
get
{
- Font menuFont = null;
+ Font? menuFont = null;
if (GetNonClientMetrics(out Interop.User32.NONCLIENTMETRICS metrics))
{
}
}
- public static Font StatusFont
+ public static Font? StatusFont
{
get
{
- Font statusFont = null;
+ Font? statusFont = null;
if (GetNonClientMetrics(out Interop.User32.NONCLIENTMETRICS metrics))
{
}
}
- public static Font MessageBoxFont
+ public static Font? MessageBoxFont
{
get
{
- Font messageBoxFont = null;
+ Font? messageBoxFont = null;
if (GetNonClientMetrics(out Interop.User32.NONCLIENTMETRICS metrics))
{
ex is FileNotFoundException);
}
- public static unsafe Font IconTitleFont
+ public static unsafe Font? IconTitleFont
{
get
{
- Font iconTitleFont = null;
+ Font? iconTitleFont = null;
Interop.User32.LOGFONT itfont = default;
if (Interop.User32.SystemParametersInfoW(Interop.User32.SystemParametersAction.SPI_GETICONTITLELOGFONT, (uint)sizeof(Interop.User32.LOGFONT), &itfont, 0))
{
get
{
- Font defaultFont = null;
+ Font? defaultFont = null;
// For Arabic systems, always return Tahoma 8.
if ((ushort)UnsafeNativeMethods.GetSystemDefaultLCID() == 0x0001)
{
get
{
- Font dialogFont = null;
+ Font? dialogFont = null;
if ((ushort)UnsafeNativeMethods.GetSystemDefaultLCID() == 0x0011)
{
// For Japanese cultures, SystemFonts.DefaultFont returns a new Font object every time it is invoked.
// So for Japanese we return the DefaultFont with its SystemFontName set to DialogFont.
- dialogFont.SetSystemFontName(nameof(DialogFont));
+ dialogFont!.SetSystemFontName(nameof(DialogFont));
return dialogFont;
}
}
private static Font GetFontFromData(Interop.User32.LOGFONT logFont)
{
- Font font = null;
+ Font? font = null;
try
{
font = Font.FromLogFont(ref logFont);
{
public static partial class SystemFonts
{
- public static Font GetFontByName(string systemFontName)
+ public static Font? GetFontByName(string systemFontName)
{
if (nameof(CaptionFont).Equals(systemFontName))
{
{
public static class SystemIcons
{
- private static Icon s_application = null;
- private static Icon s_asterisk = null;
- private static Icon s_error = null;
- private static Icon s_exclamation = null;
- private static Icon s_hand = null;
- private static Icon s_information = null;
- private static Icon s_question = null;
- private static Icon s_warning = null;
- private static Icon s_winlogo = null;
- private static Icon s_shield = null;
+ private static Icon? s_application = null;
+ private static Icon? s_asterisk = null;
+ private static Icon? s_error = null;
+ private static Icon? s_exclamation = null;
+ private static Icon? s_hand = null;
+ private static Icon? s_information = null;
+ private static Icon? s_question = null;
+ private static Icon? s_warning = null;
+ private static Icon? s_winlogo = null;
+ private static Icon? s_shield = null;
public static Icon Application => GetIcon(ref s_application, SafeNativeMethods.IDI_APPLICATION);
}
}
- private static Icon GetIcon(ref Icon icon, int iconId)
+ private static Icon GetIcon(ref Icon? icon, int iconId)
{
return icon ?? (icon = new Icon(SafeNativeMethods.LoadIcon(NativeMethods.NullHandleRef, (IntPtr)iconId)));
}
throw new ArgumentException(SR.Format(SR.ColorNotSystemColor, c.ToString()));
}
- Pen[] systemPens = (Pen[])Gdip.ThreadData[s_systemPensKey];
+ Pen[]? systemPens = (Pen[]?)Gdip.ThreadData[s_systemPensKey];
if (systemPens == null)
{
systemPens = new Pen[(int)KnownColor.WindowText + (int)KnownColor.MenuHighlight - (int)KnownColor.YellowGreen];
public TextureBrush(Image image, RectangleF dstRect) : this(image, dstRect, null) { }
- public TextureBrush(Image image, RectangleF dstRect, ImageAttributes imageAttr)
+ public TextureBrush(Image image, RectangleF dstRect, ImageAttributes? imageAttr)
{
if (image == null)
{
public TextureBrush(Image image, Rectangle dstRect) : this(image, dstRect, null) { }
- public TextureBrush(Image image, Rectangle dstRect, ImageAttributes imageAttr)
+ public TextureBrush(Image image, Rectangle dstRect, ImageAttributes? imageAttr)
{
if (image == null)
{
[AttributeUsage(AttributeTargets.Class)]
public class ToolboxBitmapAttribute : Attribute
{
- private Image smallImage = null;
- private Image bigImage = null;
+ private Image? smallImage = null;
+ private Image? bigImage = null;
public static readonly ToolboxBitmapAttribute Default = new ToolboxBitmapAttribute();
private ToolboxBitmapAttribute()
smallImage = GetImageFromResource(t, name, false);
}
- public override bool Equals(object value)
+ public override bool Equals(object? value)
{
if (!(value is ToolboxBitmapAttribute))
return false;
public override int GetHashCode()
{
- return (smallImage.GetHashCode() ^ bigImage.GetHashCode());
+ return (smallImage!.GetHashCode() ^ bigImage!.GetHashCode());
}
- public Image GetImage(object component)
+ public Image? GetImage(object component)
{
return GetImage(component.GetType(), null, false);
}
- public Image GetImage(object component, bool large)
+ public Image? GetImage(object component, bool large)
{
return GetImage(component.GetType(), null, large);
}
- public Image GetImage(Type type)
+ public Image? GetImage(Type type)
{
return GetImage(type, null, false);
}
- public Image GetImage(Type type, bool large)
+ public Image? GetImage(Type type, bool large)
{
return GetImage(type, null, large);
}
- public Image GetImage(Type type, string imgName, bool large)
+ public Image? GetImage(Type type, string? imgName, bool large)
{
if (smallImage == null)
smallImage = GetImageFromResource(type, imgName, false);
if (large)
{
if (bigImage == null)
- bigImage = new Bitmap(smallImage, 32, 32);
+ bigImage = new Bitmap(smallImage!, 32, 32);
return bigImage;
}
else
return smallImage;
}
- public static Image GetImageFromResource(Type t, string imageName, bool large)
+ public static Image? GetImageFromResource(Type t, string? imageName, bool large)
{
Bitmap bitmap;
if (imageName == null)
try
{
- using (System.IO.Stream s = t.GetTypeInfo().Assembly.GetManifestResourceStream(t.Namespace + "." + imageName))
+ using (System.IO.Stream? s = t.GetTypeInfo().Assembly.GetManifestResourceStream(t.Namespace + "." + imageName))
{
if (s == null)
{
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.Drawing.Imaging;
using System.IO;
using DpiHelper = System.Windows.Forms.DpiHelper;
[AttributeUsage(AttributeTargets.Class)]
public class ToolboxBitmapAttribute : Attribute
{
- private Image _smallImage;
- private Image _largeImage;
+ private Image? _smallImage;
+ private Image? _largeImage;
- private readonly string _imageFile;
- private readonly Type _imageType;
+ private readonly string? _imageFile;
+ private readonly Type? _imageType;
- private readonly string _imageName;
+ private readonly string? _imageName;
private static readonly Size s_largeSize = new Size(32, 32);
private static readonly Size s_smallSize = new Size(16, 16);
// Used to help cache the last result of BitmapSelector.GetFileName.
- private static string s_lastOriginalFileName;
- private static string s_lastUpdatedFileName;
+ private static string? s_lastOriginalFileName;
+ private static string? s_lastUpdatedFileName;
public ToolboxBitmapAttribute(string imageFile) : this(GetImageFromFile(imageFile, false), GetImageFromFile(imageFile, true))
{
_imageName = name;
}
- private ToolboxBitmapAttribute(Image smallImage, Image largeImage)
+ private ToolboxBitmapAttribute(Image? smallImage, Image? largeImage)
{
_smallImage = smallImage;
_largeImage = largeImage;
}
- public override bool Equals(object value)
+ public override bool Equals(object? value)
{
if (value == this)
{
public override int GetHashCode() => base.GetHashCode();
- public Image GetImage(object component) => GetImage(component, true);
+ public Image? GetImage(object? component) => GetImage(component, true);
- public Image GetImage(object component, bool large)
+ public Image? GetImage(object? component, bool large)
{
if (component != null)
{
return null;
}
- public Image GetImage(Type type) => GetImage(type, false);
+ public Image? GetImage(Type type) => GetImage(type, false);
- public Image GetImage(Type type, bool large) => GetImage(type, null, large);
+ public Image? GetImage(Type type, bool large) => GetImage(type, null, large);
- public Image GetImage(Type type, string imgName, bool large)
+ public Image? GetImage(Type type, string? imgName, bool large)
{
if ((large && _largeImage == null) || (!large && _smallImage == null))
{
- Image img = null;
+ Image? img = null;
if (large)
{
img = _largeImage;
}
}
- Image toReturn = (large) ? _largeImage : _smallImage;
+ Image? toReturn = (large) ? _largeImage : _smallImage;
if (Equals(Default))
{
}
// Helper to get the right icon from the given stream that represents an icon.
- private static Image GetIconFromStream(Stream stream, bool large, bool scaled)
+ private static Image? GetIconFromStream(Stream? stream, bool large, bool scaled)
{
if (stream == null)
{
}
Icon ico = new Icon(stream);
Icon sizedico = new Icon(ico, large ? s_largeSize : s_smallSize);
- Bitmap b = sizedico.ToBitmap();
+ Bitmap? b = sizedico.ToBitmap();
if (DpiHelper.IsScalingRequired && scaled)
{
DpiHelper.ScaleBitmapLogicalToDevice(ref b);
// Cache the last result of BitmapSelector.GetFileName because we commonly load images twice
// in succession from the same file and we don't need to compute the name twice.
- private static string GetFileNameFromBitmapSelector(string originalName)
+ private static string? GetFileNameFromBitmapSelector(string originalName)
{
if (originalName != s_lastOriginalFileName)
{
}
// Just forwards to Image.FromFile eating any non-critical exceptions that may result.
- private static Image GetImageFromFile(string imageFile, bool large, bool scaled = true)
+ private static Image? GetImageFromFile(string? imageFile, bool large, bool scaled = true)
{
- Image image = null;
+ Image? image = null;
try
{
if (imageFile != null)
{
imageFile = GetFileNameFromBitmapSelector(imageFile);
- string ext = Path.GetExtension(imageFile);
+ string? ext = Path.GetExtension(imageFile);
if (ext != null && string.Equals(ext, ".ico", StringComparison.OrdinalIgnoreCase))
{
//ico files support both large and small, so we respect the large flag here.
- using (FileStream reader = File.OpenRead(imageFile))
+ using (FileStream reader = File.OpenRead(imageFile!))
{
image = GetIconFromStream(reader, large, scaled);
}
else if (!large)
{
//we only read small from non-ico files.
- image = Image.FromFile(imageFile);
- Bitmap b = image as Bitmap;
+ image = Image.FromFile(imageFile!);
+ Bitmap? b = image as Bitmap;
if (DpiHelper.IsScalingRequired && scaled)
{
DpiHelper.ScaleBitmapLogicalToDevice(ref b);
return image;
}
- private static Image GetBitmapFromResource(Type t, string bitmapname, bool large, bool scaled)
+ private static Image? GetBitmapFromResource(Type t, string? bitmapname, bool large, bool scaled)
{
if (bitmapname == null)
{
return null;
}
- Image img = null;
+ Image? img = null;
// Load the image from the manifest resources.
- Stream stream = BitmapSelector.GetResourceStream(t, bitmapname);
+ Stream? stream = BitmapSelector.GetResourceStream(t, bitmapname);
if (stream != null)
{
- Bitmap b = new Bitmap(stream);
+ Bitmap? b = new Bitmap(stream);
img = b;
MakeBackgroundAlphaZero(b);
if (large)
return img;
}
- private static Image GetIconFromResource(Type t, string bitmapname, bool large, bool scaled)
+ private static Image? GetIconFromResource(Type t, string? bitmapname, bool large, bool scaled)
{
if (bitmapname == null)
{
return GetIconFromStream(BitmapSelector.GetResourceStream(t, bitmapname), large, scaled);
}
- public static Image GetImageFromResource(Type t, string imageName, bool large)
+ public static Image? GetImageFromResource(Type t, string? imageName, bool large)
{
return GetImageFromResource(t, imageName, large, scaled: true);
}
- internal static Image GetImageFromResource(Type t, string imageName, bool large, bool scaled)
+ internal static Image? GetImageFromResource(Type t, string? imageName, bool large, bool scaled)
{
- Image img = null;
+ Image? img = null;
try
{
- string name = imageName;
- string iconname = null;
- string bmpname = null;
- string rawbmpname = null;
+ string? name = imageName;
+ string? iconname = null;
+ string? bmpname = null;
+ string? rawbmpname = null;
// If we didn't get a name, use the class name
if (name == null)
{
- name = t.FullName;
+ name = t.FullName!;
int indexDot = name.LastIndexOf('.');
if (indexDot != -1)
{
img.SetPixel(0, img.Height - 1, newBottomLeft);
}
- public static readonly ToolboxBitmapAttribute Default = new ToolboxBitmapAttribute(null, (Image)null);
+ public static readonly ToolboxBitmapAttribute Default = new ToolboxBitmapAttribute(null, (Image?)null);
private static readonly ToolboxBitmapAttribute s_defaultComponent;
// When we call Gdip.DummyFunction, JIT will make sure Gdip..cctor will be called.
Gdip.DummyFunction();
- Stream stream = BitmapSelector.GetResourceStream(typeof(ToolboxBitmapAttribute), "DefaultComponent.bmp");
+ Stream? stream = BitmapSelector.GetResourceStream(typeof(ToolboxBitmapAttribute), "DefaultComponent.bmp");
Debug.Assert(stream != null, "DefaultComponent.bmp must be present as an embedded resource.");
var bitmap = new Bitmap(stream);
{
internal static readonly Hashtable contextReference = new Hashtable();
internal static readonly object lockobj = new object();
- internal static readonly Delegate hwnd_delegate = GetHwndDelegate();
+ internal static readonly Delegate? hwnd_delegate = GetHwndDelegate();
#if DEBUG_CLIPPING
internal static float red = 1.0f;
internal static int debug_threshold = 1;
#endif
- private static Delegate GetHwndDelegate()
+ private static Delegate? GetHwndDelegate()
{
#if !NETSTANDARD1_6
foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
{
if (string.Equals(asm.GetName().Name, "System.Windows.Forms"))
{
- Type driver_type = asm.GetType("System.Windows.Forms.XplatUICarbon");
+ Type? driver_type = asm.GetType("System.Windows.Forms.XplatUICarbon");
if (driver_type != null)
{
- return (Delegate)driver_type.GetTypeInfo().GetField("HwndDelegate", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
+ return (Delegate?)driver_type.GetTypeInfo().GetField("HwndDelegate", BindingFlags.NonPublic | BindingFlags.Static)!.GetValue(null);
}
}
}
CGContextSaveGState(context);
- Rectangle[] clip_rectangles = (Rectangle[])hwnd_delegate.DynamicInvoke(new object[] { handle });
+ Rectangle[]? clip_rectangles = (Rectangle[]?)hwnd_delegate!.DynamicInvoke(new object[] { handle });
if (clip_rectangles != null && clip_rectangles.Length > 0)
{
int length = clip_rectangles.Length;
// See the LICENSE file in the project root for more information.
using System.Configuration;
+using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
/// </summary>
/// <param name="logicalImage">The image to scale from logical units to device units</param>
/// <param name="targetImageSize">The size to scale image to</param>
- public static Bitmap CreateResizedBitmap(Bitmap logicalImage, Size targetImageSize)
+ [return: NotNullIfNotNull("logicalImage")]
+ public static Bitmap? CreateResizedBitmap(Bitmap? logicalImage, Size targetImageSize)
{
if (logicalImage == null)
{
/// Note: this method should be called only inside an if (DpiHelper.IsScalingRequired) clause
/// </summary>
/// <param name="logicalBitmap">The image to scale from logical units to device units</param>
- public static void ScaleBitmapLogicalToDevice(ref Bitmap logicalBitmap)
+ public static void ScaleBitmapLogicalToDevice([NotNullIfNotNull("logicalBitmap")]ref Bitmap? logicalBitmap)
{
if (logicalBitmap == null)
{
private IntPtr _hDC;
private readonly DeviceContextType _dcType;
- public event EventHandler Disposing;
+ public event EventHandler? Disposing;
private bool _disposed;
private IntPtr _hCurrentBmp;
private IntPtr _hCurrentFont;
- private Stack _contextStack;
+ private Stack? _contextStack;
#if GDI_FINALIZATION_WATCH
private string AllocationSite = DbgUtil.StackTrace;
/// <summary>
/// CreateDC creates a DeviceContext object wrapping an hdc created with the Win32 CreateDC function.
/// </summary>
- public static DeviceContext CreateDC(string driverName, string deviceName, string fileName, IntPtr devMode)
+ public static DeviceContext CreateDC(string driverName, string deviceName, string? fileName, IntPtr devMode)
{
// Note: All input params can be null but not at the same time. See MSDN for information.
IntPtr hdc = Interop.Gdi32.CreateDCW(driverName, deviceName, fileName, devMode);
/// <summary>
/// CreateIC creates a DeviceContext object wrapping an hdc created with the Win32 CreateIC function.
/// </summary>
- public static DeviceContext CreateIC(string driverName, string deviceName, string fileName, IntPtr devMode)
+ public static DeviceContext CreateIC(string driverName, string deviceName, string? fileName, IntPtr devMode)
{
// Note: All input params can be null but not at the same time. See MSDN for information.
if (_contextStack != null)
{
- GraphicsState g = (GraphicsState)_contextStack.Pop();
+ GraphicsState g = (GraphicsState)_contextStack.Pop()!;
_hCurrentBmp = g.hBitmap;
_hCurrentBrush = g.hBrush;
/// <summary>
/// </summary>
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
- DeviceContext other = obj as DeviceContext;
+ DeviceContext? other = obj as DeviceContext;
if (other == this)
{
internal static class DeviceContexts
{
[ThreadStatic]
- private static ClientUtils.WeakRefCollection t_activeDeviceContexts;
+ private static ClientUtils.WeakRefCollection? t_activeDeviceContexts;
/// <summary>
/// WindowsGraphicsCacheManager needs to track DeviceContext objects so it can ask them if a font is in use
}
}
- private static void OnDcDisposing(object sender, EventArgs e)
+ private static void OnDcDisposing(object? sender, EventArgs e)
{
if (sender is DeviceContext dc)
{
// Note: this dc is only disposed when owned (created) by the WindowsGraphics.
private DeviceContext _dc;
private bool _disposeDc;
- private Graphics _graphics; // cached when initialized FromGraphics to be able to call g.ReleaseHdc from Dispose.
+ private Graphics? _graphics; // cached when initialized FromGraphics to be able to call g.ReleaseHdc from Dispose.
#if GDI_FINALIZATION_WATCH
private string AllocationSite = DbgUtil.StackTrace;
{
Debug.Assert(g != null, "null Graphics object.");
- WindowsRegion wr = null;
- float[] elements = null;
+ WindowsRegion? wr = null;
+ float[]? elements = null;
- Region clipRgn = null;
- Matrix worldTransf = null;
+ Region? clipRgn = null;
+ Matrix? worldTransf = null;
if ((properties & ApplyGraphicsProperties.TranslateTransform) != 0 || (properties & ApplyGraphicsProperties.Clipping) != 0)
{
}
finally
{
- _dc = null;
+ _dc = null!;
}
}
}