Skip to content

Commit 5125ee0

Browse files
authored
Merge pull request #801 from ds5678/primitive-implicit-conversions
Implicit Conversions to System.Drawing structs
2 parents d225324 + 4be5cef commit 5125ee0

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

src/ElectronNET.API/Entities/Point.cs

+9
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,14 @@ public class Point
2020
/// The y.
2121
/// </value>
2222
public int Y { get; set; }
23+
24+
/// <summary>
25+
/// Convert this <see cref="Point"/> to <see cref="System.Drawing.Point"/>.
26+
/// </summary>
27+
/// <param name="point">The point.</param>
28+
public static implicit operator System.Drawing.Point(Point point)
29+
{
30+
return new System.Drawing.Point(point.X, point.Y);
31+
}
2332
}
2433
}

src/ElectronNET.API/Entities/Rectangle.cs

+9
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,14 @@ public class Rectangle
3636
/// The height.
3737
/// </value>
3838
public int Height { get; set; }
39+
40+
/// <summary>
41+
/// Convert this <see cref="Rectangle"/> to <see cref="System.Drawing.Rectangle"/>.
42+
/// </summary>
43+
/// <param name="rectangle">The rectangle.</param>
44+
public static implicit operator System.Drawing.Rectangle(Rectangle rectangle)
45+
{
46+
return new System.Drawing.Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
47+
}
3948
}
4049
}

src/ElectronNET.API/Entities/Size.cs

+9
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,14 @@ public class Size
2020
/// The height.
2121
/// </value>
2222
public int Height { get; set; }
23+
24+
/// <summary>
25+
/// Convert this <see cref="Size"/> to <see cref="System.Drawing.Size"/>.
26+
/// </summary>
27+
/// <param name="size">The size.</param>
28+
public static implicit operator System.Drawing.Size(Size size)
29+
{
30+
return new System.Drawing.Size(size.Width, size.Height);
31+
}
2332
}
2433
}

0 commit comments

Comments
 (0)