Skip to content

Commit

Permalink
Move Font*, Image* and Margins converters to System.Drawing.Common an…
Browse files Browse the repository at this point in the history
…d apply Unit and Name converter (#40825)

* Move Font, Image, and Margins converters to System.Drawing.Common

* Add FontUnit converter and FontName converter to Font properties

* Fix Unix tests

* Sort Compile items
  • Loading branch information
safern authored Aug 15, 2020
1 parent 1d6fc68 commit 1dbdb8b
Show file tree
Hide file tree
Showing 29 changed files with 414 additions and 356 deletions.
93 changes: 75 additions & 18 deletions src/libraries/System.Drawing.Common/ref/System.Drawing.Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,7 @@ public enum CopyPixelOperation
Whiteness = 16711778,
CaptureBlt = 1073741824,
}
#if NETCOREAPP
[System.ComponentModel.TypeConverterAttribute("System.Drawing.FontConverter, System.Windows.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51")]
#endif
[System.ComponentModel.TypeConverterAttribute(typeof(System.Drawing.FontConverter))]
public sealed partial class Font : System.MarshalByRefObject, System.ICloneable, System.IDisposable, System.Runtime.Serialization.ISerializable
{
public Font(System.Drawing.Font prototype, System.Drawing.FontStyle newStyle) { }
Expand Down Expand Up @@ -301,6 +299,7 @@ public Font(string familyName, float emSize, System.Drawing.GraphicsUnit unit) {
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public bool Italic { get { throw null; } }
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[System.ComponentModel.TypeConverterAttribute(typeof(System.Drawing.FontConverter.FontNameConverter))]
public string Name { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public string? OriginalFontName { get { throw null; } }
Expand All @@ -315,6 +314,7 @@ public Font(string familyName, float emSize, System.Drawing.GraphicsUnit unit) {
public string SystemFontName { get { throw null; } }
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public bool Underline { get { throw null; } }
[System.ComponentModel.TypeConverterAttribute(typeof(System.Drawing.FontConverter.FontUnitConverter))]
public System.Drawing.GraphicsUnit Unit { get { throw null; } }
public object Clone() { throw null; }
public void Dispose() { }
Expand All @@ -334,6 +334,33 @@ public void ToLogFont(object logFont) { }
public void ToLogFont(object logFont, System.Drawing.Graphics graphics) { }
public override string ToString() { throw null; }
}
public partial class FontConverter : System.ComponentModel.TypeConverter
{
public FontConverter() { }
public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type? sourceType) { throw null; }
public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) { throw null; }
public override object? ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value) { throw null; }
public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type destinationType) { throw null; }
public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext? context, System.Collections.IDictionary propertyValues) { throw null; }
public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext? context) { throw null; }
public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext? context, object? value, System.Attribute[]? attributes) { throw null; }
public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; }
public sealed partial class FontNameConverter : System.ComponentModel.TypeConverter, System.IDisposable
{
public FontNameConverter() { }
public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type? sourceType) { throw null; }
public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value) { throw null; }
public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext? context) { throw null; }
public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext? context) { throw null; }
public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext? context) { throw null; }
void System.IDisposable.Dispose() { }
}
public partial class FontUnitConverter : System.ComponentModel.EnumConverter
{
public FontUnitConverter() : base (default(System.Type)) { }
public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext? context) { throw null; }
}
}
public sealed partial class FontFamily : System.MarshalByRefObject, System.IDisposable
{
public FontFamily(System.Drawing.Text.GenericFontFamilies genericFamily) { }
Expand Down Expand Up @@ -629,9 +656,7 @@ public enum GraphicsUnit
Document = 5,
Millimeter = 6,
}
#if NETCOREAPP
[System.ComponentModel.TypeConverterAttribute("System.Drawing.IconConverter, System.Windows.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51")]
#endif
[System.ComponentModel.TypeConverterAttribute(typeof(System.Drawing.IconConverter))]
public sealed partial class Icon : System.MarshalByRefObject, System.ICloneable, System.IDisposable, System.Runtime.Serialization.ISerializable
{
public Icon(System.Drawing.Icon original, System.Drawing.Size size) { }
Expand Down Expand Up @@ -660,15 +685,21 @@ void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Ser
public System.Drawing.Bitmap ToBitmap() { throw null; }
public override string ToString() { throw null; }
}
public partial class IconConverter : System.ComponentModel.ExpandableObjectConverter
{
public IconConverter() { }
public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { throw null; }
public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { throw null; }
public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { throw null; }
public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { throw null; }
}
public partial interface IDeviceContext : System.IDisposable
{
System.IntPtr GetHdc();
void ReleaseHdc();
}
[System.ComponentModel.ImmutableObjectAttribute(true)]
#if NETCOREAPP
[System.ComponentModel.TypeConverterAttribute("System.Drawing.ImageConverter, System.Windows.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51")]
#endif
[System.ComponentModel.TypeConverterAttribute(typeof(System.Drawing.ImageConverter))]
public abstract partial class Image : System.MarshalByRefObject, System.ICloneable, System.IDisposable, System.Runtime.Serialization.ISerializable
{
internal Image() { }
Expand Down Expand Up @@ -742,6 +773,26 @@ public static void StopAnimate(System.Drawing.Image image, System.EventHandler o
public static void UpdateFrames() { }
public static void UpdateFrames(System.Drawing.Image image) { }
}
public partial class ImageConverter : System.ComponentModel.TypeConverter
{
public ImageConverter() { }
public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type? sourceType) { throw null; }
public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) { throw null; }
public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value) { throw null; }
public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type destinationType) { throw null; }
public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext? context, object? value, System.Attribute[]? attributes) { throw null; }
public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext? context) { throw null; }
}
public partial class ImageFormatConverter : System.ComponentModel.TypeConverter
{
public ImageFormatConverter() { }
public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type? sourceType) { throw null; }
public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) { throw null; }
public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value) { throw null; }
public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type destinationType) { throw null; }
public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext? context) { throw null; }
public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext? context) { throw null; }
}
public sealed partial class Pen : System.MarshalByRefObject, System.ICloneable, System.IDisposable
{
public Pen(System.Drawing.Brush brush) { }
Expand Down Expand Up @@ -961,7 +1012,7 @@ public void Intersect(System.Drawing.Region region) { }
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(int x, int y, 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(float x, float y) { throw null; }
Expand Down Expand Up @@ -2292,9 +2343,7 @@ public enum ImageFlags
ReadOnly = 65536,
Caching = 131072,
}
#if NETCOREAPP
[System.ComponentModel.TypeConverterAttribute("System.Drawing.ImageFormatConverter, System.Windows.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51")]
#endif
[System.ComponentModel.TypeConverterAttribute(typeof(System.Drawing.ImageFormatConverter))]
public sealed partial class ImageFormat
{
public ImageFormat(System.Guid guid) { }
Expand Down Expand Up @@ -2491,9 +2540,7 @@ public InvalidPrinterException(System.Drawing.Printing.PrinterSettings settings)
protected InvalidPrinterException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
}
#if NETCOREAPP
[System.ComponentModel.TypeConverterAttribute("System.Drawing.Printing.MarginsConverter, System.Windows.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51")]
#endif
[System.ComponentModel.TypeConverterAttribute(typeof(System.Drawing.Printing.MarginsConverter))]
public partial class Margins : System.ICloneable
{
public Margins() { }
Expand All @@ -2505,10 +2552,20 @@ public Margins(int left, int right, int top, int bottom) { }
public object Clone() { 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 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 override string ToString() { throw null; }
}
public partial class MarginsConverter : System.ComponentModel.ExpandableObjectConverter
{
public MarginsConverter() { }
public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type? sourceType) { throw null; }
public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Type? destinationType) { throw null; }
public override object? ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value) { throw null; }
public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type destinationType) { throw null; }
public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext? context, System.Collections.IDictionary propertyValues) { throw null; }
public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext? context) { throw null; }
}
public partial class PageSettings : System.ICloneable
{
public PageSettings() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@
</data>
<data name="InvalidArgumentValue" xml:space="preserve">
<value>Value of '{1}' is not valid for '{0}'.</value>
</data>
<data name="InvalidArgumentValueFontConverter" xml:space="preserve">
<value>Value of '{0}' is not valid for font size unit.</value>
</data>
<data name="InvalidBoundArgument" xml:space="preserve">
<value>Value of '{1}' is not valid for '{0}'. '{0}' should be greater than {2} and less than or equal to {3}.</value>
Expand Down Expand Up @@ -437,6 +440,9 @@
<data name="NotImplementedUnderX11" xml:space="preserve">
<value>Operation not implemented under X11</value>
</data>
<data name="none" xml:space="preserve">
<value>(none)</value>
</data>
<data name="NoValidIconImageFound" xml:space="preserve">
<value>No valid icon image found</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
<Compile Include="System\Drawing\GdiplusNative.cs" />
<Compile Include="System\Drawing\Graphics.cs" />
<Compile Include="System\Drawing\GraphicsUnit.cs" />
<Compile Include="System\Drawing\IconConverter.cs" />
<Compile Include="System\Drawing\Image.cs" />
<Compile Include="System\Drawing\ImageConverter.cs" />
<Compile Include="System\Drawing\ImageFormatConverter.cs" />
<Compile Include="System\Drawing\ImageType.cs" />
<Compile Include="System\Drawing\Pen.cs" />
<Compile Include="System\Drawing\Pens.cs" />
Expand Down Expand Up @@ -116,6 +119,7 @@
<Compile Include="System\Drawing\Internal\ISystemEventTracker.cs" />
<Compile Include="System\Drawing\Brush.cs" />
<Compile Include="System\Drawing\Font.cs" />
<Compile Include="System\Drawing\FontConverter.cs" />
<Compile Include="System\Drawing\FontFamily.cs" />
<Compile Include="System\Drawing\SolidBrush.cs" />
<Compile Include="System\Drawing\SystemBrushes.cs" />
Expand All @@ -130,6 +134,7 @@
<Compile Include="System\Drawing\Printing\InvalidPrinterException.cs" />
<Compile Include="System\Drawing\Printing\InvalidPrinterException.Core.cs" />
<Compile Include="System\Drawing\Printing\Margins.cs" />
<Compile Include="System\Drawing\Printing\MarginsConverter.cs" />
<Compile Include="System\Drawing\Printing\PaperKinds.cs" />
<Compile Include="System\Drawing\Printing\PaperSize.cs" />
<Compile Include="System\Drawing\Printing\PaperSource.cs" />
Expand Down Expand Up @@ -158,6 +163,8 @@
Link="Common\Interop\Windows\User32\Interop.LOGFONT.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Gdi32\Interop.RasterOp.cs"
Link="Common\Interop\Windows\Gdi32\Interop.RasterOp.cs" />
<Compile Include="$(CommonPath)System\Text\ValueStringBuilder.cs"
Link="Common\System\Text\ValueStringBuilder.cs" />
<EmbeddedResource Include="Resources\System\Drawing\DefaultComponent.bmp">
<LogicalName>System.Drawing.DefaultComponent.bmp</LogicalName>
</EmbeddedResource>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ namespace System.Drawing
/// <summary>
/// Defines a particular format for text, including font face, size, and style attributes.
/// </summary>
#if NETCOREAPP
[TypeConverter("System.Drawing.FontConverter, System.Windows.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51")]
#endif
[TypeConverter(typeof(FontConverter))]
[Serializable]
[System.Runtime.CompilerServices.TypeForwardedFrom("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public sealed partial class Font : MarshalByRefObject, ICloneable, IDisposable, ISerializable
Expand Down Expand Up @@ -76,11 +74,13 @@ public sealed partial class Font : MarshalByRefObject, ICloneable, IDisposable,
/// Gets the face name of this <see cref='Font'/> .
/// </summary>
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[TypeConverter(typeof(FontConverter.FontNameConverter))]
public string Name => FontFamily.Name;

/// <summary>
/// Gets the unit of measure for this <see cref='Font'/>.
/// </summary>
[TypeConverter(typeof(FontConverter.FontUnitConverter))]
public GraphicsUnit Unit => _fontUnit;

/// <summary>
Expand Down
Loading

0 comments on commit 1dbdb8b

Please sign in to comment.