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; /// The encoding of the string. public abstract Encoding Encoding { get; } /// Draws this node. /// The view information. /// The x coordinate. /// The y coordinate. /// The name of the type. /// The pixel size the node occupies. 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; } } }