Skip to content

Commit e82e0d8

Browse files
committed
Added IconProvider.
1 parent bb96209 commit e82e0d8

34 files changed

+108
-87
lines changed

ReClass.NET/Controls/DrawContextRequestEventArgs.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using ReClassNET.Memory;
33
using ReClassNET.Nodes;
4+
using ReClassNET.UI;
45

56
namespace ReClassNET.Controls
67
{
@@ -10,6 +11,8 @@ public class DrawContextRequestEventArgs : EventArgs
1011

1112
public Settings Settings { get; set; }
1213

14+
public IconProvider IconProvider { get; set; }
15+
1316
public RemoteProcess Process { get; set; }
1417

1518
public MemoryBuffer Memory { get; set; }

ReClass.NET/Controls/MemoryViewControl.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ protected override void OnPaint(PaintEventArgs e)
126126
Settings = args.Settings,
127127
Context = e.Graphics,
128128
Font = font,
129+
IconProvider = args.IconProvider,
129130
Process = args.Process,
130131
Memory = args.Memory,
131132
CurrentTime = args.CurrentTime,

ReClass.NET/Controls/ViewInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class ViewInfo
1212

1313
public Graphics Context { get; set; }
1414
public FontEx Font { get; set; }
15+
public IconProvider IconProvider { get; set; }
1516

1617
public RemoteProcess Process { get; set; }
1718
public MemoryBuffer Memory { get; set; }
@@ -31,6 +32,7 @@ public ViewInfo Clone()
3132
Settings = Settings,
3233
Context = Context,
3334
Font = Font,
35+
IconProvider = IconProvider,
3436
Process = Process,
3537
Memory = Memory,
3638
CurrentTime = CurrentTime,

ReClass.NET/Forms/MainForm.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ namespace ReClassNET.Forms
2727
public partial class MainForm : IconForm
2828
{
2929
private readonly PluginManager pluginManager;
30+
private readonly IconProvider iconProvider = new IconProvider();
3031

3132
private ReClassNetProject currentProject;
3233
public ReClassNetProject CurrentProject => currentProject;
@@ -1011,6 +1012,7 @@ private void memoryViewControl_DrawContextRequested(object sender, DrawContextRe
10111012
memoryViewBuffer.UpdateFrom(process, address);
10121013

10131014
args.Settings = Program.Settings;
1015+
args.IconProvider = iconProvider;
10141016
args.Process = process;
10151017
args.Memory = memoryViewBuffer;
10161018
args.Node = classNode;

ReClass.NET/Nodes/BaseFunctionPtrNode.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ protected Size Draw(ViewInfo view, int x, int y, string type, string name)
3737

3838
AddSelection(view, x, y, view.Font.Height);
3939

40-
x += TextPadding;
40+
x = AddIconPadding(view, x);
4141

42-
x = AddIcon(view, x, y, Icons.Function, HotSpot.NoneId, HotSpotType.None);
42+
x = AddIcon(view, x, y, view.IconProvider.Function, HotSpot.NoneId, HotSpotType.None);
4343

4444
var tx = x;
4545

ReClass.NET/Nodes/BaseHexNode.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ protected Size Draw(ViewInfo view, int x, int y, string text, int length)
4545

4646
AddSelection(view, x, y, view.Font.Height);
4747

48-
x += TextPadding + 16;
48+
x = AddIconPadding(view, x);
49+
x = AddIconPadding(view, x);
50+
4951
x = AddAddressOffset(view, x, y);
5052

5153
if (!string.IsNullOrEmpty(text))

ReClass.NET/Nodes/BaseMatrixNode.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ protected Size DrawMatrixType(ViewInfo view, int x, int y, string type, DrawMatr
3333

3434
AddSelection(view, x, y, view.Font.Height);
3535

36-
x += TextPadding;
36+
x = AddIconPadding(view, x);
3737

38-
x = AddIcon(view, x, y, Icons.Matrix, HotSpot.NoneId, HotSpotType.None);
38+
x = AddIcon(view, x, y, view.IconProvider.Matrix, HotSpot.NoneId, HotSpotType.None);
3939

4040
var tx = x;
4141

@@ -83,9 +83,9 @@ protected Size DrawVectorType(ViewInfo view, int x, int y, string type, DrawVect
8383

8484
AddSelection(view, x, y, view.Font.Height);
8585

86-
x += TextPadding;
86+
x = AddIconPadding(view, x);
8787

88-
x = AddIcon(view, x, y, Icons.Vector, HotSpot.NoneId, HotSpotType.None);
88+
x = AddIcon(view, x, y, view.IconProvider.Vector, HotSpot.NoneId, HotSpotType.None);
8989
x = AddAddressOffset(view, x, y);
9090

9191
x = AddText(view, x, y, view.Settings.TypeColor, HotSpot.NoneId, type) + view.Font.Width;

ReClass.NET/Nodes/BaseNode.cs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public abstract class BaseNode
2020

2121
internal static readonly List<INodeInfoReader> NodeInfoReader = new List<INodeInfoReader>();
2222

23-
protected static readonly int TextPadding = Icons.Dimensions;
2423
protected static readonly int HiddenHeight = 0;
2524

2625
private static int nodeIndex = 0;
@@ -383,6 +382,11 @@ protected void AddSelection(ViewInfo view, int x, int y, int height)
383382
AddHotSpot(view, new Rectangle(0, y, view.ClientArea.Right - (IsSelected ? 16 : 0), height), string.Empty, HotSpot.NoneId, HotSpotType.Select);
384383
}
385384

385+
protected int AddIconPadding(ViewInfo view, int x)
386+
{
387+
return x + view.IconProvider.Dimensions;
388+
}
389+
386390
/// <summary>Draws an icon and adds a <see cref="HotSpot"/> if <paramref name="id"/> is not <see cref="HotSpot.NoneId"/>.</summary>
387391
/// <param name="view">The view information.</param>
388392
/// <param name="x">The x coordinate.</param>
@@ -397,19 +401,21 @@ protected int AddIcon(ViewInfo view, int x, int y, Image icon, int id, HotSpotTy
397401
Contract.Requires(view.Context != null);
398402
Contract.Requires(icon != null);
399403

400-
if (y > view.ClientArea.Bottom || y + Icons.Dimensions < 0)
404+
var size = view.IconProvider.Dimensions;
405+
406+
if (y > view.ClientArea.Bottom || y + size < 0)
401407
{
402-
return x + Icons.Dimensions;
408+
return x + size;
403409
}
404410

405-
view.Context.DrawImage(icon, x + 2, y, Icons.Dimensions, Icons.Dimensions);
411+
view.Context.DrawImage(icon, x + 2, y, size, size);
406412

407413
if (id != HotSpot.NoneId)
408414
{
409-
AddHotSpot(view, new Rectangle(x, y, Icons.Dimensions, Icons.Dimensions), string.Empty, id, type);
415+
AddHotSpot(view, new Rectangle(x, y, size, size), string.Empty, id, type);
410416
}
411417

412-
return x + Icons.Dimensions;
418+
return x + size;
413419
}
414420

415421
/// <summary>Adds a togglable Open/Close icon.</summary>
@@ -422,12 +428,13 @@ protected int AddOpenCloseIcon(ViewInfo view, int x, int y)
422428
Contract.Requires(view != null);
423429
Contract.Requires(view.Context != null);
424430

425-
if (y > view.ClientArea.Bottom || y + Icons.Dimensions < 0)
431+
if (y > view.ClientArea.Bottom || y + view.IconProvider.Dimensions < 0)
426432
{
427-
return x + Icons.Dimensions;
433+
return x + view.IconProvider.Dimensions;
428434
}
429435

430-
return AddIcon(view, x, y, LevelsOpen[view.Level] ? Icons.OpenCloseOpen : Icons.OpenCloseClosed, 0, HotSpotType.OpenClose);
436+
var icon = LevelsOpen[view.Level] ? view.IconProvider.OpenCloseOpen : view.IconProvider.OpenCloseClosed;
437+
return AddIcon(view, x, y, icon, 0, HotSpotType.OpenClose);
431438
}
432439

433440
/// <summary>Draws a context drop icon if the node is selected.</summary>
@@ -438,14 +445,14 @@ protected void AddContextDropDownIcon(ViewInfo view, int y)
438445
Contract.Requires(view != null);
439446
Contract.Requires(view.Context != null);
440447

441-
if (view.MultipleNodesSelected || y > view.ClientArea.Bottom || y + Icons.Dimensions < 0 || IsWrapped)
448+
if (view.MultipleNodesSelected || y > view.ClientArea.Bottom || y + view.IconProvider.Dimensions < 0 || IsWrapped)
442449
{
443450
return;
444451
}
445452

446453
if (IsSelected)
447454
{
448-
AddIcon(view, 0, y, Icons.DropArrow, 0, HotSpotType.Context);
455+
AddIcon(view, 0, y, view.IconProvider.DropArrow, 0, HotSpotType.Context);
449456
}
450457
}
451458

@@ -457,14 +464,14 @@ protected void AddDeleteIcon(ViewInfo view, int y)
457464
Contract.Requires(view != null);
458465
Contract.Requires(view.Context != null);
459466

460-
if (y > view.ClientArea.Bottom || y + Icons.Dimensions < 0 || IsWrapped)
467+
if (y > view.ClientArea.Bottom || y + view.IconProvider.Dimensions < 0 || IsWrapped)
461468
{
462469
return;
463470
}
464471

465472
if (IsSelected)
466473
{
467-
AddIcon(view, view.ClientArea.Right - Icons.Dimensions, y, Icons.Delete, 0, HotSpotType.Delete);
474+
AddIcon(view, view.ClientArea.Right - view.IconProvider.Dimensions, y, view.IconProvider.Delete, 0, HotSpotType.Delete);
468475
}
469476
}
470477

ReClass.NET/Nodes/BaseNumericNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected Size DrawNumeric(ViewInfo view, int x, int y, Image icon, string type,
3232

3333
AddSelection(view, x, y, view.Font.Height);
3434

35-
x += TextPadding;
35+
x = AddIconPadding(view, x);
3636

3737
x = AddIcon(view, x, y, icon, HotSpot.NoneId, HotSpotType.None);
3838
x = AddAddressOffset(view, x, y);

ReClass.NET/Nodes/BaseTextNode.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ protected Size DrawText(ViewInfo view, int x, int y, string type)
4242

4343
AddSelection(view, x, y, view.Font.Height);
4444

45-
x += TextPadding;
46-
x = AddIcon(view, x, y, Icons.Text, HotSpot.NoneId, HotSpotType.None);
45+
x = AddIconPadding(view, x);
46+
47+
x = AddIcon(view, x, y, view.IconProvider.Text, HotSpot.NoneId, HotSpotType.None);
4748
x = AddAddressOffset(view, x, y);
4849

4950
x = AddText(view, x, y, view.Settings.TypeColor, HotSpot.NoneId, type) + view.Font.Width;

0 commit comments

Comments
 (0)