Skip to content

Commit 1d322a0

Browse files
committed
renamed D2DGraphics to DXGraphics
1 parent 44ac15d commit 1d322a0

File tree

6 files changed

+21
-22
lines changed

6 files changed

+21
-22
lines changed

README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ Install-Package D2Phap.DXControl
3131
## Example
3232

3333

34-
<img src="https://user-images.githubusercontent.com/3154213/185740243-6a3cb1b6-13e6-4888-8c57-ce8ac9998c6e.png" width="500" />
34+
<img src="https://github.com/user-attachments/assets/837414d9-b342-487b-99c9-056b8a24205d" width="500" />
3535

3636
Draws a rectangle, then moves it to the right side.
3737

3838
```cs
39-
using D2Phap;
39+
using D2Phap.DXControl;
4040

4141
// create a WinForms custom control that extends from DXCanvas
4242
public class DemoCanvas : DXCanvas
@@ -49,7 +49,7 @@ public class DemoCanvas : DXCanvas
4949
UseHardwareAcceleration = true;
5050
}
5151

52-
protected override void OnRender(D2DGraphics g)
52+
protected override void OnRender(DXGraphics g)
5353
{
5454
// draw a yellow rectangle with green border
5555
g.FillRectangle(rectText, Color.FromArgb(100, Yellow));
@@ -75,7 +75,6 @@ See Demo project for full details.
7575
- [GitHub sponsor](https://github.com/sponsors/d2phap)
7676
- [Patreon](https://www.patreon.com/d2phap)
7777
- [PayPal](https://www.paypal.me/d2phap)
78-
- [Wire Transfers](https://donorbox.org/imageglass)
7978

8079
Thanks for your gratitude and finance help!
8180

Source/DXControl/DXCanvas.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class DXCanvas : Control
2727
protected IComObject<IDWriteFactory5>? _dWriteFactory = null;
2828
protected IComObject<ID2D1HwndRenderTarget>? _renderTarget;
2929
protected IComObject<ID2D1DeviceContext6>? _device;
30-
protected D2DGraphics? _graphicsD2d;
30+
protected DXGraphics? _graphicsD2d;
3131

3232

3333
protected bool _useHardwardAcceleration = true;
@@ -71,10 +71,10 @@ public class DXCanvas : Control
7171

7272

7373
/// <summary>
74-
/// Gets the <see cref='D2DGraphics'/> object used to draw in <see cref="Render"/>.
74+
/// Gets the <see cref='DXGraphics'/> object used to draw in <see cref="Render"/>.
7575
/// </summary>
7676
[Browsable(false)]
77-
public D2DGraphics? D2Graphics => _graphicsD2d;
77+
public DXGraphics? D2Graphics => _graphicsD2d;
7878

7979

8080
/// <summary>
@@ -85,7 +85,7 @@ public class DXCanvas : Control
8585

8686

8787
/// <summary>
88-
/// Gets, sets the DPI for drawing when using <see cref="D2DGraphics"/>.
88+
/// Gets, sets the DPI for drawing when using <see cref="DXGraphics"/>.
8989
/// </summary>
9090
[Browsable(false)]
9191
public float BaseDpi
@@ -171,7 +171,7 @@ public virtual bool UseHardwareAcceleration
171171

172172

173173
/// <summary>
174-
/// Occurs when the control is being rendered by <see cref="D2DGraphics"/>.
174+
/// Occurs when the control is being rendered by <see cref="DXGraphics"/>.
175175
/// </summary>
176176
public event EventHandler<RenderEventArgs>? Render;
177177

@@ -271,7 +271,7 @@ protected virtual void CreateDevice(DeviceCreatedReason reason)
271271

272272
// create devide and graphics
273273
_device = _renderTarget.AsComObject<ID2D1DeviceContext6>();
274-
_graphicsD2d = new D2DGraphics(_device, _d2DFactory, _dWriteFactory);
274+
_graphicsD2d = new DXGraphics(_device, _d2DFactory, _dWriteFactory);
275275

276276

277277
OnDeviceCreated(reason);
@@ -308,7 +308,7 @@ protected virtual void OnDeviceCreated(DeviceCreatedReason reason)
308308
/// <summary>
309309
/// Triggers <see cref="Render"/> event to paint the control.
310310
/// </summary>
311-
protected virtual void OnRender(D2DGraphics g)
311+
protected virtual void OnRender(DXGraphics g)
312312
{
313313
if (!IsReady) return;
314314
Render?.Invoke(this, new(g));
@@ -490,7 +490,7 @@ protected override void OnPaintBackground(PaintEventArgs e)
490490

491491

492492
/// <summary>
493-
/// <b>Do use</b> <see cref="OnRender(D2DGraphics)"/> if you want to draw on the control.
493+
/// <b>Do use</b> <see cref="OnRender(DXGraphics)"/> if you want to draw on the control.
494494
/// </summary>
495495
protected override void OnPaint(PaintEventArgs e)
496496
{

Source/DXControl/D2DGraphics.cs Source/DXControl/DXGraphics.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace D2Phap.DXControl;
1212
/// <summary>
1313
/// Encapsulates a Direct2D drawing surface.
1414
/// </summary>
15-
public class D2DGraphics : IDisposable
15+
public class DXGraphics : IDisposable
1616
{
1717
#region IDisposable Disposing
1818

@@ -38,7 +38,7 @@ public virtual void Dispose()
3838
GC.SuppressFinalize(this);
3939
}
4040

41-
~D2DGraphics()
41+
~DXGraphics()
4242
{
4343
Dispose(false);
4444
}
@@ -99,10 +99,10 @@ public bool UseAntialias
9999

100100

101101
/// <summary>
102-
/// Initialize new instance of <see cref="D2DGraphics"/>.
102+
/// Initialize new instance of <see cref="DXGraphics"/>.
103103
/// </summary>
104104
/// <exception cref="ArgumentNullException"></exception>
105-
public D2DGraphics(IComObject<ID2D1DeviceContext6>? dc, IComObject<ID2D1Factory1>? d2dF, IComObject<IDWriteFactory5>? wf)
105+
public DXGraphics(IComObject<ID2D1DeviceContext6>? dc, IComObject<ID2D1Factory1>? d2dF, IComObject<IDWriteFactory5>? wf)
106106
{
107107
if (dc == null)
108108
{

Source/DXControl/Enums.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public enum DeviceCreatedReason
1818

1919

2020
/// <summary>
21-
/// Interpolation mode for <see cref="D2DGraphics"/>.
21+
/// Interpolation mode for <see cref="DXGraphics"/>.
2222
/// </summary>
2323
public enum InterpolationMode
2424
{

Source/DXControl/Events.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ namespace D2Phap.DXControl;
1010
/// <summary>
1111
/// Provides the data for <see cref="DXCanvas.Render"/> event.
1212
/// </summary>
13-
public class RenderEventArgs(D2DGraphics g) : EventArgs
13+
public class RenderEventArgs(DXGraphics g) : EventArgs
1414
{
1515
/// <summary>
16-
/// Gets the <see cref='D2DGraphics'/> object used to draw.
16+
/// Gets the <see cref='DXGraphics'/> object used to draw.
1717
/// </summary>
18-
public D2DGraphics Graphics { get; init; } = g;
18+
public DXGraphics Graphics { get; init; } = g;
1919
}
2020

2121

Source/Demo/DemoCanvas.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ protected override void OnDeviceCreated(DeviceCreatedReason reason)
6161
}
6262

6363

64-
protected override void OnRender(D2DGraphics g)
64+
protected override void OnRender(DXGraphics g)
6565
{
6666
var p1 = new Point(0, 0);
6767
var p2 = new Point(ClientSize.Width, ClientSize.Height);
@@ -98,7 +98,7 @@ protected override void OnRender(D2DGraphics g)
9898

9999

100100
// draw geometry D2D only
101-
if (g is D2DGraphics dg)
101+
if (g is DXGraphics dg)
102102
{
103103
using var geo = dg.GetCombinedRectanglesGeometry(new RectangleF(200, 300, 300, 300),
104104
new Rectangle(250, 250, 300, 100), 0, 0, D2D1_COMBINE_MODE.D2D1_COMBINE_MODE_INTERSECT);

0 commit comments

Comments
 (0)