forked from ReClassNET/ReClass.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseTextPtrNode.cs
More file actions
69 lines (54 loc) · 2.01 KB
/
BaseTextPtrNode.cs
File metadata and controls
69 lines (54 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Diagnostics.Contracts;
using System.Drawing;
using System.Text;
using ReClassNET.UI;
namespace ReClassNET.Nodes
{
public abstract class BaseTextPtrNode : BaseNode
{
private const int MaxStringCharacterCount = 256;
public override int MemorySize => IntPtr.Size;
/// <summary>The encoding of the string.</summary>
public abstract Encoding Encoding { get; }
/// <summary>Draws this node.</summary>
/// <param name="view">The view information.</param>
/// <param name="x">The x coordinate.</param>
/// <param name="y">The y coordinate.</param>
/// <param name="type">The name of the type.</param>
/// <returns>The pixel size the node occupies.</returns>
public Size DrawText(ViewInfo view, int x, int y, string type)
{
Contract.Requires(view != null);
Contract.Requires(type != null);
if (IsHidden && !IsWrapped)
{
return DrawHidden(view, x, y);
}
var ptr = view.Memory.ReadIntPtr(Offset);
var text = view.Process.ReadRemoteString(Encoding, ptr, MaxStringCharacterCount);
var origX = x;
AddSelection(view, x, y, view.Font.Height);
x += TextPadding;
x = AddIcon(view, x, y, Icons.Text, HotSpot.NoneId, HotSpotType.None);
x = AddAddressOffset(view, x, y);
x = AddText(view, x, y, view.Settings.TypeColor, HotSpot.NoneId, type) + view.Font.Width;
if (!IsWrapped)
{
x = AddText(view, x, y, view.Settings.NameColor, HotSpot.NameId, Name) + view.Font.Width;
}
x = AddText(view, x, y, view.Settings.TextColor, HotSpot.NoneId, "= '");
x = AddText(view, x, y, view.Settings.TextColor, HotSpot.ReadOnlyId, text);
x = AddText(view, x, y, view.Settings.TextColor, HotSpot.NoneId, "'") + view.Font.Width;
x = AddComment(view, x, y);
DrawInvalidMemoryIndicatorIcon(view, y);
AddContextDropDownIcon(view, y);
AddDeleteIcon(view, y);
return new Size(x - origX, view.Font.Height);
}
public override int CalculateDrawnHeight(ViewInfo view)
{
return IsHidden && !IsWrapped ? HiddenHeight : view.Font.Height;
}
}
}