using System.Drawing;
using ReClassNET.Controls;
using ReClassNET.Extensions;
using ReClassNET.UI;
namespace ReClassNET.Nodes
{
public class BoolNode : BaseNumericNode
{
public override int MemorySize => 1;
public override void GetUserInterfaceInfo(out string name, out Image icon)
{
name = "Bool";
icon = Properties.Resources.B16x16_Button_Bool;
}
public override Size Draw(DrawContext context, int x, int y)
{
if (IsHidden && !IsWrapped)
{
return DrawHidden(context, x, y);
}
var origX = x;
AddSelection(context, x, y, context.Font.Height);
x = AddIconPadding(context, x);
x = AddIconPadding(context, x);
x = AddAddressOffset(context, x, y);
x = AddText(context, x, y, context.Settings.TypeColor, HotSpot.NoneId, "Bool") + context.Font.Width;
if (!IsWrapped)
{
x = AddText(context, x, y, context.Settings.NameColor, HotSpot.NameId, Name) + context.Font.Width;
}
x = AddText(context, x, y, context.Settings.NameColor, HotSpot.NoneId, "=") + context.Font.Width;
var value = context.Memory.ReadUInt8(Offset);
x = AddText(context, x, y, context.Settings.ValueColor, 0, value == 0 ? "false" : "true") + context.Font.Width;
x = AddComment(context, x, y);
DrawInvalidMemoryIndicatorIcon(context, y);
AddContextDropDownIcon(context, y);
AddDeleteIcon(context, y);
return new Size(x - origX, context.Font.Height);
}
public override int CalculateDrawnHeight(DrawContext context)
{
return IsHidden && !IsWrapped ? HiddenHeight : context.Font.Height;
}
/// Updates the node from the given spot and sets the value.
/// The spot.
public override void Update(HotSpot spot)
{
base.Update(spot);
if (spot.Id == 0)
{
if (bool.TryParse(spot.Text, out var val))
{
spot.Process.WriteRemoteMemory(spot.Address, (byte)(val ? 1 : 0));
}
}
}
}
}