forked from ReClassNET/ReClass.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseTextNode.cs
More file actions
98 lines (77 loc) · 2.48 KB
/
Copy pathBaseTextNode.cs
File metadata and controls
98 lines (77 loc) · 2.48 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System;
using System.Diagnostics.Contracts;
using System.Drawing;
using ReClassNET.UI;
using ReClassNET.Util;
namespace ReClassNET.Nodes
{
[ContractClass(typeof(BaseTextNodeContract))]
public abstract class BaseTextNode : BaseNode
{
public int Length { get; set; }
/// <summary>Size of the node in bytes.</summary>
public override int MemorySize => Length * CharacterSize;
/// <summary>Size of one character in bytes.</summary>
public abstract int CharacterSize { get; }
public override void CopyFromNode(BaseNode node)
{
Length = node.MemorySize / CharacterSize;
}
protected Size DrawText(ViewInfo view, int x, int y, string type, int length, string text)
{
Contract.Requires(view != null);
Contract.Requires(type != null);
Contract.Requires(text != null);
if (IsHidden)
{
return DrawHidden(view, x, y);
}
DrawInvalidMemoryIndicator(view, y);
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;
x = AddText(view, x, y, view.Settings.NameColor, HotSpot.NameId, Name);
x = AddText(view, x, y, view.Settings.IndexColor, HotSpot.NoneId, "[");
x = AddText(view, x, y, view.Settings.IndexColor, 0, length.ToString());
x = AddText(view, x, y, view.Settings.IndexColor, HotSpot.NoneId, "]") + view.Font.Width;
x = AddText(view, x, y, view.Settings.TextColor, HotSpot.NoneId, "= '");
x = AddText(view, x, y, view.Settings.TextColor, HotSpot.NoneId, text.LimitLength(150));
x = AddText(view, x, y, view.Settings.TextColor, HotSpot.NoneId, "'") + view.Font.Width;
x = AddComment(view, x, y);
AddTypeDrop(view, y);
AddDelete(view, y);
return new Size(x - origX, view.Font.Height);
}
public override int CalculateDrawnHeight(ViewInfo view)
{
return IsHidden ? HiddenHeight : view.Font.Height;
}
public override void Update(HotSpot spot)
{
base.Update(spot);
if (spot.Id == 0)
{
if (int.TryParse(spot.Text, out var val) && val > 0)
{
Length = val;
ParentNode.ChildHasChanged(this);
}
}
}
}
[ContractClassFor(typeof(BaseTextNode))]
internal abstract class BaseTextNodeContract : BaseTextNode
{
public override int CharacterSize
{
get
{
Contract.Ensures(Contract.Result<int>() > 0);
throw new NotImplementedException();
}
}
}
}